A FAC discord ai chatbot Made by Emma & Egbie
in order to get this bot working, we need access to the following things
-
Server ID of a guild where you can add members to.
-
Token of a discord bot which you can create & manage the permissions of.
-
An Open AI Key linked to an account with some form of credit.
-
If you're setting this up for the first time, you'll also need your bot's Client ID and an appropriate bot Permission Integer.
If you have all the above, please skip to the Installation Steps instead.
- Enable developer mode (discord desktop) by pressing the cog next to your pofile icon to enter settings, selecting Advanced, and toggling on Developer Mode.
- After exiting settings, right click on the guild to which you want to add the bot and select Copy Server ID. Make a note of that somewhere.
Note: If you want to add the bot to someone else's guild, make sure to have their permissions first. If you don't have the required permissions, you'll also need to ask them to add the bot to the guild for you.
Assuming you're generating a discord app for the first time:
- Login to the discord developer portal.
- Create a New Application.
- Select your bot & click on Bot on the LHS menu.
- Click on Reset Token and make a note of it for later. If you lose this token, you'll need to generate a new one.
- Generate a Permission Integer by using the tool at the bottom of the Bot menu. Keep in mind that for the bot to function as intended, it needs to be able to moderate users on top of other permissions like sending & receiving messages. We recommend using the following permissions integer:
1995012435014
- Navigating to the OAuth2 menu on the left, make a note of the Client ID
- Construct a URL of the following format:
https://discord.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot&permissions=PERMISSIONS_INTEGER
, replacingCLIENT_ID
andPERMISSIONS_INTEGER
with the values found above. - By following the link, add the bot to the server with the same Guild Server ID. Note: if you're not an admin on the server, send this link to someone who is.
This is assuming this is your first time dealing with OpenAI's API:
- After creating an OpenAI account, navigate to the API keys menu.
- Create a new Secret Key and make a note of it.
- Make sure you have some credit available.
git clone
the repository & navigate into it- run
npm install
to install all packages required - create a
.env
file and copy the contents into it from.env-template
- Inside the
.env
file, fill in the values of the Server ID, Discord Bot Token, and OpenAI API key with the values you've acquired from following the Prerequisite steps. - start the project using
npm start
If all went well and you've added your bot successfully to a guild, you should be able to interact with it by mentioning, followed by a prompt, like so:
@BOT_NAME Hey, can you tell me a fun fact
You can also see your chat history by typing:
@BOT_NAME !showMyChatHistory
The bot will also delete & notify you of any messages which are flagged by the OpenAI's moderation API, and will issue timeouts (up to an hour) for repeat offenders.
This project uses ESLint
and Prettier
to try and maintain some form of formatting consistency. It's helping us write cleaner and more readable code collaboratively.