let admins reset default emojis

This commit is contained in:
Azareal 2020-07-15 17:05:06 +10:00
parent 5bfc5e3e40
commit 32bd1a5e28
1 changed files with 26 additions and 20 deletions

View File

@ -66,6 +66,7 @@ func init() {
var emojis map[string]string var emojis map[string]string
type emojiHolder struct { type emojiHolder struct {
NoDefault bool `json:"no_defaults"`
Emojis []map[string]string `json:"emojis"` Emojis []map[string]string `json:"emojis"`
} }
@ -77,17 +78,22 @@ func InitEmoji() error {
} }
emojis = make(map[string]string, len(emoji.Emojis)) emojis = make(map[string]string, len(emoji.Emojis))
if !emoji.NoDefault {
for _, item := range emoji.Emojis { for _, item := range emoji.Emojis {
for ikey, ival := range item { for ikey, ival := range item {
emojis[ikey] = ival emojis[ikey] = ival
} }
} }
}
emoji = emojiHolder{} emoji = emojiHolder{}
err = unmarshalJsonFileIgnore404("./config/emoji.json", &emoji) err = unmarshalJsonFileIgnore404("./config/emoji.json", &emoji)
if err != nil { if err != nil {
return err return err
} }
if emoji.NoDefault {
emojis = make(map[string]string)
}
for _, item := range emoji.Emojis { for _, item := range emoji.Emojis {
for ikey, ival := range item { for ikey, ival := range item {