From c8e135c11cc0f0d2227c355760787beeecb08442 Mon Sep 17 00:00:00 2001 From: Dylan Hackworth Date: Wed, 29 Jul 2020 17:32:11 -0500 Subject: [PATCH 1/5] Cleanup --- scripts/build.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 scripts/build.sh diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..118fc28 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,5 @@ +cd ../ +OUTPUT=$PWD +cd ./cmd/mcauth +go build -o $OUTPUT +echo 'Built to' $OUTPUT \ No newline at end of file From 1c220227b5902360d4cab4eb48cf7e3b40889d9e Mon Sep 17 00:00:00 2001 From: Dylan Hackworth Date: Wed, 29 Jul 2020 17:43:53 -0500 Subject: [PATCH 2/5] Simplicity --- internal/bot/events.go | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/internal/bot/events.go b/internal/bot/events.go index f257cc7..ffee35b 100644 --- a/internal/bot/events.go +++ b/internal/bot/events.go @@ -52,9 +52,6 @@ func (bot *Bot) onMessage(_ *dg.Session, msg *dg.MessageCreate) { // args = [, ] args := strings.Fields(msg.Content) - isAdmin := bot.isAdmin(msg.Member) - // whether they attempted to run an administrator related command - adminAttempt := false if len(args) < 2 { return @@ -75,32 +72,45 @@ func (bot *Bot) onMessage(_ *dg.Session, msg *dg.MessageCreate) { bot.client, msg.Message, strings.Replace(commands, "{prefix}", bot.config.Prefix, -1), ) + default: + bot.onAdminCommand(msg.Message, args) + } +} + +func (bot *Bot) onAdminCommand(msg *dg.Message, args []string) { + isAdmin := bot.isAdmin(msg.Member) + + // whether they attempted to run an administrator related command + adminAttempt := false + + switch args[1] { /* Administrator Commands */ case "status": if isAdmin { - bot.cmdStatus(msg.Message) + bot.cmdStatus(msg) } else { adminAttempt = true } case "lock": if isAdmin { bot.locked = true - _, _ = util.Reply(bot.client, msg.Message, "Maintenance mode is now on.") + _, _ = util.Reply(bot.client, msg, "Maintenance mode is now on.") } else { adminAttempt = true } case "unlock": if isAdmin { bot.locked = false - _, _ = util.Reply(bot.client, msg.Message, "Maintenance mode is now off.") + _, _ = util.Reply(bot.client, msg, "Maintenance mode is now off.") } else { adminAttempt = true } default: - _, _ = util.Reply(bot.client, msg.Message, bot.config.Help) + _, _ = util.Reply(bot.client, msg, bot.config.Help) } + if adminAttempt { - _, _ = util.Reply(bot.client, msg.Message, + _, _ = util.Reply(bot.client, msg, "You must be an administrator to run this command.", ) } From 8a62c14015fe5bf7f756e7c57c8f04ab3fb4daf1 Mon Sep 17 00:00:00 2001 From: Dylan Hackworth Date: Sun, 2 Aug 2020 13:24:49 -0500 Subject: [PATCH 3/5] Renamed MCAuth --- .../{1. The MCAuth Client (plugin).md => 1. The MCAuth Client.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{1. The MCAuth Client (plugin).md => 1. The MCAuth Client.md} (100%) diff --git a/docs/1. The MCAuth Client (plugin).md b/docs/1. The MCAuth Client.md similarity index 100% rename from docs/1. The MCAuth Client (plugin).md rename to docs/1. The MCAuth Client.md From f08b790d085cbee4c819c3f916687325abae64c5 Mon Sep 17 00:00:00 2001 From: Dylan Hackworth Date: Sun, 2 Aug 2020 13:41:08 -0500 Subject: [PATCH 4/5] Fixed hyperlink --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b8f6a73..2e9bc7d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ and give it the "why" you made the pull request. ## RTFM - 1. [The MCAuth Client (plugin)](./docs/1.%20The%20MCAuth%20Client%20(plugin).md) + 1. [The MCAuth Client](./docs/1.%20The%20MCAuth%20Client.md) 2. [The Web Server](./docs/2.%20Web%20Server.md) 1. [Verifying Players](./docs/2.1.%20Verifying%20Players.md) 2. [Alt Account Management](./docs/2.2.%20Alt%20Account%20Management.md) From 37a7dbd0f33d7e3e9b1daee1c81e4c9975067c34 Mon Sep 17 00:00:00 2001 From: Dylan Hackworth Date: Mon, 3 Aug 2020 19:24:19 -0500 Subject: [PATCH 5/5] Removed fatalf from member fetching --- internal/bot/bot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/bot/bot.go b/internal/bot/bot.go index cf8e08e..675f258 100644 --- a/internal/bot/bot.go +++ b/internal/bot/bot.go @@ -90,7 +90,7 @@ func (bot *Bot) syncMember(memberID string) { if strings.Contains(err.Error(), "Unknown Member") { bot.sync.SyncRoles(memberID, &[]string{}) } else { - log.Fatalf( + log.Printf( "Failed to fetch member \"%s\", please investigate \n%s", memberID, err, )