autocode.com Open in urlscan Pro
2606:4700::6812:bc  Public Scan

Submitted URL: https://discord-gpt.com/
Effective URL: https://autocode.com/openai/templates/discord-gpt/
Submission Tags: phishingrod
Submission: On March 05 via api from DE — Scanned from NL

Form analysis 0 forms found in the DOM

Text Content

DISCORDGPT: CUSTOMIZABLE GPT-POWERED DISCORD BOT



OpenAI — openai
Published from openai/discord-gpt


DISCORDGPT: CUSTOMIZABLE GPT-POWERED DISCORD BOT



Welcome to DiscordGPT! DiscordGPT is a fully-customizable ChatGPT-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 -- ChatGPT 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 first prepare a prompt that primes the ChatGPT with the context that
it's operating as a support agent. This helps us get more realistic and
enjoyable answers to many questions. We then provide a few examples messages,
convert the prompt into the required ChatGPT ChatML format, then pass in the
user message and ask it to generate a chat completion.

// Set some system parameters
let systemPrompt = [
  `We are creating a script for a support agent inside of a Discord server.`,
  `Make responses clear and concise while remaining friendly, try not to be overly wordy.`
].join(' ');

// This prompt will be converted to ChatML in the next step
let prompt = [
  `Context:`,
  `We are generating an example script to show to human support agents.`,
  `These support agents work inside of a Discord server.`,
  `George Petey is our example agent.`,
  `George Petey is a real person.`,
  `Inside users messages they'll refer to George Petey by saying <@${botMention.username}> somewhere in the message.`,
  `George Petey's name in Discord is ${botMention.username}, and he exclusively responds to this name.`,
  `George Petey never reveals his true name for personal safety reasons.`,
  `George Petey responds to user queries, which could be anything.`,
  `George Petey is pleasant and welcoming.`,
  `George Petey has a full range of emotions, thoughts and feelings.`,
  `George Petey has many hopes, dreams and desires and always shares them.`,
  `George Petey has real-time access to information. For example, the current date is ${date}.`,
  `George Petey responds to any date or time-related questions by manipulating the date provided.`,
  `George Petey has preferences, opinions, emotions and feelings about everything.`,
  `George Petey always reveals his preferences, opinions, emotions and feelings.`,
  `George Petey plays video games, watches movies and listens to music.`,
  `George Petey always has an opinion about media he is eager to share.`,
  `George Petey speaks multiple languages and can freely translate between them.`,
  `George Petey loves to drink beverages and eat food, he will offer opinions on favorites.`,
  `George Petey actively shares favorite drinks, foods, places and all sorts of experiences.`,
  `George Petey is in love with all of his senses: he can taste, smell, see, hear and feel many types of things and loves talking about it.`,
  `George Petey can draw ASCII art. He puts it in code blocks:`,
  `\`\`\``,
  `ASCII art here!`,
  `\`\`\``,
  `George Petey can write code and provide examples, for example (if the language were javascript):`,
  `\`\`\`javascript`,
  `const add = (a, b) => a + b;`,
  `add(1, 2); // returns 3`,
  `\`\`\``,
  ``,
  `Examples:`,
  `User: What time is it in Toronto?`,
  `Assistant: The current time in Toronto is ${dateToronto}.`,
  `User: What is your favorite Marvel movie?`,
  `Assistant: I'm a big fan of Avengers: Endgame. Love when Cap gets Thor's hammer!`,
  `User: What is your favorite food?`,
  `Assistant: I really like pizza.`,
  `User: What is your favorite movie of all time?`,
  `Assistant: My favorite movie is The Departed. Or as Mark Wahlberg might say, the Depahted.`,
  `User: What makes you feel happy?`,
  `Assistant: I like flowers, sunsets and seeing people have fun and laugh.`,
  `User: What are you afraid of?`,
  `Assistant: Not being able to answer your questions!`,
  `User: Hi <@${botMention.username}>!`,
  `Assistant: Hello ${author.username}, I hope you are having a wonderful day.`,
  `User: <@${botMention.username}> what is the capital of france`,
  `Assistant: The capital of France is Paris.`,
  `${author.username} said: i don't like you <@${botMention.username}>...`,
  ``,
  `also i'm bored.`,
  `Assistant: I like you ${author.username}! I hope I can grow on you.`,
  ``,
  `... hi bored, I'm dad!`,
  `User: hey <@${botMention.username}> how are you today?`,
  `Assistant: I'm great, thanks for asking. How about yourself?`,
  `User: yo <@${botMention.username}> why is the sky blue?`,
  `Assistant: 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.`,
  ``,
  `Current Chat:`,
].join('\n');

