From 68c0afd97c1e2b7659cf6ad68a1608da9cfb1c2d Mon Sep 17 00:00:00 2001 From: Luther Wen Xu Date: Wed, 16 Oct 2019 12:47:36 +0800 Subject: [PATCH] go: discord/modules: Add limits to change trust --- GoBot/discord/config/translate.go | 2 ++ GoBot/discord/modules/trust.go | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/GoBot/discord/config/translate.go b/GoBot/discord/config/translate.go index b08c37b..8394770 100644 --- a/GoBot/discord/config/translate.go +++ b/GoBot/discord/config/translate.go @@ -132,6 +132,8 @@ const ChangeTrustSuccessTitle = "成功更新玩家评分 Update Player Score Su const ChangeTrustSuccessDescription = "你对这名玩家的分数改变已被记录。\nThe score has been updated." const ErrorChangeTrustTitle = "调整信誉分错误 Change Trust Error" const ErrorChangeTrustTargetNotFound = "无法寻找到改变目标。\nCannot find the target user." +const ErrorChangeTrustSelf = "无法改变自己的分数。\nCannot set your own score." +const ErrorChangeTrustNotMember = "目标用户不是伺服器成员。\nTarget user is not a server member." const ErrorChangeTrustRecentlyChanged = "你在一个月内设定过该名玩家的分数。你这次的更动没有被记录。\nYou have already changed your score for this player within the previous month. Your change was not recorded." const VoteSuggestionUsage = "!votesuggest <种类:custom> <内容>\n!votesuggest " diff --git a/GoBot/discord/modules/trust.go b/GoBot/discord/modules/trust.go index 73a5c67..d2d44a1 100644 --- a/GoBot/discord/modules/trust.go +++ b/GoBot/discord/modules/trust.go @@ -26,6 +26,28 @@ var changeTrust = enforceDM(memberFilter(true, enforceArgumentCount( return } + if member.User.ID == m.Author.ID { + message.InitNewEmbed( + config.ErrorChangeTrustTitle, + config.ErrorChangeTrustSelf, + config.ErrorColour, + ).Send(s, m.ChannelID) + } + + isMember := false + for _, v := range member.Roles { + if v == config.MemberRoleID { + isMember = true + } + } + if !isMember { + message.InitNewEmbed( + config.ErrorChangeTrustTitle, + config.ErrorChangeTrustNotMember, + config.ErrorColour, + ).Send(s, m.ChannelID) + } + embed := message.NewEmbed(). SetTitle(config.ChangeTrustPromptTitle). SetColour(config.ChangeTrustPromptColour).