WIP Discord bot written in golang using Discordgo.
See TODO
This project was started as a more-modular based approach to handle commands and events. As such, each command has a properties file as well as a func that is called. Example and templates are shown below.
- Follow this Effective Go
- And this Documenting Go Code
- Create a REDIS server.
- Clone this repo
git clone https://github.com/chaseweaver/Nagato.git
- Install required dependencies
- Rename
config.ex.json
toconfig.json
- Register a bot account at Discord App Developers
- Grab bot
Token
and paste it in the newly renamedconfig.json
file. - Build the project
$ go build
- Run the bot
$ ./Nagato
- ezpz
- Go back to Discord App Developers's
- Grab
Client ID
- Go to Discord Permissions Calculator and select the required permissions and paste your
Client ID
in. - Click on newly-creted link.
- ezpz
-
init (to be placed in
func init() { ... }
)func init() { RegisterNewCommand(Command{ Name: "command name", Func: FunctionName, Enabled: true, NSFWOnly: false, IgnoreSelf: true, IgnoreBots: true, Cooldown: 30, RunIn: []string{"Text", "DM"}, Aliases: []string{"nameone", "nametwo"}, UserPermissions: []string{"Kick Members"}, ArgsDelim: " ", Usage: []string{"<@Member>", "Other"}, Description: "Description Here", }) // RegisterNewCommand(Command{ ... }
-
Commands (to be placed in the desired
*.go
)func CommandName(ctx Context) { // Do some neat things here return }
-
Events (to be placed in
events.go
)func EventName(ctx Context) { // More neat stuff }
Each command has it's own properties that dictate when / how it can be run. Here's the list of currently supported properties:
This is to be passed in for each func call:
Property | Description | Type |
---|---|---|
Name | Name of the command, case sensitive | string |
Func | Name of the command func that gets ran, case sensitive | func |
Enabled | Whether or not the command is enabled and can be ran | bool |
NSFWOnly | Whether or not the command is only available in NSFW-marked channels | bool |
IgnoreSelf | Whether or not the bot will ignore itself | bool |
IgnoreBots | Whether or not the bot will ignore other bots | bool |
Cooldown | Time the command can be ran again by the same user | int |
RunIn | Channel type the command can be ran in (DM, Text) | []string{} |
Aliases | Other names the command will execute under | []string{} |
UserPermissions | Permissions the user needs in order for the command to execute | []string{} |
ArgsDelim | Seperator that will parse individual arguments | string |
Usage | Example of how to run the command, used for help |
[]string{} |
Description | Description of the command, used for help |
string |
This is to be passed in for each func call:
Property | Description | Type |
---|---|---|
Session | *discordgo.Session | Session |
Event | *discordgo.MessageCreate | Event |
Guild | *discordgo.Guild | Guild |
Channel | *discordgo.Channel | Channel |
Command | Command to be run | Command |
Name | Name of the command, case sensitive | string |
Args | Arguments passed in for the command | []string{} |
Permissions the Author of the command needs in order for the bot to run said command (really only need the important ones like KickMembers, etc).
- Bot Owner (bot owner, forces all commands to run regardless)
- Read Messages
- Send Messages
- Send TTS Messages
- Manage Messages
- Embed Links
- Attach Files
- Read Message History
- Mention Everyone
- Use External Emojis
- Voice Connect
- Voice Speak
- Voice Mute Members
- Voice Deafen Members
- Voice Move Members
- Voice Use VAD
- Change Nickname
- Manage Nicknames
- Manage Roles
- Manage Webhooks
- Manage Emojis
- Create Instant Invite
- Kick Members
- Ban Members
- Administrator
- Manage Channels
- Manage Server
- Add Reactions
- View Audit Logs
- All Text
- All Voice
- All Channel
- All