grim/wasdead

add a show-config command
draft
2019-05-11, Gary Kramlich
6efee9941570
Parents e42b44a80cf1
Children 25c58bcbc247
add a show-config command
--- a/discord/commands.go Sat May 11 21:30:21 2019 -0500
+++ b/discord/commands.go Sat May 11 21:54:24 2019 -0500
@@ -23,6 +23,7 @@
Help HelpCmd `kong:"cmd,help='displays this help message'"`
SetChannel SetChannelCmd `kong:"cmd,help='set the current channel as the channel to announce new streams'"`
+ ShowConfig ShowConfigCmd `kong:"cmd,help='show the configuration for the current guild.'"`
Status StatusCmd `kong:"cmd,help='get the streaming status of someone'"`
Uptime UptimeCmd `kong:"cmd,help='display how long the bot has been running for'"`
}
@@ -73,6 +74,34 @@
return nil
}
+type ShowConfigCmd struct{}
+
+func (c *ShowConfigCmd) Run(g *Globals) error {
+ guild, err := database.LoadGuild(g.msg.GuildID)
+ if err != nil {
+ return err
+ }
+
+ channel, err := g.client.client.Channel(guild.Channel)
+ if err != nil {
+ return err
+ }
+
+ embed := &discordgo.MessageEmbed{
+ Title: "@wasdead configuration",
+ Fields: []*discordgo.MessageEmbedField{
+ &discordgo.MessageEmbedField{
+ Name: "Announcement Channel",
+ Value: channel.Mention(),
+ },
+ },
+ }
+
+ g.client.sendChannelEmbed(g.msg.ChannelID, embed)
+
+ return nil
+}
+
type StatusCmd struct {
Target string `kong:"arg"`
}
--- a/discord/discord.go Sat May 11 21:30:21 2019 -0500
+++ b/discord/discord.go Sat May 11 21:54:24 2019 -0500
@@ -67,6 +67,15 @@
return err
}
+func (c *DiscordClient) sendChannelEmbed(channelID string, embed *discordgo.MessageEmbed) error {
+ _, err := c.client.ChannelMessageSendEmbed(
+ channelID,
+ embed,
+ )
+
+ return err
+}
+
func (c *DiscordClient) getPresence(guildId, userId string) *discordgo.Presence {
p, err := c.client.State.Presence(guildId, userId)
if err != nil {