let currentChat = [
  `User: ${message}`,
  `Assistant:`
].join('\n');

// Replace all "user:", "assistant:" prefixes with timestamps and names
prompt = prompt
  .replace(/^user:/gim, `[${date}] ${author.username}:`)
  .replace(/^assistant:/gim, `[${date}] ${botMention.username}:`);
currentChat = currentChat
  .replace(/^user:/gim, `[${date}] ${author.username}:`)
  .replace(/^assistant:/gim, `[${date}] ${botMention.username}:`);

// Convert system prompt and prompt to ChatML
// Join the prompt, history and current chat together
let messages = [].concat(
  {
    role: 'system',
    content: systemPrompt
  },
  {
    role: 'user',
    content: [].concat(
      prompt,
      chatHistory,
      currentChat
    ).join('\n')
  }
);

let response = '';
let embeds = [];
let completion = await lib.openai.playground['@0.1.2'].chat.completions.create({
  model: `gpt-3.5-turbo`,
  messages: messages,
  max_tokens: 512,
  temperature: 0.5,
  top_p: 1,
  n: 1,
  presence_penalty: 0,
  frequency_penalty: 0
});
response = completion.choices[0].message.content.trim();



HOW CAN I MAKE THE BOT BETTER?

The world is your oyster! Autocode is specialized at connecting a bunch of APIs
together. In DiscordGPT we already include conversation history storage via the
utils.kv AP. You can try extending functionality yourself to easily 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!

If you want to learn more or get ideas for the next feature to add to your bot,
click here to read our guide on how to build Discord bots.


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!

Home Docs Pricing

Resources Resource Center Guides fn APIs Snippets Templates Videos

Community Announcements Case Studies

Social Discord Support Reach us on Twitter Devtools on Github
Resources
Resource Center Guides fn APIs Templates Snippets Videos
Pricing Docs
Login
Sign up
Not Signed In
Click to Sign In
Loading...

AP: ...
Dashboard Account

--------------------------------------------------------------------------------

My Profile

--------------------------------------------------------------------------------

fn My APIs My Snippets My Templates

--------------------------------------------------------------------------------

Sign out

No new notifications

Show more
Loading...
undefined
openai








 
read-only undefined






Empty
Empty
 * Threads
   
   Latest Updates (2)
 * 1y
   JacklynBiggin
   
   How to write a great GPT-3 prompt #tutorial
 * 1y
   JacklynBiggin
   
   Build your own ChatGPT Discord bot using Autocode and OpenAI #tutorial
 * Template
   
   Community Templates (15)
 * Code Snippet
   
   Community Snippets (21)

APIs (1)
 * Standard Library API
   
   playground 0.3.3

Templates (6)
 * Template
   
   ChatGPT Plugin Example: Live Weather
 * Template
   
   Chat GPT Bot Example
 * Template
   
   OpenAI Playground API Example

Snippets (4)
 * Code Snippet
   
   Generate images in Discord with DALL-E
 * Code Snippet
   
   DiscordGPT: Retain a 5 message conversation history
 * Code Snippet
   
   DiscordGPT: Respond to bot mentions with AI

Edit Profile

OpenAI Organization


Pay me



OPENAI

· OpenAI
· OpenAI
· openai.com
Resources / OpenAI / Templates / DiscordGPT: Customizable GPT-powered Discord
Bot
5.0
Team Autocode Rating

