Skip to content

Nagato is a WIP Discord bot written in golang using Discordgo.

License

Notifications You must be signed in to change notification settings

chaseweaver/Nagato

Repository files navigation

Nagato

WIP Discord bot written in golang using Discordgo.

Progress / TODO

See TODO

Info

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.

Prerequisites

  1. Follow this Effective Go
  2. And this Documenting Go Code
  3. Create a REDIS server.

Install / Run

  1. Clone this repo
    git clone https://github.com/chaseweaver/Nagato.git
    
  2. Install required dependencies
  3. Rename config.ex.json to config.json
  4. Register a bot account at Discord App Developers
  5. Grab bot Token and paste it in the newly renamed config.json file.
  6. Build the project
    $ go build
  7. Run the bot
    $ ./Nagato
  8. ezpz

Adding Bot to a Guild

  1. Go back to Discord App Developers's
  2. Grab Client ID
  3. Go to Discord Permissions Calculator and select the required permissions and paste your Client ID in.
  4. Click on newly-creted link.
  5. ezpz

Templates

  • 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
    }

Command Properties

Each command has it's own properties that dictate when / how it can be run. Here's the list of currently supported properties:

Command

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

Context

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{}

UserPermissions

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

About

Nagato is a WIP Discord bot written in golang using Discordgo.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages