discord-chat-gpt

2.0.1 • Public • Published

Discord Chat GPT

Advance discord ChatGPT Chat Bot System with Support Slash/Message support

Download

npm i discord-chat-gpt
------ or ---------------------
yarn add discord-chat-gpt

Example

Example

Setting up

Client values

import { Client, GatewayIntentBits } from "discord.js";
import { ChatGPT } from "discord-chat-gpt";

const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildMembers,
  ],
  allowedMentions: {
    repliedUser: false,
  },
});

const chatGpt = new ChatGPT({
  apiKey: `OPEN_AI_KEY`, // get from https://beta.openai.com/account/api-keys
});

client.on("ready", () => {
  console.log(`> ${client.user.username} is Online !!`);
});

Discord Chat Bot Example

client.on("messageCreate", async (message) => {
  if (!message.guild || message.author.bot) return;
  let ChatBotChannelId = "ChannelID";
  let channel = message.guild.channels.cache.get(ChatBotChannelId);
  if (!channel) return;
  if (message.channel.id === channel.id) {
    let chatreply = await chatGpt
      .chat(message.content, message.author.username)
      .catch((e) => {
        console.log(e);
      });
    message.reply({
      content: `${chatreply}`,
    });
  }
});

Bugs, glitches and issues

If you encounter any problems feel free to open an issue in our GitHub repository or join the Discord server.

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i discord-chat-gpt

    Weekly Downloads

    17

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    3.73 kB

    Total Files

    4

    Last publish

    Collaborators

    • kabirsingh