Skip to content

Discord Bot for the Anti-Xeno Initiative Discord Server

Notifications You must be signed in to change notification settings

Airom42/warden.bot

 
 

Repository files navigation

Warden.bot

Security Scan

Warden is a discord bot for the Anti-Xeno Initiative Discord Server. Based on Discord.js warden is a combination of systems that culminate in a relatively advanced custom built discord bot for the needs of the AXI.

AXI Discord

Development

Setting up a local copy of the bot for development.

  1. Clone the repository to your system.
  2. Run npm i to install dependencies.
  3. Create a Discord Server for Testing
  4. Create a Discord Bot and Invite it to your Test Server (Make sure it has read/write permissions in your text channels).
  5. IMPORTANT: Make sure you give your bot the "bot" and "applications.commands" permissions in OAuth when inviting your bot. image
  6. Run the SETUP.ps1 file in Powershell (Run as Admin if you have any issues).
  7. Follow the prompts and enter the Bot TOKEN.
  8. Start the bot using npm start in command line or terminal.

The SETUP.ps1 file will create a .env file in your root directory, if you need to make any changes, edit the variables in this file.

image

Useful Links

For working with google cloud vision (sentry commands) https://discordjs.guide/preparations/setting-up-a-bot-application.html#creating-your-bot https://medium.com/analytics-vidhya/setting-up-google-cloud-vision-api-with-node-js-db29d1b6fbe2

Creating Commands

To create a new command, make a new .js file in one of the subfolders, and copy the necessary module.exports content into it. ducc.js is a great example command.

Note: Commands will ONLY be loaded if they are in a subfolder. Any command file not in a subfolder will cause the command handler to fail.

Command Folders

Commands are all stored in subfolders of the "../commands" folder, if they are not within a subfolder they will not be registered as a command and won't be detected by the command handler.

Command Files

Each command is a seperate .js file setup as a module. Within the file are parameters that define what the command is, how it can be used and other details.

There are two types of commands that can be used with this bot Slash Commands and Non-Slash Commands. We prefer you try design commands as Slash commands as these are better supported and have better UI integration into Discord.

Within the file is an execute(message, args) {} or execute(interaction) {} function, this is where your code executes when the command is called by a user. The message and args or interaction variables are defined by the type of command you created.

Use the following as a boilerplate for your commands.

New Command File Format (Slash Commands)

Command name and description are defined in the data: field, this feeds into discord to allow the slash command UI to make easy command browsing, here you can also specify special argument fields (more below).

module.exports = {
	data: new Discord.SlashCommandBuilder()
	.setName('myCommandName') // What the user types to call the command
	.setDescription('myCommandDescription'), // The Discord Description for the command
	permissions: 0,
	execute(interaction) {
        // Command Code
        interaction.reply({ content: "Hello World!"}) // Replies to the user "Hello World".
	},
};

You can set options for commands, this allows users to have extra inputs with each command. You can read more about this here: https://discordjs.guide/interactions/registering-slash-commands.html

Example with Slash Command Options:

module.exports = {
	data: new Discord.SlashCommandBuilder()
	.setName('myCommandName') // What the user types to call the command
	.setDescription('myCommandDescription')
    .addStringOption(option => option.setName('myArgument') // Create the option
		.setDescription('Type Something Here!')
		.setRequired(true)),
	permissions: 0,
	execute(interaction) {
        // Command Code
        let response = interaction.options.data.find(arg => arg.name === 'myArgument').value // Get the option from the command usage

        interaction.reply({ content: response}) // Sends the option text back to the user as a reply.
	},
};

A good example of this type of command is ./commands/wiki/wiki.js or ./commands/math/mttot.js

OLD Command File Format (Non-Slash Commands)

This format is discontinued and all commands are in the process of being updated away from this format.

module.exports = {
    name: "myCommand",
    description: "myCommandDescription",
    format: '"myArgument"',
    args: true,
    permissions: 0,
    hidden: false,
    execute (message, args) {
		// Command Code
		let response = args[0] // Grab the first thing said after the command
		message.reply({ content: response }) // send it back to the user as a reply
    }
}

About

Discord Bot for the Anti-Xeno Initiative Discord Server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.4%
  • Other 0.6%