A Basic discord bot with music and AI inside of it
Nahida is just my discord bot's name :)
-
Open file named
.env.example
(located inconfig
directory), copy your bot token, client_id, guild_id.- The token, you can get from discord developer website in this link, go to application and go to your bot get your token there.
- The Client ID, you can get it from discord server and copy the ID from your bot.
- The Guild ID, you can get it from discord server and copy the ID from your server ID. This is optional, if you want to make the bot can used globally, simply don't add it.
- Don't forget to rename the file from
.env.example
to.env
.
-
(OPTIONAL) Configure OpenAI Key
- Copy your API Key from openai and copy to
api_key
inside file.env
(the token, guild, and client that you set in number 1) - For more secure, Copy your Role ID into
ai_config
->role
inside fileconfig.json
- To make this AI Works, you need Channel ID into
ai_config
->channel
inside fileconfig.json
- Copy your API Key from openai and copy to
NOTE! Make sure you have subscription/billing in OpenAI Platform. Otherwise, this will not work for you! if you want to change the model, see this documentation :
https://platform.openai.com/account/rate-limits
I'm using discord.js
, discord-player
, and openai
packages from npm and running it using node.
The token it'll needed to authenticate your bot into discord API. Also, client ID and guild ID is the identity of your bot user and server user.
Actually, guild ID isn't necessary to adding it. This just make to load slash commands into directed server! But, you really need client ID
-
Installing Packages
Use commandnpm i
and wait until done!
if there's something error, just ignore it :) -
Get the auth token for youtube
WARNING! When getting the auth token from youtube, please don't use your main account. Because is too risky, and the biggest disaster is your account will get permanently ban.
You can see the documentation and reason about in :
https://github.com/retrouser955/discord-player-youtubei/blob/master/LEGAL.md
Use commandnode getAuth.js
or you can use
npx --no discord-player-youtubei
Copy all cookies data into
.env
file, insideYT_CREDENTIAL_USER
. -
Run the bot :)
Use commandnode .
Done! :)
NOTE! Remember to always direct directory into bot folder before you do the step!
WARNING! This branch contain explicit content. Please use this branch wisely
Or, if you don't want it, just disable or set to 0 the nh
and pics
command in config.json
Having problem to connect API's?
Check this link, maybe help you to solve the problem :)