A complete code to download for a Welcomer Bot
-> Bot that plays sound when somebody joins or leaves a voice channel :)
-> type *help
in chat to learn more when you set up the bot
Copy the config.json.example
in the config folder and rename it to config.json
{
"terminateOnUncaughtException": true,
"bot": {
"token": "put your bot token here",
"prefix": "*",
"ignoreMessageEndingWithPrefix": false,
"ownerID": "put your discord id here"
},
"status": {
"status": "online",
"game": "made by EnhancedMind ❤️"
},
"emoji": {
"success": ":notes:",
"info": ":bulb:",
"warning": ":warning:",
"error": ":no_entry_sign:",
"loading": ":watch:",
"searching": ":mag_right:"
},
"response": {
"missingArguments": "Missing arguments. Please use `{prefix}help` for more information.",
"invalidPermissions": "You do not have the permission to use this command.",
"invalidNumber": "Please provide a valid number.",
"noChannel": "You must be in a voice channel.",
"wrongChannel": "You must be in the same voice channel as I am.",
"afkChannel": "You can't be in a AFK voice channel.",
"noMusic": "No music is playing on this server."
},
"player": {
"maxTime": 15,
"playIntoEmptyChannel": false,
"selfDeaf": false,
"debug": false,
"allowedExtensions": ["mp3", "wav", "ogg", "flac", "m4a", "aac", "webm", "opus", "aiff", "wma", "ac3"]
},
"logs": {
"resetLogOnStart": true,
"logToFile": false,
"timeFormat": "en-US"
}
}
terminateOnUncaughtException
: whether to terminate the process on uncaught exception or not - only for advanced users
bot.token
: the token of your discord bot you can get from Discord Developers pagebot.prefix
: the prefix which will be used for your bot's commandsbot.ignoreMessageEndingWithPrefix
: whether to ignore messages (commands) ending with the prefix or not (useful for * and prefixes like this that are used for markdown)bot.ownerID
: your discord user id you can get by right clicking user on discord after enabling developer mode
status.status
: the status of the bot - online / idle / dnd / invisiblestatus.game
: the game status the bot will show. can be changed with a command
emoji.success
: the emoji that will be used for success messagesemoji.info
: the emoji that will be used for info messagesemoji.warning
: the emoji that will be used for warning messagesemoji.error
: the emoji that will be used for error messagesemoji.loading
: the emoji that will be used for loading messagesemoji.searching
: the emoji that will be used for searching messages
response.notValidCommand
: whether to send a message when the user uses a command that doesn't existresponse.missingArguments
: the message that will be sent when the command is missing argumentsresponse.invalidPermissions
: the message that will be sent when the user does not have the permission to use the commandresponse.invalidNumber
: the message that will be sent when the user provides an invalid numberresponse.noChannel
: the message that will be sent when the bot is not in a voice channel, but the command requires itresponse.wrongChannel
: the message that will be sent when the user is not in the same voice channel as the bot, but the command requires itresponse.afkChannel
: the message that will be sent when the user is in a AFK voice channel, but the user tries to play musicresponse.noMusic
: the message that will be sent when the user tries to use a command that requires music to be playing, but there is no music playing
player.maxTime
: the maximum length of a soound that will be accepted by the setsong commandplayer.playIntoEmptyChannel
: whether to play leave sound into an empty voice channel or notplayer.selfDeaf
: whether to deafen the bot or notplayer.debug
: whether to show audioplayer debug messages or notplayer.allowedExtensions
: the extensions that will be allowed to be played by the bot - only for advanced users
logs.resetLogOnStart
: whether to clear the session log on start or continue at the end of the file ´logs.logToFile
: whether to log to a file or only to the consolelogs.timeFormat
: the time format that will be used for the logs - en-US
To add sounds you will need to add them to the music
folder.
In the sounds folder there are 3 files and a users folder.
default.mp3
is the sound that will be played when a user joins a voice channel.leave0.mp3
andleave1.mp3
are the sounds that will be played when a user leaves a voice channel. One of them will be randomly selected based on 50% chance.
users
folder is where you can add custom join sounds for users. To add user a custom sound, simply put a music file named 'USERID_optionalcomment.extention' You can get the userid in discord after enabling developer mode by right clicking the user and selecting 'copy ID'. The allowed extensions are the same as in the config file. I strongly advise against changing the allowedExtensions in the config if you don't know what you are doing.
To use the project you will need:
Node JS v16.11 or newer
You will need to install some modules using the following command:
npm i