From 43998246d97f0b5b6e80fe296069569ecc79bc98 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Thu, 13 May 2021 21:54:38 -0500 Subject: [PATCH 1/9] Add imgur album commands Signed-off-by: Etzelia --- config/canopeas.example.toml | 8 ++- config/config.go | 16 ++++-- discord/discord.go | 12 ++-- discord/help.go | 2 +- discord/history.go | 4 +- discord/imgur.go | 71 ++++++++++++++++++++++++ discord/jupiter.go | 21 ------- imgur/imgur.go | 19 ++----- sedbot.toml | 103 +++++++++++++++++++++++++++++++++++ 9 files changed, 208 insertions(+), 48 deletions(-) create mode 100644 discord/imgur.go delete mode 100644 discord/jupiter.go create mode 100755 sedbot.toml diff --git a/config/canopeas.example.toml b/config/canopeas.example.toml index cda4eb2..f01f229 100644 --- a/config/canopeas.example.toml +++ b/config/canopeas.example.toml @@ -5,7 +5,7 @@ token = "" prefix = "!" # db_path is the path to the database (default is next to binary) -db_path = "sedbot.db" +db_path = "canopeas.db" # mc_path is the path to the root directory of the minecraft server mc_path = "/home/minecraft/server/" @@ -78,6 +78,12 @@ verbs = [] nouns = [] minor_things = [] +[[albums]] +name = "jupiter" +aliases = ["jup", "jupjup"] +album_id = "" +help = "Images of Jupiter" + # echoes are any basic command -> message [[echoes]] name = "discord" diff --git a/config/config.go b/config/config.go index 2e7e8d1..a28db47 100644 --- a/config/config.go +++ b/config/config.go @@ -38,6 +38,7 @@ type Config struct { StaffRoles []string `toml:"staff_roles"` Echoes []Echo `toml:"echoes"` + Albums []Album `toml:"albums"` MessageRoles []MessageRole `toml:"message_roles"` RegisterRole string `toml:"register_role"` RegisteredChannel string `toml:"registered_channel"` @@ -58,13 +59,13 @@ type Config struct { } type MessageRole struct { - ChannelID string `toml:"channel_id"` - MessageID string `toml:"message_id"` + ChannelID string `toml:"channel_id"` + MessageID string `toml:"message_id"` Reactions []MessageReaction `toml:"reactions"` } type MessageReaction struct { - Emoji string `toml:"emoji"` - RoleID string `toml:"role_id"` + Emoji string `toml:"emoji"` + RoleID string `toml:"role_id"` } type Echo struct { @@ -74,6 +75,13 @@ type Echo struct { Help string `toml:"help"` } +type Album struct { + Name string `toml:"name"` + Aliases []string `toml:"aliases"` + AlbumID string `toml:"album_id"` + Help string `toml:"help"` +} + func Load(configPath string) (*Config, error) { var err error var configContent []byte diff --git a/discord/discord.go b/discord/discord.go index 423087f..ac73f80 100644 --- a/discord/discord.go +++ b/discord/discord.go @@ -7,12 +7,11 @@ import ( "git.birbmc.com/canopeas/config" "git.birbmc.com/canopeas/database" - "git.birbmc.com/canopeas/imgur" + "git.birbmc.com/Etzelia/go-serverapi" "github.com/bwmarrin/discordgo" "github.com/dghubble/go-twitter/twitter" "github.com/dghubble/oauth1" - "git.birbmc.com/Etzelia/go-serverapi" "go.jolheiser.com/beaver" ) @@ -39,6 +38,7 @@ type command struct { staffOnly bool deleteInvocation bool echo bool + album bool // TODO Does this really need to exist separately? validate func(cmd commandInit) bool run func(cmd commandInit) (string, error) @@ -53,11 +53,8 @@ func Bot(cfg *config.Config, db *database.Database) (*discordgo.Session, error) return nil, err } - // Init Jupiter images + // Init rand rand.Seed(time.Now().UnixNano()) - if err := imgur.Init(cfg.ImgurClientID); err != nil { - return nil, err - } // Init ServerAPI sapi := serverapi.NewClient(cfg.ServerAPI.Endpoint, serverapi.WithToken(cfg.ServerAPI.Token)) @@ -86,6 +83,9 @@ func Bot(cfg *config.Config, db *database.Database) (*discordgo.Session, error) } // Init commandMap + if err := Album(cfg); err != nil { + return nil, err + } Echo(cfg) for _, c := range commands { if c.name == "" { diff --git a/discord/help.go b/discord/help.go index 2587ef6..a8fcd53 100644 --- a/discord/help.go +++ b/discord/help.go @@ -65,7 +65,7 @@ func allHelp(cmd commandInit) *discordgo.MessageEmbed { embed.Description = "Commands with an asterisk (*) are staff-only" } for _, c := range commands { - if c.echo { + if c.echo || c.album { continue } diff --git a/discord/history.go b/discord/history.go index a79a032..fe697c1 100644 --- a/discord/history.go +++ b/discord/history.go @@ -5,10 +5,10 @@ import ( "strings" "time" - "github.com/bwmarrin/discordgo" - "go.jolheiser.com/beaver" "gitea.com/jolheiser/gojang" "gitea.com/jolheiser/gojang/rate" + "github.com/bwmarrin/discordgo" + "go.jolheiser.com/beaver" ) func init() { diff --git a/discord/imgur.go b/discord/imgur.go new file mode 100644 index 0000000..8449f52 --- /dev/null +++ b/discord/imgur.go @@ -0,0 +1,71 @@ +package discord + +import ( + "fmt" + "strings" + + "git.birbmc.com/canopeas/config" + "git.birbmc.com/canopeas/imgur" + + "github.com/bwmarrin/discordgo" +) + +func Album(cfg *config.Config) error { + for _, a := range cfg.Albums { + images, err := imgur.Get(cfg.ImgurClientID, a.AlbumID) + if err != nil { + return err + } + commands = append(commands, &command{ + name: a.Name, + aliases: a.Aliases, + album: true, + validate: func(cmd commandInit) bool { + return true + }, + run: func(cmd commandInit) (string, error) { + if !memeRateLimit.Try() { + return "", nil + } + img := images[rand.Intn(len(images))-1] + return img.Link, nil + }, + help: a.Help, + }) + } + + commands = append(commands, &command{ + deleteInvocation: true, + name: "albums", + validate: func(cmd commandInit) bool { + return true + }, + run: func(cmd commandInit) (string, error) { + embed := &discordgo.MessageEmbed{ + Title: "Album Commands", + Fields: make([]*discordgo.MessageEmbedField, len(cfg.Albums)), + } + for i, a := range cfg.Albums { + name := a.Name + if len(a.Aliases) > 0 { + name += fmt.Sprintf(" (%s)", strings.Join(a.Aliases, ", ")) + } + embed.Fields[i] = &discordgo.MessageEmbedField{ + Name: name, + Value: a.Help, + Inline: true, + } + } + + channel, err := cmd.session.UserChannelCreate(cmd.message.Author.ID) + if err != nil { + return "", err + } + + sendEmbed(cmd.session, channel.ID, embed) + return "", nil + }, + help: "Get all imgur albums", + }) + return nil +} diff --git a/discord/jupiter.go b/discord/jupiter.go deleted file mode 100644 index a045721..0000000 --- a/discord/jupiter.go +++ /dev/null @@ -1,21 +0,0 @@ -package discord - -import "git.birbmc.com/canopeas/imgur" - -func init() { - commands = append(commands, &command{ - name: "jupiter", - aliases: []string{"jup", "jupjup"}, - validate: func(cmd commandInit) bool { - return true - }, - run: func(cmd commandInit) (string, error) { - if !memeRateLimit.Try() { - return "", nil - } - img := imgur.Images[rand.Intn(len(imgur.Images))-1] - return img.Link, nil - }, - help: "Get a Jupiter image", - }) -} diff --git a/imgur/imgur.go b/imgur/imgur.go index b7b6378..0b2e680 100644 --- a/imgur/imgur.go +++ b/imgur/imgur.go @@ -6,10 +6,6 @@ import ( "net/http" ) -// TODO Make a client for this in a separate module - -var Images []*Image - type Response struct { Images []*Image `json:"data"` Success bool `json:"success"` @@ -33,23 +29,20 @@ type Image struct { Link string `json:"link"` } -func Init(clientID string) error { +func Get(clientID, albumID string) ([]*Image, error) { - req, err := http.NewRequest(http.MethodGet, "https://api.imgur.com/3/album/TaJVIdQ/images", nil) + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("https://api.imgur.com/3/album/%s/images", albumID), nil) if err != nil { - return err + return nil, err } req.Header.Set("Authorization", fmt.Sprintf("Client-ID %s", clientID)) resp, err := http.DefaultClient.Do(req) if err != nil { - return err + return nil, err } + defer resp.Body.Close() var imgurResp Response - if err := json.NewDecoder(resp.Body).Decode(&imgurResp); err != nil { - return err - } - Images = imgurResp.Images - return resp.Body.Close() + return imgurResp.Images, json.NewDecoder(resp.Body).Decode(&imgurResp) } diff --git a/sedbot.toml b/sedbot.toml new file mode 100755 index 0000000..e0d541f --- /dev/null +++ b/sedbot.toml @@ -0,0 +1,103 @@ +# token is the Discord token for the bot +token = "ODMyNDUxMDUyNTY5MTAwMzA4.YHj-dQ.UZEO71yJpGVDUFguTx3vs6rpKu0" + +# prefix is the bot command prefix +prefix = "!" + +# db_path is the path to the database (default is next to binary) +db_path = "sedbot.db" + +# mc_path is the path to the root directory of the minecraft server +mc_path = "/home/minecraft/server/" + +# fired_role is to check how many time Carolyn has been fired +fired_role = "0" + +# register_role is the role to assign to a user after registering +register_role = "0" + +# registered_channel is the channel to message to welcome the newly registered user +registered_channel = "0" + +# leave_channel is the channel to post leave messages to +leave_channel = "0" + +# staff_roles are for staff commands +staff_roles = [] + +# meme_rate is the rate limit for memes +meme_rate = "0" + +# Imgur Client ID +imgur_client_id = "66153d2fa93df9b" + +# ServerAPI options +[serverapi] +# API endpoint +endpoint = "" +# Auth token +token = "" + +# Twitter options +[twitter] +# Consumer Key +consumer_key = "" +# Consumer Secret +consumer_secret = "" +# Access Token +access_token = "" +# Access Secret +access_secret = "" + +# Server options +[server] +# connection address +address = "" +# connection port +port = 25565 + +# MCM options +[mcm] +# the token for the MCM API +token = "" +# the base URL to the MCM API +url = "" + +# insults +# , your looks like , you +[insult] +targets = [] +comparisons = [] +adjectives = [] +nouns = [] + +# compliments +# , I would my just to . +[compliment] +verbs = [] +nouns = [] +minor_things = [] + +[[albums]] +name = "jupiter" +aliases = ["jup", "jupjup"] +album_id = "TaJVIdQ" +help = "Images of Jupiter" + +# echoes are any basic command -> message +[[echoes]] +name = "discord" +aliases = ["invite", "gib"] +message = "" +help = "Get the invite link" + +# message_roles are for messages that should toggle a role when a user selects it +[[message_roles]] +channel_id = "0" +message_id = "0" +[[message_roles.reactions]] +role_id = "0" +emoji = "👍" +[[message_roles.reactions]] +role_id = "0" +emoji = "👎" \ No newline at end of file -- 2.41.0 From 1daa78027b761a693e6d03593bb82bcd48e94266 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Thu, 13 May 2021 22:04:34 -0500 Subject: [PATCH 2/9] Mark clear as staffOnly Signed-off-by: Etzelia --- discord/clear.go | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/clear.go b/discord/clear.go index f75c676..56ca952 100644 --- a/discord/clear.go +++ b/discord/clear.go @@ -10,6 +10,7 @@ const clearMax = 20 func init() { commands = append(commands, &command{ name: "clear", + staffOnly: true, validate: func(cmd commandInit) bool { return isStaff(cmd.message.Member.Roles, cmd.config.StaffRoles) }, -- 2.41.0 From 21bd2a2c8bbb4def7009694f736662b92b04e02b Mon Sep 17 00:00:00 2001 From: Etzelia Date: Thu, 13 May 2021 22:07:58 -0500 Subject: [PATCH 3/9] Rename echo/album field to child Signed-off-by: Etzelia --- discord/clear.go | 2 +- discord/discord.go | 3 +-- discord/echo.go | 2 +- discord/help.go | 2 +- discord/imgur.go | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/discord/clear.go b/discord/clear.go index 56ca952..3a86822 100644 --- a/discord/clear.go +++ b/discord/clear.go @@ -9,7 +9,7 @@ const clearMax = 20 func init() { commands = append(commands, &command{ - name: "clear", + name: "clear", staffOnly: true, validate: func(cmd commandInit) bool { return isStaff(cmd.message.Member.Roles, cmd.config.StaffRoles) diff --git a/discord/discord.go b/discord/discord.go index ac73f80..93c5f89 100644 --- a/discord/discord.go +++ b/discord/discord.go @@ -37,8 +37,7 @@ type commandInit struct { type command struct { staffOnly bool deleteInvocation bool - echo bool - album bool + child bool // TODO Does this really need to exist separately? validate func(cmd commandInit) bool run func(cmd commandInit) (string, error) diff --git a/discord/echo.go b/discord/echo.go index b69bd85..7c230d5 100644 --- a/discord/echo.go +++ b/discord/echo.go @@ -14,7 +14,7 @@ func Echo(cfg *config.Config) { commands = append(commands, &command{ name: e.Name, aliases: e.Aliases, - echo: true, + child: true, validate: func(cmd commandInit) bool { return true }, diff --git a/discord/help.go b/discord/help.go index a8fcd53..9b88c32 100644 --- a/discord/help.go +++ b/discord/help.go @@ -65,7 +65,7 @@ func allHelp(cmd commandInit) *discordgo.MessageEmbed { embed.Description = "Commands with an asterisk (*) are staff-only" } for _, c := range commands { - if c.echo || c.album { + if c.child { continue } diff --git a/discord/imgur.go b/discord/imgur.go index 8449f52..8c441f5 100644 --- a/discord/imgur.go +++ b/discord/imgur.go @@ -19,7 +19,7 @@ func Album(cfg *config.Config) error { commands = append(commands, &command{ name: a.Name, aliases: a.Aliases, - album: true, + child: true, validate: func(cmd commandInit) bool { return true }, -- 2.41.0 From 1004a31be41d8833bc51732c7a03c73fb03f4820 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Thu, 13 May 2021 22:08:38 -0500 Subject: [PATCH 4/9] Signed-off-by: Etzelia --- config/config.go | 2 +- sedbot.toml | 103 ----------------------------------------------- 2 files changed, 1 insertion(+), 104 deletions(-) delete mode 100755 sedbot.toml diff --git a/config/config.go b/config/config.go index a28db47..73101a0 100644 --- a/config/config.go +++ b/config/config.go @@ -86,7 +86,7 @@ func Load(configPath string) (*Config, error) { var err error var configContent []byte if len(configPath) == 0 { - configPath = "sedbot.toml" + configPath = "canopeas.toml" } configContent, err = ioutil.ReadFile(configPath) diff --git a/sedbot.toml b/sedbot.toml deleted file mode 100755 index e0d541f..0000000 --- a/sedbot.toml +++ /dev/null @@ -1,103 +0,0 @@ -# token is the Discord token for the bot -token = "ODMyNDUxMDUyNTY5MTAwMzA4.YHj-dQ.UZEO71yJpGVDUFguTx3vs6rpKu0" - -# prefix is the bot command prefix -prefix = "!" - -# db_path is the path to the database (default is next to binary) -db_path = "sedbot.db" - -# mc_path is the path to the root directory of the minecraft server -mc_path = "/home/minecraft/server/" - -# fired_role is to check how many time Carolyn has been fired -fired_role = "0" - -# register_role is the role to assign to a user after registering -register_role = "0" - -# registered_channel is the channel to message to welcome the newly registered user -registered_channel = "0" - -# leave_channel is the channel to post leave messages to -leave_channel = "0" - -# staff_roles are for staff commands -staff_roles = [] - -# meme_rate is the rate limit for memes -meme_rate = "0" - -# Imgur Client ID -imgur_client_id = "66153d2fa93df9b" - -# ServerAPI options -[serverapi] -# API endpoint -endpoint = "" -# Auth token -token = "" - -# Twitter options -[twitter] -# Consumer Key -consumer_key = "" -# Consumer Secret -consumer_secret = "" -# Access Token -access_token = "" -# Access Secret -access_secret = "" - -# Server options -[server] -# connection address -address = "" -# connection port -port = 25565 - -# MCM options -[mcm] -# the token for the MCM API -token = "" -# the base URL to the MCM API -url = "" - -# insults -# , your looks like , you -[insult] -targets = [] -comparisons = [] -adjectives = [] -nouns = [] - -# compliments -# , I would my just to . -[compliment] -verbs = [] -nouns = [] -minor_things = [] - -[[albums]] -name = "jupiter" -aliases = ["jup", "jupjup"] -album_id = "TaJVIdQ" -help = "Images of Jupiter" - -# echoes are any basic command -> message -[[echoes]] -name = "discord" -aliases = ["invite", "gib"] -message = "" -help = "Get the invite link" - -# message_roles are for messages that should toggle a role when a user selects it -[[message_roles]] -channel_id = "0" -message_id = "0" -[[message_roles.reactions]] -role_id = "0" -emoji = "👍" -[[message_roles.reactions]] -role_id = "0" -emoji = "👎" \ No newline at end of file -- 2.41.0 From cc3ceb66685180e46e9eea476a767a1d5c8d8f00 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Fri, 14 May 2021 03:10:02 +0000 Subject: [PATCH 5/9] Make imgur album commands configurable (#7) Signed-off-by: Etzelia Rename echo/album field to child Signed-off-by: Etzelia Mark clear as staffOnly Signed-off-by: Etzelia Add imgur album commands Signed-off-by: Etzelia Reviewed-on: https://git.birbmc.com/Etzelia/canopeas/pulls/7 Co-Authored-By: Etzelia Co-Committed-By: Etzelia --- config/canopeas.example.toml | 8 +++- config/config.go | 18 ++++++--- discord/clear.go | 3 +- discord/discord.go | 13 +++---- discord/echo.go | 2 +- discord/help.go | 2 +- discord/history.go | 4 +- discord/imgur.go | 71 ++++++++++++++++++++++++++++++++++++ discord/jupiter.go | 21 ----------- imgur/imgur.go | 19 +++------- 10 files changed, 109 insertions(+), 52 deletions(-) create mode 100644 discord/imgur.go delete mode 100644 discord/jupiter.go diff --git a/config/canopeas.example.toml b/config/canopeas.example.toml index cda4eb2..f01f229 100644 --- a/config/canopeas.example.toml +++ b/config/canopeas.example.toml @@ -5,7 +5,7 @@ token = "" prefix = "!" # db_path is the path to the database (default is next to binary) -db_path = "sedbot.db" +db_path = "canopeas.db" # mc_path is the path to the root directory of the minecraft server mc_path = "/home/minecraft/server/" @@ -78,6 +78,12 @@ verbs = [] nouns = [] minor_things = [] +[[albums]] +name = "jupiter" +aliases = ["jup", "jupjup"] +album_id = "" +help = "Images of Jupiter" + # echoes are any basic command -> message [[echoes]] name = "discord" diff --git a/config/config.go b/config/config.go index 2e7e8d1..73101a0 100644 --- a/config/config.go +++ b/config/config.go @@ -38,6 +38,7 @@ type Config struct { StaffRoles []string `toml:"staff_roles"` Echoes []Echo `toml:"echoes"` + Albums []Album `toml:"albums"` MessageRoles []MessageRole `toml:"message_roles"` RegisterRole string `toml:"register_role"` RegisteredChannel string `toml:"registered_channel"` @@ -58,13 +59,13 @@ type Config struct { } type MessageRole struct { - ChannelID string `toml:"channel_id"` - MessageID string `toml:"message_id"` + ChannelID string `toml:"channel_id"` + MessageID string `toml:"message_id"` Reactions []MessageReaction `toml:"reactions"` } type MessageReaction struct { - Emoji string `toml:"emoji"` - RoleID string `toml:"role_id"` + Emoji string `toml:"emoji"` + RoleID string `toml:"role_id"` } type Echo struct { @@ -74,11 +75,18 @@ type Echo struct { Help string `toml:"help"` } +type Album struct { + Name string `toml:"name"` + Aliases []string `toml:"aliases"` + AlbumID string `toml:"album_id"` + Help string `toml:"help"` +} + func Load(configPath string) (*Config, error) { var err error var configContent []byte if len(configPath) == 0 { - configPath = "sedbot.toml" + configPath = "canopeas.toml" } configContent, err = ioutil.ReadFile(configPath) diff --git a/discord/clear.go b/discord/clear.go index f75c676..3a86822 100644 --- a/discord/clear.go +++ b/discord/clear.go @@ -9,7 +9,8 @@ const clearMax = 20 func init() { commands = append(commands, &command{ - name: "clear", + name: "clear", + staffOnly: true, validate: func(cmd commandInit) bool { return isStaff(cmd.message.Member.Roles, cmd.config.StaffRoles) }, diff --git a/discord/discord.go b/discord/discord.go index 423087f..93c5f89 100644 --- a/discord/discord.go +++ b/discord/discord.go @@ -7,12 +7,11 @@ import ( "git.birbmc.com/canopeas/config" "git.birbmc.com/canopeas/database" - "git.birbmc.com/canopeas/imgur" + "git.birbmc.com/Etzelia/go-serverapi" "github.com/bwmarrin/discordgo" "github.com/dghubble/go-twitter/twitter" "github.com/dghubble/oauth1" - "git.birbmc.com/Etzelia/go-serverapi" "go.jolheiser.com/beaver" ) @@ -38,7 +37,7 @@ type commandInit struct { type command struct { staffOnly bool deleteInvocation bool - echo bool + child bool // TODO Does this really need to exist separately? validate func(cmd commandInit) bool run func(cmd commandInit) (string, error) @@ -53,11 +52,8 @@ func Bot(cfg *config.Config, db *database.Database) (*discordgo.Session, error) return nil, err } - // Init Jupiter images + // Init rand rand.Seed(time.Now().UnixNano()) - if err := imgur.Init(cfg.ImgurClientID); err != nil { - return nil, err - } // Init ServerAPI sapi := serverapi.NewClient(cfg.ServerAPI.Endpoint, serverapi.WithToken(cfg.ServerAPI.Token)) @@ -86,6 +82,9 @@ func Bot(cfg *config.Config, db *database.Database) (*discordgo.Session, error) } // Init commandMap + if err := Album(cfg); err != nil { + return nil, err + } Echo(cfg) for _, c := range commands { if c.name == "" { diff --git a/discord/echo.go b/discord/echo.go index b69bd85..7c230d5 100644 --- a/discord/echo.go +++ b/discord/echo.go @@ -14,7 +14,7 @@ func Echo(cfg *config.Config) { commands = append(commands, &command{ name: e.Name, aliases: e.Aliases, - echo: true, + child: true, validate: func(cmd commandInit) bool { return true }, diff --git a/discord/help.go b/discord/help.go index 2587ef6..9b88c32 100644 --- a/discord/help.go +++ b/discord/help.go @@ -65,7 +65,7 @@ func allHelp(cmd commandInit) *discordgo.MessageEmbed { embed.Description = "Commands with an asterisk (*) are staff-only" } for _, c := range commands { - if c.echo { + if c.child { continue } diff --git a/discord/history.go b/discord/history.go index a79a032..fe697c1 100644 --- a/discord/history.go +++ b/discord/history.go @@ -5,10 +5,10 @@ import ( "strings" "time" - "github.com/bwmarrin/discordgo" - "go.jolheiser.com/beaver" "gitea.com/jolheiser/gojang" "gitea.com/jolheiser/gojang/rate" + "github.com/bwmarrin/discordgo" + "go.jolheiser.com/beaver" ) func init() { diff --git a/discord/imgur.go b/discord/imgur.go new file mode 100644 index 0000000..8c441f5 --- /dev/null +++ b/discord/imgur.go @@ -0,0 +1,71 @@ +package discord + +import ( + "fmt" + "strings" + + "git.birbmc.com/canopeas/config" + "git.birbmc.com/canopeas/imgur" + + "github.com/bwmarrin/discordgo" +) + +func Album(cfg *config.Config) error { + for _, a := range cfg.Albums { + images, err := imgur.Get(cfg.ImgurClientID, a.AlbumID) + if err != nil { + return err + } + commands = append(commands, &command{ + name: a.Name, + aliases: a.Aliases, + child: true, + validate: func(cmd commandInit) bool { + return true + }, + run: func(cmd commandInit) (string, error) { + if !memeRateLimit.Try() { + return "", nil + } + img := images[rand.Intn(len(images))-1] + return img.Link, nil + }, + help: a.Help, + }) + } + + commands = append(commands, &command{ + deleteInvocation: true, + name: "albums", + validate: func(cmd commandInit) bool { + return true + }, + run: func(cmd commandInit) (string, error) { + embed := &discordgo.MessageEmbed{ + Title: "Album Commands", + Fields: make([]*discordgo.MessageEmbedField, len(cfg.Albums)), + } + for i, a := range cfg.Albums { + name := a.Name + if len(a.Aliases) > 0 { + name += fmt.Sprintf(" (%s)", strings.Join(a.Aliases, ", ")) + } + embed.Fields[i] = &discordgo.MessageEmbedField{ + Name: name, + Value: a.Help, + Inline: true, + } + } + + channel, err := cmd.session.UserChannelCreate(cmd.message.Author.ID) + if err != nil { + return "", err + } + + sendEmbed(cmd.session, channel.ID, embed) + return "", nil + }, + help: "Get all imgur albums", + }) + return nil +} diff --git a/discord/jupiter.go b/discord/jupiter.go deleted file mode 100644 index a045721..0000000 --- a/discord/jupiter.go +++ /dev/null @@ -1,21 +0,0 @@ -package discord - -import "git.birbmc.com/canopeas/imgur" - -func init() { - commands = append(commands, &command{ - name: "jupiter", - aliases: []string{"jup", "jupjup"}, - validate: func(cmd commandInit) bool { - return true - }, - run: func(cmd commandInit) (string, error) { - if !memeRateLimit.Try() { - return "", nil - } - img := imgur.Images[rand.Intn(len(imgur.Images))-1] - return img.Link, nil - }, - help: "Get a Jupiter image", - }) -} diff --git a/imgur/imgur.go b/imgur/imgur.go index b7b6378..0b2e680 100644 --- a/imgur/imgur.go +++ b/imgur/imgur.go @@ -6,10 +6,6 @@ import ( "net/http" ) -// TODO Make a client for this in a separate module - -var Images []*Image - type Response struct { Images []*Image `json:"data"` Success bool `json:"success"` @@ -33,23 +29,20 @@ type Image struct { Link string `json:"link"` } -func Init(clientID string) error { +func Get(clientID, albumID string) ([]*Image, error) { - req, err := http.NewRequest(http.MethodGet, "https://api.imgur.com/3/album/TaJVIdQ/images", nil) + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("https://api.imgur.com/3/album/%s/images", albumID), nil) if err != nil { - return err + return nil, err } req.Header.Set("Authorization", fmt.Sprintf("Client-ID %s", clientID)) resp, err := http.DefaultClient.Do(req) if err != nil { - return err + return nil, err } + defer resp.Body.Close() var imgurResp Response - if err := json.NewDecoder(resp.Body).Decode(&imgurResp); err != nil { - return err - } - Images = imgurResp.Images - return resp.Body.Close() + return imgurResp.Images, json.NewDecoder(resp.Body).Decode(&imgurResp) } -- 2.41.0 From 8e838851184c0be157e4cf453582195970542b01 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Fri, 14 May 2021 03:27:39 +0000 Subject: [PATCH 6/9] Dad joke status (#8) Dad joke status Signed-off-by: Etzelia Reviewed-on: https://git.birbmc.com/Etzelia/canopeas/pulls/8 Co-Authored-By: Etzelia Co-Committed-By: Etzelia --- discord/dad.go | 65 +++++++++++++++++++++++++++------------------- discord/discord.go | 16 ++++++++++++ main.go | 2 +- 3 files changed, 56 insertions(+), 27 deletions(-) diff --git a/discord/dad.go b/discord/dad.go index a9fb940..c91c39f 100644 --- a/discord/dad.go +++ b/discord/dad.go @@ -2,8 +2,11 @@ package discord import ( "encoding/json" + "errors" "io/ioutil" "net/http" + + "go.jolheiser.com/beaver" ) const ( @@ -28,33 +31,9 @@ func init() { return "", nil } - req, err := http.NewRequest(http.MethodGet, dadJokeAPI, nil) + dj, err := newDadJoke() if err != nil { - return "", err - } - req.Header.Add("Accept", "application/json") - - resp, err := http.DefaultClient.Do(req) - if err != nil { - return "", err - } - - if resp.StatusCode != http.StatusOK { - return dadJokeErr, nil - } - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return "", err - } - - var dj dadJoke - if err := json.Unmarshal(body, &dj); err != nil { - return "", nil - } - - // Check status again, in case API returned an error - if dj.Status != http.StatusOK { + beaver.Warnf("error getting new dad joke: %v", err) return dadJokeErr, nil } @@ -63,3 +42,37 @@ func init() { help: "Get a random Dad joke", }) } + +func newDadJoke() (*dadJoke, error) { + req, err := http.NewRequest(http.MethodGet, dadJokeAPI, nil) + if err != nil { + return nil, err + } + req.Header.Add("Accept", "application/json") + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, err + } + + if resp.StatusCode != http.StatusOK { + return nil, errors.New("non-ok status") + } + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + var dj *dadJoke + if err := json.Unmarshal(body, &dj); err != nil { + return nil, errors.New("could not unmarshal") + } + + // Check status again, in case API returned an error + if dj.Status != http.StatusOK { + return nil, errors.New("API error") + } + + return dj, nil +} diff --git a/discord/discord.go b/discord/discord.go index 93c5f89..c3e9571 100644 --- a/discord/discord.go +++ b/discord/discord.go @@ -165,6 +165,9 @@ func isStaff(authorRoleIDs, staffRoleIDs []string) bool { func readyHandler() func(s *discordgo.Session, m *discordgo.Ready) { return func(s *discordgo.Session, r *discordgo.Ready) { beaver.Infof("https://discord.com/api/oauth2/authorize?client_id=%s&permissions=0&redirect_uri=https://birbmc.com&scope=bot", r.User.ID) + + // Init status changer + go updateStatus(s) } } @@ -276,3 +279,16 @@ func leaveHandler(cfg *config.Config) func(s *discordgo.Session, m *discordgo.Gu sendMessage(s, cfg.LeaveChannel, fmt.Sprintf("%s (%s) left the server. :sob:", m.Mention(), m.User.String()), true) } } + +func updateStatus(s *discordgo.Session) { + ticker := time.NewTicker(time.Minute * 30) + for { + dj, err := newDadJoke() + if err != nil { + beaver.Warnf("could not get new dad joke: %v", err) + } else if err := s.UpdateStatus(1, dj.Joke); err != nil { + beaver.Warnf("could not update status: %v", err) + } + <-ticker.C + } +} diff --git a/main.go b/main.go index acef729..5c3ac85 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ import ( var configFlag string func main() { - flag.StringVar(&configFlag, "config", "sedbot.toml", "Set config path") + flag.StringVar(&configFlag, "config", "canopeas.toml", "Set config path") flag.Parse() beaver.Console.Format = beaver.FormatOptions{ -- 2.41.0 From 4fb7cc2928cfa1c8d7fb6234a123a9288cd06e15 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sun, 20 Jun 2021 21:35:48 +0000 Subject: [PATCH 7/9] Closures (#9) Closures Signed-off-by: Etzelia Reviewed-on: https://git.birbmc.com/Etzelia/canopeas/pulls/9 Co-Authored-By: Etzelia Co-Committed-By: Etzelia --- discord/echo.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/discord/echo.go b/discord/echo.go index 7c230d5..df08ff1 100644 --- a/discord/echo.go +++ b/discord/echo.go @@ -10,7 +10,8 @@ import ( ) func Echo(cfg *config.Config) { - for _, e := range cfg.Echoes { + for _, echo := range cfg.Echoes { + e := echo // Closure commands = append(commands, &command{ name: e.Name, aliases: e.Aliases, -- 2.41.0 From 74e49546fee50cfbca9b5bd5bdbafaa227e8635e Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sat, 17 Jul 2021 01:26:23 +0000 Subject: [PATCH 8/9] Add config for register URL and check for dupes (#12) Update modules Signed-off-by: Etzelia Update module Signed-off-by: Etzelia Start CI Move welcome channel to register table Signed-off-by: Etzelia Add config for register URL and check for dupes Signed-off-by: Etzelia Reviewed-on: https://git.canopymc.net/Etzelia/canopeas/pulls/12 Reviewed-by: ZeroHD Co-Authored-By: Etzelia Co-Committed-By: Etzelia --- .drone.yml | 2 +- config/canopeas.example.toml | 16 ++++++++++------ config/config.go | 24 +++++++++++++----------- discord/ban.go | 2 +- discord/birb.go | 2 +- discord/broadcast.go | 2 +- discord/discord.go | 6 +++--- discord/echo.go | 2 +- discord/imgur.go | 4 ++-- discord/inspire.go | 2 +- discord/register.go | 28 +++++++++++++++++++++------- discord/unban.go | 2 +- discord/utils.go | 4 ++-- go.mod | 10 +++++----- go.sum | 16 ++++++++-------- main.go | 6 +++--- 16 files changed, 74 insertions(+), 54 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4d81de7..5c9eba7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -37,6 +37,6 @@ steps: settings: token: from_secret: gitea_token - base: https://git.birbmc.com + base: https://git.canopymc.net files: - "canopeas" \ No newline at end of file diff --git a/config/canopeas.example.toml b/config/canopeas.example.toml index f01f229..f1ff6a1 100644 --- a/config/canopeas.example.toml +++ b/config/canopeas.example.toml @@ -13,12 +13,6 @@ mc_path = "/home/minecraft/server/" # fired_role is to check how many time Carolyn has been fired fired_role = "0" -# register_role is the role to assign to a user after registering -register_role = "0" - -# registered_channel is the channel to message to welcome the newly registered user -registered_channel = "0" - # leave_channel is the channel to post leave messages to leave_channel = "0" @@ -31,6 +25,16 @@ meme_rate = "0" # Imgur Client ID imgur_client_id = "" +[register] +# role is the role to assign to a user after registering +role = "0" + +# url is the URL to show to new users +url = "https://google.com" + +# welcome_channel is the channel to message to welcome the newly registered user +welcome_channel = "0" + # ServerAPI options [serverapi] # API endpoint diff --git a/config/config.go b/config/config.go index 73101a0..bd0d679 100644 --- a/config/config.go +++ b/config/config.go @@ -35,17 +35,19 @@ type Config struct { AccessToken string `toml:"access_token"` AccessSecret string `toml:"access_secret"` } `toml:"twitter"` - - StaffRoles []string `toml:"staff_roles"` - Echoes []Echo `toml:"echoes"` - Albums []Album `toml:"albums"` - MessageRoles []MessageRole `toml:"message_roles"` - RegisterRole string `toml:"register_role"` - RegisteredChannel string `toml:"registered_channel"` - LeaveChannel string `toml:"leave_channel"` - FiredRole string `toml:"fired_role"` - MemeRate string `toml:"meme_rate"` - Insult struct { + StaffRoles []string `toml:"staff_roles"` + Echoes []Echo `toml:"echoes"` + Albums []Album `toml:"albums"` + MessageRoles []MessageRole `toml:"message_roles"` + Register struct { + URL string `toml:"url"` + Role string `toml:"role"` + WelcomeChannel string `toml:"welcome_channel"` + } `toml:"register"` + LeaveChannel string `toml:"leave_channel"` + FiredRole string `toml:"fired_role"` + MemeRate string `toml:"meme_rate"` + Insult struct { Targets []string `toml:"targets"` Comparisons []string `toml:"comparisons"` Adjectives []string `toml:"adjectives"` diff --git a/discord/ban.go b/discord/ban.go index 9976341..5601499 100644 --- a/discord/ban.go +++ b/discord/ban.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "git.birbmc.com/Etzelia/go-serverapi" + "git.canopymc.net/Etzelia/go-serverapi" ) func init() { diff --git a/discord/birb.go b/discord/birb.go index dba4e7a..572fb82 100644 --- a/discord/birb.go +++ b/discord/birb.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "git.birbmc.com/Etzelia/falseknees" + "git.canopymc.net/Etzelia/falseknees" ) func init() { diff --git a/discord/broadcast.go b/discord/broadcast.go index 7864fcd..a6c3513 100644 --- a/discord/broadcast.go +++ b/discord/broadcast.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "git.birbmc.com/Etzelia/go-serverapi" + "git.canopymc.net/Etzelia/go-serverapi" ) func init() { diff --git a/discord/discord.go b/discord/discord.go index c3e9571..00a9527 100644 --- a/discord/discord.go +++ b/discord/discord.go @@ -5,10 +5,10 @@ import ( "strings" "time" - "git.birbmc.com/canopeas/config" - "git.birbmc.com/canopeas/database" + "git.canopymc.net/Etzelia/canopeas/config" + "git.canopymc.net/Etzelia/canopeas/database" - "git.birbmc.com/Etzelia/go-serverapi" + "git.canopymc.net/Etzelia/go-serverapi" "github.com/bwmarrin/discordgo" "github.com/dghubble/go-twitter/twitter" "github.com/dghubble/oauth1" diff --git a/discord/echo.go b/discord/echo.go index df08ff1..439bff7 100644 --- a/discord/echo.go +++ b/discord/echo.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "git.birbmc.com/canopeas/config" + "git.canopymc.net/Etzelia/canopeas/config" "github.com/bwmarrin/discordgo" ) diff --git a/discord/imgur.go b/discord/imgur.go index 8c441f5..7705375 100644 --- a/discord/imgur.go +++ b/discord/imgur.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "git.birbmc.com/canopeas/config" - "git.birbmc.com/canopeas/imgur" + "git.canopymc.net/Etzelia/canopeas/config" + "git.canopymc.net/Etzelia/canopeas/imgur" "github.com/bwmarrin/discordgo" ) diff --git a/discord/inspire.go b/discord/inspire.go index c622f7d..8a66759 100644 --- a/discord/inspire.go +++ b/discord/inspire.go @@ -1,6 +1,6 @@ package discord -import "git.birbmc.com/Etzelia/inspiro" +import "git.canopymc.net/Etzelia/inspiro" func init() { commands = append(commands, &command{ diff --git a/discord/register.go b/discord/register.go index 7a4a3e3..b844857 100644 --- a/discord/register.go +++ b/discord/register.go @@ -7,10 +7,10 @@ import ( "path/filepath" "strings" - "git.birbmc.com/canopeas/config" + "git.canopymc.net/Etzelia/canopeas/config" - "git.birbmc.com/Etzelia/go-mcm" - "git.birbmc.com/Etzelia/go-mcm/model/django" + "git.canopymc.net/Etzelia/go-mcm" + "git.canopymc.net/Etzelia/go-mcm/model/django" ) const bannedPlayersFile = "banned-players.json" @@ -69,7 +69,7 @@ func init() { } } else if len(apps) > 0 { if apps[0].Accepted != nil && *apps[0].Accepted { - return "Please join the server and then re-try this command", nil + return fmt.Sprintf("Please join the server at `%s` and then re-try this command", cmd.config.Register.URL), nil } } else { return "No player or applications found for that username", nil @@ -82,16 +82,30 @@ func init() { return "Your application was denied, good luck finding a new server", nil } - // Accepted + // Accepted, check for dupe user + guild, err := cmd.session.State.Guild(cmd.message.GuildID) + if err != nil { + return "", err + } + for _, member := range guild.Members { + nick := member.Nick + if nick == "" { + } + nick = member.User.Username + if strings.EqualFold(nickname, nick) { + return "A member with that name already exists in this Discord. Please contact staff.", nil + } + } + if err := cmd.session.GuildMemberNickname(cmd.message.GuildID, cmd.message.Author.ID, nickname); err != nil { return "", err } - if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.RegisterRole); err != nil { + if err := cmd.session.GuildMemberRoleAdd(cmd.message.GuildID, cmd.message.Author.ID, cmd.config.Register.Role); err != nil { return "", err } // Don't return feedback because this goes in a different channel - sendMessage(cmd.session, cmd.config.RegisteredChannel, fmt.Sprintf("Welcome, **%s**!", cmd.message.Author.Mention()), false) + sendMessage(cmd.session, cmd.config.Register.WelcomeChannel, fmt.Sprintf("Welcome, **%s**!", cmd.message.Author.Mention()), false) return "", nil }, help: "Register yourself with the Discord", diff --git a/discord/unban.go b/discord/unban.go index b357048..cee5344 100644 --- a/discord/unban.go +++ b/discord/unban.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "git.birbmc.com/canopeas/database" + "git.canopymc.net/Etzelia/canopeas/database" ) func init() { diff --git a/discord/utils.go b/discord/utils.go index fcd11b2..c599243 100644 --- a/discord/utils.go +++ b/discord/utils.go @@ -5,9 +5,9 @@ import ( "net/http" "time" - "git.birbmc.com/canopeas/database" + "git.canopymc.net/Etzelia/canopeas/database" - "git.birbmc.com/Etzelia/go-serverapi" + "git.canopymc.net/Etzelia/go-serverapi" "go.jolheiser.com/beaver" ) diff --git a/go.mod b/go.mod index 88ce2be..2e0b0b8 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ -module git.birbmc.com/canopeas +module git.canopymc.net/Etzelia/canopeas go 1.16 require ( - git.birbmc.com/Etzelia/falseknees v0.0.0-20210505030520-ce2b19ebd088 - git.birbmc.com/Etzelia/go-mcm v0.0.0-20210505031740-e1ed806ef685 - git.birbmc.com/Etzelia/go-serverapi v0.0.0-20210505031332-398feec0ab7c - git.birbmc.com/Etzelia/inspiro v0.0.2 + git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451 + git.canopymc.net/Etzelia/go-mcm v0.0.0-20210713232816-d2b27d7edff0 + git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304 + git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f gitea.com/jolheiser/gojang v0.0.7 gitea.com/jolheiser/xkcd v0.0.2 github.com/bwmarrin/discordgo v0.22.0 diff --git a/go.sum b/go.sum index 82e5002..8b1ea55 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,11 @@ -git.birbmc.com/Etzelia/falseknees v0.0.0-20210505030520-ce2b19ebd088 h1:M4ZyccJQrio2jZEehRTGDs4LQ8FXx8BF+ng346B1cvY= -git.birbmc.com/Etzelia/falseknees v0.0.0-20210505030520-ce2b19ebd088/go.mod h1:BWmpXhZF6Cl/gCGGt0IhJpjnAWjcMBdU+m4nnBEQUk0= -git.birbmc.com/Etzelia/go-mcm v0.0.0-20210505031740-e1ed806ef685 h1:IWiRA9U58aBa2ZW2v7cjDymaxWqr+8DVcskzo4hAU2k= -git.birbmc.com/Etzelia/go-mcm v0.0.0-20210505031740-e1ed806ef685/go.mod h1:JXB7oUc0CS0NwuFkYcHkzbYEBEMigLldn4VLvwFIhdk= -git.birbmc.com/Etzelia/go-serverapi v0.0.0-20210505031332-398feec0ab7c h1:S/9aOOsBbE9rJDk43Vh4HOEgHmHxqehd8VMi5fGdHdM= -git.birbmc.com/Etzelia/go-serverapi v0.0.0-20210505031332-398feec0ab7c/go.mod h1:KH8M3zEZuJw9kNFVE+EOESZaMjSizQzSFiY8bqMd8FY= -git.birbmc.com/Etzelia/inspiro v0.0.2 h1:/lNp4+RLfAvLGoq69cQ4enYjVNYBP7JzRmSxDvQtVWs= -git.birbmc.com/Etzelia/inspiro v0.0.2/go.mod h1:JT9Q/xy8U2Gl/89zfW4Wnag2F1kGm5r6m4QR984lVIg= +git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451 h1:EbxWDS7sOyxv8einE7ps8WsywvlFqyKp3vdvk4PYVw4= +git.canopymc.net/Etzelia/falseknees v0.0.0-20210713232726-7325698e2451/go.mod h1:bgGHtcoYFmNIFgcU4P2LwqANZsJxoygnLI0C6OWE/U4= +git.canopymc.net/Etzelia/go-mcm v0.0.0-20210713232816-d2b27d7edff0 h1:UrwR0Ap4sjoRDfbi/ow76OeBAR9pI+BFKMYU6Jj9EtU= +git.canopymc.net/Etzelia/go-mcm v0.0.0-20210713232816-d2b27d7edff0/go.mod h1:M9yjY5mBSK5vGVPru7RG6K5bUfoRH7dTtyQ+MCuJ33g= +git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304 h1:gBzoEToJCO1nKbfhfzhGMgSWY6szwDbA8doVmPr3SIY= +git.canopymc.net/Etzelia/go-serverapi v0.0.0-20210713233104-94e800dbb304/go.mod h1:U0H8WgtAzR+L+65odnpUH1lT6z7ylcG6R9keOOTG+fk= +git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f h1:CupD+6/4Vrx0fGDIFf+cu8ponr19or3bCzkPPQXmRJk= +git.canopymc.net/Etzelia/inspiro v0.0.3-0.20210713233035-ffd88077147f/go.mod h1:7zYT6obYO7/a3v+gV+uNfNlWK1dJz6Mz7lY9FeRSGOU= gitea.com/jolheiser/gojang v0.0.7 h1:Q4cG7QYiKQsJtUWgXXiolAH9DCLRoaQ4olaO9OV628U= gitea.com/jolheiser/gojang v0.0.7/go.mod h1:r9kj2wv/21Da7VpWz+qmxLexH85o2BAM4NMxeYgQlcY= gitea.com/jolheiser/xkcd v0.0.2 h1:HJP83YwSKxSYcoNfpb1ZpAfBvkUAnN+YgeukraXtfrc= diff --git a/main.go b/main.go index 5c3ac85..295fe0c 100644 --- a/main.go +++ b/main.go @@ -6,9 +6,9 @@ import ( "os/signal" "syscall" - "git.birbmc.com/canopeas/config" - "git.birbmc.com/canopeas/database" - "git.birbmc.com/canopeas/discord" + "git.canopymc.net/Etzelia/canopeas/config" + "git.canopymc.net/Etzelia/canopeas/database" + "git.canopymc.net/Etzelia/canopeas/discord" "go.jolheiser.com/beaver" ) -- 2.41.0 From ac862d8d185e42350da9921743dbee6f13f07dc2 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sat, 17 Jul 2021 19:51:15 +0000 Subject: [PATCH 9/9] Ignore self in register (#13) Ignore self in register Signed-off-by: Etzelia Reviewed-on: https://git.canopymc.net/Etzelia/canopeas/pulls/13 Reviewed-by: ZeroHD Co-Authored-By: Etzelia Co-Committed-By: Etzelia --- discord/register.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/register.go b/discord/register.go index b844857..e1fb0e4 100644 --- a/discord/register.go +++ b/discord/register.go @@ -92,7 +92,7 @@ func init() { if nick == "" { } nick = member.User.Username - if strings.EqualFold(nickname, nick) { + if strings.EqualFold(nickname, nick) && cmd.message.Author.ID != member.User.ID { return "A member with that name already exists in this Discord. Please contact staff.", nil } } -- 2.41.0