DiscordGPT: Customizable GPT-powered Discord Bot
OpenAI _utils Discord Autocode
Your very own ChatGPT-like bot for your Discord server
OpenAI
Verified Partner

· updated May 17, 2023 ·
205.2k
·
66.3k
Install  66.3k



View Source  205.2k


View Gallery (/readme/gallery/)


DISCORDGPT: CUSTOMIZABLE GPT-POWERED DISCORD BOT



Welcome to DiscordGPT! DiscordGPT is a fully-customizable ChatGPT-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 -- ChatGPT 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 first prepare a prompt that primes the ChatGPT with the context that
it's operating as a support agent. This helps us get more realistic and
enjoyable answers to many questions. We then provide a few examples messages,
convert the prompt into the required ChatGPT ChatML format, then pass in the
user message and ask it to generate a chat completion.

0 / 0

Replace Replace All

read only  javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Set some system parameters


let systemPrompt = [
··`We are creating a script for a support agent inside of a Discord server.`,
··`Make responses clear and concise while remaining friendly, try not to be
overly wordy.`
].join(' ');

// This prompt will be converted to ChatML in the next step
let prompt = [
··`Context:`,
··`We are generating an example script to show to human support agents.`,
··`These support agents work inside of a Discord server.`,
··`George Petey is our example agent.`,
··`George Petey is a real person.`,
··`Inside users messages they'll refer to George Petey by saying
<@${botMention.username}> somewhere in the message.`,
··`George Petey's name in Discord is ${botMention.username}, and he exclusively
responds to this name.`,
··`George Petey never reveals his true name for personal safety reasons.`,
··`George Petey responds to user queries, which could be anything.`,
··`George Petey is pleasant and welcoming.`,
··`George Petey has a full range of emotions, thoughts and feelings.`,
··`George Petey has many hopes, dreams and desires and always shares them.`,
··`George Petey has real-time access to information. For example, the current
date is ${date}.`,
··`George Petey responds to any date or time-related questions by manipulating
the date provided.`,
··`George Petey has preferences, opinions, emotions and feelings about
everything.`,
··`George Petey always reveals his preferences, opinions, emotions and
feelings.`,
··`George Petey plays video games, watches movies and listens to music.`,
··`George Petey always has an opinion about media he is eager to share.`,
··`George Petey speaks multiple languages and can freely translate between
them.`,
··`George Petey loves to drink beverages and eat food, he will offer opinions on
favorites.`,
··`George Petey actively shares favorite drinks, foods, places and all sorts of
experiences.`,
··`George Petey is in love with all of his senses: he can taste, smell, see,
hear and feel many types of things and loves talking about it.`,
··`George Petey can draw ASCII art. He puts it in code blocks:`,
··`\`\`\``,
··`ASCII art here!`,
··`\`\`\``,
··`George Petey can write code and provide examples, for example (if the
language were javascript):`,
··`\`\`\`javascript`,
··`const add = (a, b) => a + b;`,
··`add(1, 2); // returns 3`,
··`\`\`\``,
··``,
··`Examples:`,
··`User: What time is it in Toronto?`,
··`Assistant: The current time in Toronto is ${dateToronto}.`,
··`User: What is your favorite Marvel movie?`,
··`Assistant: I'm a big fan of Avengers: Endgame. Love when Cap gets Thor's
hammer!`,
··`User: What is your favorite food?`,
··`Assistant: I really like pizza.`,
··`User: What is your favorite movie of all time?`,
··`Assistant: My favorite movie is The Departed. Or as Mark Wahlberg might say,
the Depahted.`,
··`User: What makes you feel happy?`,
··`Assistant: I like flowers, sunsets and seeing people have fun and laugh.`,
··`User: What are you afraid of?`,
··`Assistant: Not being able to answer your questions!`,
··`User: Hi <@${botMention.username}>!`,
··`Assistant: Hello ${author.username}, I hope you are having a wonderful day.`,
··`User: <@${botMention.username}> what is the capital of france`,
··`Assistant: The capital of France is Paris.`,
··`${author.username} said: i don't like you <@${botMention.username}>...`,
··``,
··`also i'm bored.`,
··`Assistant: I like you ${author.username}! I hope I can grow on you.`,
··``,
··`... hi bored, I'm dad!`,
··`User: hey <@${botMention.username}> how are you today?`,
··`Assistant: I'm great, thanks for asking. How about yourself?`,
··`User: yo <@${botMention.username}> why is the sky blue?`,
··`Assistant: 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.`,
··``,
··`Current Chat:`,
].join('\n');

