Go to file
2019-06-21 15:14:34 +02:00
build.sh added simple build script 2019-03-02 10:17:45 +01:00
CHANGELOG.md added !vc to create temporary voice channels 2019-03-12 22:37:06 +01:00
command.go fix possible null pointer dereference in role assignment 2019-06-12 23:51:49 +02:00
config.go gofmt all the things 2019-01-10 00:51:50 +01:00
config.json I can’t into json :selphyDerp: (actually fix #2) 2018-06-10 21:32:06 +02:00
events.go add image to welcome fallback message 2019-06-21 15:14:34 +02:00
helpers.go hopefully fix !vc 2019-06-08 05:31:06 +02:00
main.go Minor changes to the temporary voice channels 2019-03-13 20:44:17 +01:00
README.md added readme (closes #1) 2018-06-19 12:39:08 +02:00
voicechannel.go hopefully fix !vc 2019-06-08 05:31:06 +02:00
welcome.go gofmt all the things 2019-01-10 00:51:50 +01:00

discord-selphybot

A custom bot for the discord community of https://twitch.tv/selphy. Most of the commands are fairly specific, but the underlying command logic (i. e. the registerCommand wrapper) can be reused in other projects to simplify the https://github.com/bwmarrin/discordgo API bindings. I might release a standalone version of just the wrappers at some point. Might.
Anyway.

Dependencies

Usage

I doubt anyone will want to run an exact copy of this, but if you do, it works just like any other project. Edit config.json as needed, and then run go build *.go. No magic involved.
More relevant should be the reusable part. By calling registerCommand at any point during program execution, a new command can be added. A command is defined as a struct with various properties do control its behavior.

  • Trigger string: a string that is used to trigger the command when it appears in a message. Type is used to control how this string is matched.
  • Output string: simple text response for commands that don’t require any advanced logic.
  • OutputEmbed *discordgo.MessageEmbed: if specified, the specified embed will be used as a reply. Overwrites Output.
  • Type CommandType: specifies how Trigger is matched. Possible values are: CommandTypePrefix, CommandTypeFullMatch, CommandTypeContains, CommandTypeRegex. Defaults to Prefix; names should be self-explanatory.
  • IgnoreCase bool: Ignore case when matching Trigger. Defaults to false.
  • Cooldown int: cooldown for the command in seconds. 0 (no cooldown) if unspecified.
  • OutputIsReply bool: @mention the user who triggered the command. This requires a <@%s> in Output. Defaults to false.
  • RequiresMention bool: require @mentioning the bot to trigger the command. This requires a <@%s> in Trigger. Defaults to false.
  • DeleteInput bool: delete the messages that triggered the command. Requires permissions to manage messages. Defaults to false.
  • DMOnly bool: command can only be used in DMs. Defaults to false.
  • AdminOnly bool: command can only be used by the admins specified in config.json. Defaults to false.
  • Function func(*discordgo.Session, *discordgo.MessageCreate): execute a custom function when the command is triggered and pass the Session and MessageCreate event to that function. Ignores all other options except the matching-related ones and Trigger. Defaults to nil.

It should be noted that admin users can use DMOnly commands everywhere and are unaffected by cooldowns.