Skip to content

Commit

Permalink
Added slap command
Browse files Browse the repository at this point in the history
  • Loading branch information
FlameInTheDark committed May 15, 2019
1 parent 955abe1 commit d4f0daa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions bot/context.go
Expand Up @@ -70,6 +70,15 @@ func (ctx *Context) Loc(key string) string {
return ctx.Conf.Locales[ctx.GetGuild().Language][key]
}

func (ctx *Context) GetGuildUser(id string) *discordgo.User {
for i, m := range ctx.Guild.Members {
if m.User.ID == id {
return ctx.Guild.Members[i].User
}
}
return nil
}

// WeatherCode returns unicode symbol of weather font icon
func (ctx *Context) WeatherCode(code string) string {
return ctx.Conf.WeatherCodes[code]
Expand Down
7 changes: 6 additions & 1 deletion cmd/funcommand.go
Expand Up @@ -11,7 +11,12 @@ func SlapCommand(ctx bot.Context) {
if len(ctx.Args) > 0 {
url, err := fun.GetImageURL("slap")
if err == nil {
ctx.ReplyEmbedAttachmentImageURL("", fmt.Sprintf("%v slaping %v", ctx.User.Mention(), ctx.Args[0]), url)
user := ctx.GetGuildUser(ctx.Args[0][2 : len(ctx.Args[0])-1])
var mention = ctx.Args[0]
if user != nil {
mention = user.Username
}
ctx.ReplyEmbedAttachmentImageURL("", fmt.Sprintf("%v slaping %v", ctx.User.Username, mention), url)
} else {
fmt.Printf(err.Error())
}
Expand Down

0 comments on commit d4f0daa

Please sign in to comment.