Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add thanks command, update env, msg package and readme #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand All @@ -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 |

Expand Down
34 changes: 34 additions & 0 deletions app/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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!")
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type ChannelCfg struct {
intros string
rfr string
learningResources string
thanks string
}

type BotCfg struct {
Expand Down Expand Up @@ -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"),
Expand Down
1 change: 1 addition & 0 deletions app/msg/greetings.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
LogError string = "[ERROR] "
LogLearning string = "[Learning] "
LogShutdown string = "[Shutdown] "
LogThanks string = "[Thanks] "
)

const (
Expand Down