Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package bot |
||
2 | |||
3 | import ( |
||
4 | "github.com/bwmarrin/discordgo" |
||
5 | "github.com/globalsign/mgo/bson" |
||
6 | ) |
||
7 | |||
8 | // Greetings sends greetings for user |
||
9 | func Greetings(discord *discordgo.Session, event *discordgo.GuildMemberAdd, guild *GuildData) { |
||
10 | if guild.Greeting != "" { |
||
11 | ch, cErr := discord.UserChannelCreate(event.User.ID) |
||
12 | if cErr != nil { |
||
13 | return |
||
14 | } |
||
15 | _, mErr := discord.ChannelMessageSend(ch.ID, guild.Greeting) |
||
16 | if mErr != nil { |
||
17 | return |
||
18 | } |
||
19 | } |
||
20 | } |
||
21 | |||
22 | // AddGreetings adds new greetings to guild |
||
23 | func (ctx *Context) AddGreetings(text string) { |
||
24 | ctx.Guilds.Guilds[ctx.Guild.ID].Greeting = text |
||
25 | _ = ctx.DB.Guilds().Update(bson.M{"id": ctx.Guild.ID}, bson.M{"$set": bson.M{"greeting": text}}) |
||
26 | } |
||
27 | |||
28 | // RemoveGreetings removes greetings from guild |
||
29 | func (ctx *Context) RemoveGreetings() { |
||
30 | ctx.Guilds.Guilds[ctx.Guild.ID].Greeting = "" |
||
31 | _ = ctx.DB.Guilds().Update(bson.M{"id": ctx.Guild.ID}, bson.M{"$set": bson.M{"greeting": ""}}) |
||
32 | |||
34 |