Socket
Socket
Sign inDemoInstall

discordjs-chatgpt

Package Overview
Dependencies
91
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    discordjs-chatgpt

A small module for quick implemntation of OpenAI's Chat-GPT into Discord.JS


Version published
Maintainers
1
Created

Readme

Source

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'
});

Keywords

FAQs

Last updated on 23 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc