forked from ImpactDevelopment/ImpactBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules.go
More file actions
102 lines (91 loc) · 3.24 KB
/
rules.go
File metadata and controls
102 lines (91 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package main
import (
"errors"
"fmt"
"log"
"strconv"
"strings"
"github.com/bwmarrin/discordgo"
)
const rulesChannel = "667494326372139008"
const rulesMessage = "667497572264312832"
var rules = []string{
"Discord ToS",
"Moderators have the final say. Do not argue with them.",
"Use the correct channels in this server. Do not DM anyone. Ask questions in <#" + help + ">, report bugs on github, etc",
"Channel specific rules or topics can be found in the channel description",
"No trolling, unnecessary pinging / @-ing, spamming, advertising, non-English conversation, NSFW content, bullying, or blatant rudeness",
"Don't \"ask to ask\". This means no messages that just say something like \"Can I ask a question?\", or \"Can someone help me?\", or, worst of all, \"hello??\". The answer is yes, in <#" + help + ">).",
}
var extraRules = []*discordgo.MessageEmbedField{
{
Name: "Volunteers",
Value: "All staff, including Support, Moderators, and Developers are volunteers. " +
"They are under _no obligation_ to help you, but are likely to if you are polite.",
},
{
Name: "Why can't I speak‽",
Value: "You need to verify yourself! Click the link at the top of my welcome DM to you, if you have it. Otherwise, click [here](https://impactclient.net/discord.html?member=1) and fill in your info manually.",
},
{
Name: "Terms",
Value: "By using this discord you agree to our bots storing information about you, such as your discord id. " +
"If you wish for this information to be removed from our servers you can run `i!optout` to delete any records we have about you and remove you from the server.",
},
}
func rulesHandler(caller *discordgo.Member, msg *discordgo.Message, args []string) error {
reply := discordgo.MessageEmbed{
Color: prettyembedcolor,
}
switch len(args) {
case 1:
reply.Title = "Rules"
reply.Description = buildRules()
case 2:
index, err := strconv.Atoi(args[1])
if err != nil {
return err
}
index-- // Rule numbers are one higher than index
if index >= len(rules) {
return errors.New("There are only " + strconv.Itoa(len(rules)) + " rules, " + args[1] + " is too high.")
}
if index < 0 {
return errors.New("Rules are counted from 1, " + args[1] + " is too low")
}
reply.Title = "Rule " + strconv.Itoa(index+1)
reply.Description = rules[index]
reply.Footer = &discordgo.MessageEmbedFooter{
Text: fmt.Sprintf("Run %s%s for more", prefix, args[0]),
}
default:
return errors.New("incorrect number of arguments")
}
_, err := discord.ChannelMessageSendEmbed(msg.ChannelID, &reply)
return err
}
func updateRules() {
_, err := discord.ChannelMessageEditEmbed(rulesChannel, rulesMessage, &discordgo.MessageEmbed{
Color: prettyembedcolor,
Thumbnail: &discordgo.MessageEmbedThumbnail{
URL: "https://cdn.discordapp.com/attachments/224684271913140224/571442198718185492/unknown.png",
},
Fields: append(extraRules, &discordgo.MessageEmbedField{
Name: "Rules",
Value: buildRules(),
}),
})
if err != nil {
log.Println("Unable to edit rules message with id " + rulesMessage)
}
}
func buildRules() string {
var r strings.Builder
for index, rule := range rules {
r.WriteString(strconv.Itoa(index + 1))
r.WriteString(". ")
r.WriteString(rule)
r.WriteString("\n")
}
return r.String()
}