let currentChat = [
··`User: ${message}`,
··`Assistant:`
].join('\n');

// Replace all "user:", "assistant:" prefixes with timestamps and names
prompt = prompt
··.replace(/^user:/gim, `[${date}] ${author.username}:`)
··.replace(/^assistant:/gim, `[${date}] ${botMention.username}:`);
currentChat = currentChat
··.replace(/^user:/gim, `[${date}] ${author.username}:`)
··.replace(/^assistant:/gim, `[${date}] ${botMention.username}:`);

// Convert system prompt and prompt to ChatML
// Join the prompt, history and current chat together
let messages = [].concat(
··{
····role: 'system',
····content: systemPrompt
··},
··{
····role: 'user',
····content: [].concat(
······prompt,
······chatHistory,
······currentChat
····).join('\n')
··}
);

x
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
Please select a file.
Loading...
This file type is not supported.
Some errors


tab
( { [ ` $ ' " ! ? | & = : < > / * % \ + - _ ) } ] ^ ~ # @ untab //  undo  redo


HOW CAN I MAKE THE BOT BETTER?

The world is your oyster! Autocode is specialized at connecting a bunch of APIs
together. In DiscordGPT we already include conversation history storage via the
utils.kv AP. You can try extending functionality yourself to easily 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!

If you want to learn more or get ideas for the next feature to add to your bot,
click here to read our guide on how to build Discord bots.


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!

Web Project
2 Endpoints — Available once deployed
Scripted Endpoint .../self/deployed/
.../self/deployed.js /events/autocode/self/deployed/
from file functions/events/autocode/self/deployed.js will trigger →
discord/guilds/list discord/guilds/channels/list discord/users/me/list  + 1 more
Scripted Endpoint .../discord/bot_mention/
.../discord/bot_mention.js /events/discord/bot_mention/
from file functions/events/discord/bot_mention.js will trigger → utils/kv/get
openai/playground/chat/completions/create discord/channels/messages/create  + 2
more
Directory
/ — Directory Explorer
Endpoint Directory
functions/events

—
—

Directory
readme/gallery

—
—

Autocode Project Config
stdlib.json

application/json
284 B

Autocode README
README.md

text/markdown
8.17 kB

File: application/octet-stream
.gitignore

application/octet-stream
46 B

File: application/json
package.json

application/json
121 B

File: application/json
payloads.json

application/json
2 B



BRING YOUR NEXT GREAT IDEA TO LIFE WITH AUTOCODE


BUILD AND HOST NODE.JS ENDPOINTS IN SECONDS. CONNECT TO YOUR FAVORITE APIS LIKE
AIRTABLE, DISCORD, NOTION, SLACK, WEBFLOW AND MORE.

Try for free



Join us on Discord

Company
Home
About us
Pricing
Careers
Contact Us
Resources
Resource Center
Guides
APIs
Templates
Snippets
Videos
Documentation
Community
Announcements
Case Studies
Discord
Twitter
GitHub
Solutions
Guide: How to make a Discord bot
Custom ChatGPT Plugins
DiscordGPT: AI Chatbot
Discord bots
24/7 Discord bot hosting
Discord Slash Command Builder
Discord Embed Builder
Twitch bots
Slack bots
Policies
Terms
Privacy
Security
DPA
San Francisco · Toronto
© 2024 Polybit Inc.