diff --git a/README.md b/README.md index 22c066f..555768f 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,11 @@ If you are intending to fork FCCBot to use in your own server, understand that w ## **Getting Started** - ### **Installation** 1. Clone the repository. 2. Run `go get` to install the packages needed. - ### **Running** #### **Environment Variables** @@ -43,6 +41,7 @@ You will need to create .env files before running the bot: `dev.env` and `prod.e | LOG_CHANNEL | The log channel's id: create a channel, and right click it | | INTRO_CHANNEL | The introduction channel's id: create a channel, and right click it | | LEARNING_RESOURCE_CHANNEL | The learning resource channel's id: create a channel, and right click it | +| THANKS_CHANNEL | The thanks channel's id: create a channel, and right click it | | RFR_POST | The post to listen for react-for-role reactions: create a post, and right click it | | ROLE_VERIFIED | The role users receive when validated: create a role, and right click it | diff --git a/app/command.go b/app/command.go index d95c954..350a33a 100644 --- a/app/command.go +++ b/app/command.go @@ -52,6 +52,12 @@ func (c *Commands) create() { allSuccessful = false } + if _, err := c.bot.Session.ApplicationCommandCreate(c.bot.Cfg.bot.id, c.bot.Cfg.server.guild, ThankCommand); err != nil { + c.bot.SendLog(msg.LogError, "Whilst adding thank command:") + c.bot.SendLog(msg.LogError, err.Error()) + allSuccessful = false + } + if _, err := c.bot.Session.ApplicationCommandCreate(c.bot.Cfg.bot.id, c.bot.Cfg.server.guild, RemindCommand); err != nil { c.bot.SendLog(msg.LogError, "Whilst adding remind command:") c.bot.SendLog(msg.LogError, err.Error()) @@ -167,6 +173,26 @@ var LearningResourceCommand = &discordgo.ApplicationCommand{ }, } +var ThankCommand = &discordgo.ApplicationCommand{ + Name: "thanks", + Type: discordgo.ChatApplicationCommand, + Description: "Give thanks to a member of the community", + Options: []*discordgo.ApplicationCommandOption{ + { + Name: "user", + Type: discordgo.ApplicationCommandOptionUser, + Description: "Who do you want to thank?", + Required: true, + }, + { + Name: "reason-for-thanks", + Type: discordgo.ApplicationCommandOptionString, + Description: "Specify why you are thanking them.", + Required: true, + }, + }, +} + var RemindCommand = &discordgo.ApplicationCommand{ Name: "remind", Type: discordgo.ChatApplicationCommand, @@ -355,7 +381,15 @@ func (c *Commands) RegularCommandGroup(s *discordgo.Session, i *discordgo.Intera c.bot.Utils.SendResponse(i, "Thanks for posting a Learning Resource!") } + case "thanks": + userToThank := options[0].UserValue(s) + reasonForThanks := options[1].StringValue() + + messageContents := fmt.Sprintf("Thanks to %s, for helping %s with:\n %s", userToThank.Mention(), interactionMember.User.Mention(), reasonForThanks) + c.bot.Session.ChannelMessageSend(c.bot.Cfg.server.thanks, messageContents) + c.bot.SendLog(msg.LogThanks, fmt.Sprintf("%s said thanks to another user via the bot", interactionMember.User.Username)) + c.bot.Utils.SendResponse(i, "Thanks for showing your appreciation!") } } diff --git a/app/main.go b/app/main.go index c1915d1..0c49307 100644 --- a/app/main.go +++ b/app/main.go @@ -19,6 +19,7 @@ type ChannelCfg struct { intros string rfr string learningResources string + thanks string } type BotCfg struct { @@ -84,6 +85,7 @@ func main() { intros: os.Getenv("INTRO_CHANNEL"), rfr: os.Getenv("RFR_POST"), learningResources: os.Getenv("LEARNING_RESOURCE_CHANNEL"), + thanks: os.Getenv("THANKS_CHANNEL"), }, bot: BotCfg{ token: os.Getenv("BOT_TOKEN"), diff --git a/app/msg/greetings.go b/app/msg/greetings.go index 412623a..639af48 100644 --- a/app/msg/greetings.go +++ b/app/msg/greetings.go @@ -25,6 +25,7 @@ const ( LogError string = "[ERROR] " LogLearning string = "[Learning] " LogShutdown string = "[Shutdown] " + LogThanks string = "[Thanks] " ) const (