DiscordGPT: Customizable GPT-powered Discord Bot

Welcome to DiscordGPT! DiscordGPT is a fully-customizable GPT-powered Discord
bot that uses Autocode for easy hosting and development. Autocode provides
(1) Node.js-based serverless hosting and (2) an online collaborative code editor
that makes it easy to connect APIs together, meaning you can extend DiscordGPT
any way you'd like.
If you're not familiar with code, don't worry — Autocode
is easy to get a hang of. If you're already a software developer you'll be
right at home. Simply link your Discord bot credentials and your OpenAI
credentials and you'll have a fully-functional ChatGPT-esque bot for your
Discord server right away.

Getting Started
To get started with DiscordGPT, click the install button at the top of the
template page. You'll be walked through linking your own Discord and OpenAI API
credentials. Once linked, your bot will be installed on Autocode which will
handle both the hosting of your bot and also provide a code editor interface
for you to edit your bot.
Help! My bot doesn't work.
You'll need to enable Privileged Intents,
specifically the Message Content intent to get your bot to work out-of-the-box.
Once enabled, your bot will respond to mentions.
How does this work?
The bot is pretty simple -- GPT-3 and the OpenAI APIs are incredibly powerful.
Autocode provides (1) a serverless Node.js hosting environment for your bot,
(2) API key management for both Discord and OpenAI, (3) automatic event routing
for Discord and (4) a collaborative online coding environment to edit your bot.
The file functions/events/discord/bot_mention.js
contains all the logic for
your bot. We prepare a prompt that primes GPT-3 with the context that it's
operating as a Discord bot and give a few examples messages, then pass in the
user message and ask it to generate a completion.
let prompt = [
`You are a chat bot inside of a Discord server. Your name is ${botMention.username}.`,
`You respond to queries users ask you, which could be anything. Your goal is to be pleasant and welcoming.`,
`Inside users messages to you, they'll refer to you by saying <@${botMention.username}> somewhere in the message.`,
`User input may be multi-line, and you can respond with multiple lines as well. Here are some examples:`,
``,
`${author.username} said: Hi <@${botMention.username}>!`,
`Your response: Hello ${author.username}, I hope you are having a wonderful day.`,
`${author.username} said: <@${botMention.username}> what is the capital of france`,
`Your response: The capital of France is Paris.`,
`${author.username} said: i don't like you <@${botMention.username}>...`,
``,
`also i'm bored.`,
`Your response: I like you ${author.username}! I hope I can grow on you.`,
``,
`... hi bored, I'm dad.`,
`${author.username} said: yo <@${botMention.username}> why is the sky blue?`,
`Your response: As white light passes through our atmosphere, tiny air molecules cause it to 'scatter'. The scattering caused by these tiny air molecules (known as Rayleigh scattering) increases as the wavelength of light decreases. Violet and blue light have the shortest wavelengths and red light has the longest.`,
`${author.username} said: ${message}`,
`Your response: `
].join('\n');
let completion = await lib.openai.playground['@0.0.1'].completions.create({
model: `text-davinci-003`,
prompt: [
prompt
],
max_tokens: 512,
temperature: 0.5,
top_p: 1,
n: 1,
echo: false,
presence_penalty: 0,
frequency_penalty: 0,
best_of: 1
});
How can I make the bot better?
The world is your oyster! Autocode is specialized at connecting a bunch of APIs
together so I'm sure you can come up with really creative ways to extend DiscordGPT
by getting it to store conversation history, access other APIs like the weather,
Google, you name it. If we don't have the API on our standard library,
Autocode supports the entirety of NPM -- any Node package works!
How can I get more help?
You can visit Autocode's official Discord server at discord.gg/autocode.
You can also e-mail us directly at contact@autocode.com
Happy hacking!