GithubHelp home page GithubHelp logo

elitezen / discordjs-chatgpt Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 4.0 22 KB

A Chat GPT plugin for Discord.JS

JavaScript 100.00%
api chat-gpt-3 chatgpt discord discord-bot discordjs openai openai-api discord-chatgpt

discordjs-chatgpt's Introduction

discordjs-chatgpt

screenshot

A small module for quick implemntation of OpenAI's Chat-GPT into Discord.JS. This is the first public version of the library. For bug reports or feature requests visit https://github.com/Elitezen/discordjs-chatgpt

This module requires an OpenAI API key. You can get one here


Updates

0.2.1

Added gaurd to text length in embeds


Installing

npm i discordjs-chatgpt

Example Usage

Interaction

const { SlashCommandBuilder } = require('discord.js');

const { ChatGPTClient } = require('discordjs-chatgpt');
const chatgpt = new ChatGPTClient('YOUR_OPENAI_API_KEY');

module.exports = {
  data: new SlashCommandBuilder()
    .setName('chatgpt')
    .setDescription('Talk with Chat-GPT!')
    .addStringOption(option =>
        option
          .setName('message')
          .setDescription('Your message')),
  async execute(interaction) {
      const msg = interaction.options.getString('message', true);
      await chatgpt.chatInteraction(interaction, msg);
  }
};

Message

Filter messages and clean message.content as needed.

const { Events } = require('discord.js');

const { ChatGPTClient } = require('discordjs-chatgpt');
const chatgpt = new ChatGPTClient('YOUR_OPENAI_API_KEY');

const examplePrefix = "!";

module.exports = {
	name: Events.MessageCreate,
	once: false,
	execute(message) {
        const msg = message.content.replace(examplePrefix, '');
		return await chatgpt.chatMessage(message, msg);
	},
};

Options

You can toggle context remebering, and response type.

const chatgpt = new ChatGPTClient('YOUR_OPENAI_API_KEY', {
  contextRemembering: true,
  responseType: 'embed' // or 'string'
});

discordjs-chatgpt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

discordjs-chatgpt's Issues

Error Invalid environment; fetch is not defined

file:///C:/Users//Desktop/cekret/dickcord/_bot/node_modules/chatgpt/build/index.js:150
throw new Error("Invalid environment; fetch is not defined");
^

Error: Invalid environment; fetch is not defined
at new ChatGPTAPI (file:///C:/Users//Desktop/cekret/dickcord/_bot/node_modules/chatgpt/build/index.js:150:13)
at ChatGPTClient. (C:\Users*\Desktop\cekret\dickcord*_bot\node_modules\discordjs-chatgpt\src\ChatGPTClient.js:29:24)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.