the discord package - commands shouldn't be exported
This commit is contained in:
parent
9da466d526
commit
c3eb4b42d1
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
ChangeLanguageCommand Command = "changelanguage"
|
||||
cmdChangeLanguage command = "changelanguage"
|
||||
)
|
||||
|
||||
type hndlrChangeLanguage struct {
|
||||
|
@ -18,8 +18,8 @@ type hndlrChangeLanguage struct {
|
|||
|
||||
var _ commandHandler = &hndlrChangeLanguage{}
|
||||
|
||||
func (hndlr *hndlrChangeLanguage) cmd() Command {
|
||||
return ChangeLanguageCommand
|
||||
func (hndlr *hndlrChangeLanguage) cmd() command {
|
||||
return cmdChangeLanguage
|
||||
}
|
||||
|
||||
func (hndlr *hndlrChangeLanguage) requireAdmPermissions() bool {
|
||||
|
|
|
@ -7,13 +7,13 @@ import (
|
|||
"github.com/tribalwarshelp/dcbot/model"
|
||||
)
|
||||
|
||||
type Command string
|
||||
type command string
|
||||
|
||||
func (cmd Command) String() string {
|
||||
func (cmd command) String() string {
|
||||
return string(cmd)
|
||||
}
|
||||
|
||||
func (cmd Command) WithPrefix(prefix string) string {
|
||||
func (cmd command) WithPrefix(prefix string) string {
|
||||
return prefix + cmd.String()
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ type commandCtx struct {
|
|||
}
|
||||
|
||||
type commandHandler interface {
|
||||
cmd() Command
|
||||
cmd() command
|
||||
requireAdmPermissions() bool
|
||||
execute(ctx *commandCtx, m *discordgo.MessageCreate, args ...string)
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
coordsLimit = 20
|
||||
CoordsTranslationCommand Command = "coordstranslation"
|
||||
DisableCoordsTranslationCommand Command = "disablecoordstranslation"
|
||||
coordsLimit = 20
|
||||
cmdCoordsTranslation command = "coordstranslation"
|
||||
cmdDisableCoordsTranslation command = "disablecoordstranslation"
|
||||
)
|
||||
|
||||
var coordsRegex = regexp.MustCompile(`(\d+)\|(\d+)`)
|
||||
|
@ -28,8 +28,8 @@ type hndlrCoordsTranslation struct {
|
|||
|
||||
var _ commandHandler = &hndlrCoordsTranslation{}
|
||||
|
||||
func (hndlr *hndlrCoordsTranslation) cmd() Command {
|
||||
return CoordsTranslationCommand
|
||||
func (hndlr *hndlrCoordsTranslation) cmd() command {
|
||||
return cmdCoordsTranslation
|
||||
}
|
||||
|
||||
func (hndlr *hndlrCoordsTranslation) requireAdmPermissions() bool {
|
||||
|
@ -84,8 +84,8 @@ type hndlrDisableCoordsTranslation struct {
|
|||
|
||||
var _ commandHandler = &hndlrDisableCoordsTranslation{}
|
||||
|
||||
func (hndlr *hndlrDisableCoordsTranslation) cmd() Command {
|
||||
return DisableCoordsTranslationCommand
|
||||
func (hndlr *hndlrDisableCoordsTranslation) cmd() command {
|
||||
return cmdDisableCoordsTranslation
|
||||
}
|
||||
|
||||
func (hndlr *hndlrDisableCoordsTranslation) requireAdmPermissions() bool {
|
||||
|
|
|
@ -24,18 +24,18 @@ const (
|
|||
)
|
||||
|
||||
const (
|
||||
AddGroupCommand Command = "addgroup"
|
||||
DeleteGroupCommand Command = "deletegroup"
|
||||
GroupsCommand Command = "groups"
|
||||
ShowEnnobledBarbariansCommand Command = "showennobledbarbs"
|
||||
ObserveCommand Command = "observe"
|
||||
ObservationsCommand Command = "observations"
|
||||
DeleteObservationCommand Command = "deleteobservation"
|
||||
LostVillagesCommand Command = "lostvillages"
|
||||
DisableLostVillagesCommand Command = "disablelostvillages"
|
||||
ConqueredVillagesCommand Command = "conqueredvillages"
|
||||
DisableConqueredVillagesCommand Command = "disableconqueredvillages"
|
||||
ShowInternalsCommand Command = "showinternals"
|
||||
cmdAddGroup command = "addgroup"
|
||||
cmdDeleteGroup command = "deletegroup"
|
||||
cmdGroups command = "groups"
|
||||
cmdShowEnnobledBarbarians command = "showennobledbarbs"
|
||||
cmdObserve command = "observe"
|
||||
cmdObservations command = "observations"
|
||||
cmdDeleteObservation command = "deleteobservation"
|
||||
cmdLostVillages command = "lostvillages"
|
||||
cmdDisableLostVillages command = "disablelostvillages"
|
||||
cmdConqueredVillages command = "conqueredvillages"
|
||||
cmdDisableConqueredVillages command = "disableconqueredvillages"
|
||||
cmdShowInternals command = "showinternals"
|
||||
)
|
||||
|
||||
type hndlrAddGroup struct {
|
||||
|
@ -44,8 +44,8 @@ type hndlrAddGroup struct {
|
|||
|
||||
var _ commandHandler = &hndlrAddGroup{}
|
||||
|
||||
func (hndlr *hndlrAddGroup) cmd() Command {
|
||||
return AddGroupCommand
|
||||
func (hndlr *hndlrAddGroup) cmd() command {
|
||||
return cmdAddGroup
|
||||
}
|
||||
|
||||
func (hndlr *hndlrAddGroup) requireAdmPermissions() bool {
|
||||
|
@ -98,8 +98,8 @@ type hndlrDeleteGroup struct {
|
|||
|
||||
var _ commandHandler = &hndlrDeleteGroup{}
|
||||
|
||||
func (hndlr *hndlrDeleteGroup) cmd() Command {
|
||||
return DeleteGroupCommand
|
||||
func (hndlr *hndlrDeleteGroup) cmd() command {
|
||||
return cmdDeleteGroup
|
||||
}
|
||||
|
||||
func (hndlr *hndlrDeleteGroup) requireAdmPermissions() bool {
|
||||
|
@ -113,8 +113,8 @@ func (hndlr *hndlrDeleteGroup) execute(ctx *commandCtx, m *discordgo.MessageCrea
|
|||
m.Author.Mention()+" "+ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpDeleteGroup,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": DeleteGroupCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdDeleteGroup.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
@ -152,8 +152,8 @@ type hndlrGroups struct {
|
|||
|
||||
var _ commandHandler = &hndlrGroups{}
|
||||
|
||||
func (hndlr *hndlrGroups) cmd() Command {
|
||||
return GroupsCommand
|
||||
func (hndlr *hndlrGroups) cmd() command {
|
||||
return cmdGroups
|
||||
}
|
||||
|
||||
func (hndlr *hndlrGroups) requireAdmPermissions() bool {
|
||||
|
@ -203,8 +203,8 @@ type hndlrConqueredVillages struct {
|
|||
|
||||
var _ commandHandler = &hndlrConqueredVillages{}
|
||||
|
||||
func (hndlr *hndlrConqueredVillages) cmd() Command {
|
||||
return ConqueredVillagesCommand
|
||||
func (hndlr *hndlrConqueredVillages) cmd() command {
|
||||
return cmdConqueredVillages
|
||||
}
|
||||
|
||||
func (hndlr *hndlrConqueredVillages) requireAdmPermissions() bool {
|
||||
|
@ -219,7 +219,7 @@ func (hndlr *hndlrConqueredVillages) execute(ctx *commandCtx, m *discordgo.Messa
|
|||
MessageID: message.HelpConqueredVillages,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": hndlr.cmd().WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
@ -269,8 +269,8 @@ type hndlrDisableConqueredVillages struct {
|
|||
|
||||
var _ commandHandler = &hndlrDisableConqueredVillages{}
|
||||
|
||||
func (hndlr *hndlrDisableConqueredVillages) cmd() Command {
|
||||
return DisableConqueredVillagesCommand
|
||||
func (hndlr *hndlrDisableConqueredVillages) cmd() command {
|
||||
return cmdDisableConqueredVillages
|
||||
}
|
||||
|
||||
func (hndlr *hndlrDisableConqueredVillages) requireAdmPermissions() bool {
|
||||
|
@ -285,7 +285,7 @@ func (hndlr *hndlrDisableConqueredVillages) execute(ctx *commandCtx, m *discordg
|
|||
MessageID: message.HelpDisableConqueredVillages,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": hndlr.cmd().WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
@ -337,8 +337,8 @@ type hndlrLostVillages struct {
|
|||
|
||||
var _ commandHandler = &hndlrLostVillages{}
|
||||
|
||||
func (hndlr *hndlrLostVillages) cmd() Command {
|
||||
return LostVillagesCommand
|
||||
func (hndlr *hndlrLostVillages) cmd() command {
|
||||
return cmdLostVillages
|
||||
}
|
||||
|
||||
func (hndlr *hndlrLostVillages) requireAdmPermissions() bool {
|
||||
|
@ -353,7 +353,7 @@ func (hndlr *hndlrLostVillages) execute(ctx *commandCtx, m *discordgo.MessageCre
|
|||
MessageID: message.HelpLostVillages,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": hndlr.cmd().WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
@ -404,8 +404,8 @@ type hndlrDisableLostVillages struct {
|
|||
|
||||
var _ commandHandler = &hndlrDisableLostVillages{}
|
||||
|
||||
func (hndlr *hndlrDisableLostVillages) cmd() Command {
|
||||
return DisableLostVillagesCommand
|
||||
func (hndlr *hndlrDisableLostVillages) cmd() command {
|
||||
return cmdDisableLostVillages
|
||||
}
|
||||
|
||||
func (hndlr *hndlrDisableLostVillages) requireAdmPermissions() bool {
|
||||
|
@ -420,7 +420,7 @@ func (hndlr *hndlrDisableLostVillages) execute(ctx *commandCtx, m *discordgo.Mes
|
|||
MessageID: message.HelpDisableLostVillages,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": hndlr.cmd().WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
@ -473,8 +473,8 @@ type hndlrObserve struct {
|
|||
|
||||
var _ commandHandler = &hndlrObserve{}
|
||||
|
||||
func (hndlr *hndlrObserve) cmd() Command {
|
||||
return ObserveCommand
|
||||
func (hndlr *hndlrObserve) cmd() command {
|
||||
return cmdObserve
|
||||
}
|
||||
|
||||
func (hndlr *hndlrObserve) requireAdmPermissions() bool {
|
||||
|
@ -489,7 +489,7 @@ func (hndlr *hndlrObserve) execute(ctx *commandCtx, m *discordgo.MessageCreate,
|
|||
MessageID: message.HelpObserve,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": hndlr.cmd().WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
@ -610,8 +610,8 @@ type hndlrDeleteObservation struct {
|
|||
|
||||
var _ commandHandler = &hndlrDeleteObservation{}
|
||||
|
||||
func (hndlr *hndlrDeleteObservation) cmd() Command {
|
||||
return DeleteObservationCommand
|
||||
func (hndlr *hndlrDeleteObservation) cmd() command {
|
||||
return cmdDeleteObservation
|
||||
}
|
||||
|
||||
func (hndlr *hndlrDeleteObservation) requireAdmPermissions() bool {
|
||||
|
@ -626,8 +626,8 @@ func (hndlr *hndlrDeleteObservation) execute(ctx *commandCtx, m *discordgo.Messa
|
|||
MessageID: message.HelpDeleteObservation,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": hndlr.cmd().WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"ObservationsCommand": ObservationsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"ObservationsCommand": cmdObservations.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
@ -687,8 +687,8 @@ type hndlrObservations struct {
|
|||
|
||||
var _ commandHandler = &hndlrObservations{}
|
||||
|
||||
func (hndlr *hndlrObservations) cmd() Command {
|
||||
return ObservationsCommand
|
||||
func (hndlr *hndlrObservations) cmd() command {
|
||||
return cmdObservations
|
||||
}
|
||||
|
||||
func (hndlr *hndlrObservations) requireAdmPermissions() bool {
|
||||
|
@ -703,7 +703,7 @@ func (hndlr *hndlrObservations) execute(ctx *commandCtx, m *discordgo.MessageCre
|
|||
MessageID: message.HelpObservations,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": hndlr.cmd().WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
@ -823,8 +823,8 @@ type hndlrShowEnnobledBarbarians struct {
|
|||
|
||||
var _ commandHandler = &hndlrShowEnnobledBarbarians{}
|
||||
|
||||
func (hndlr *hndlrShowEnnobledBarbarians) cmd() Command {
|
||||
return ShowEnnobledBarbariansCommand
|
||||
func (hndlr *hndlrShowEnnobledBarbarians) cmd() command {
|
||||
return cmdShowEnnobledBarbarians
|
||||
}
|
||||
|
||||
func (hndlr *hndlrShowEnnobledBarbarians) requireAdmPermissions() bool {
|
||||
|
@ -838,8 +838,8 @@ func (hndlr *hndlrShowEnnobledBarbarians) execute(ctx *commandCtx, m *discordgo.
|
|||
m.Author.Mention()+" "+ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpShowEnnobledBarbs,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": ShowEnnobledBarbariansCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdShowEnnobledBarbarians.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
@ -906,8 +906,8 @@ type hndlrShowInternals struct {
|
|||
|
||||
var _ commandHandler = &hndlrShowInternals{}
|
||||
|
||||
func (hndlr *hndlrShowInternals) cmd() Command {
|
||||
return ShowInternalsCommand
|
||||
func (hndlr *hndlrShowInternals) cmd() command {
|
||||
return cmdShowInternals
|
||||
}
|
||||
|
||||
func (hndlr *hndlrShowInternals) requireAdmPermissions() bool {
|
||||
|
@ -922,7 +922,7 @@ func (hndlr *hndlrShowInternals) execute(ctx *commandCtx, m *discordgo.MessageCr
|
|||
MessageID: message.HelpShowInternals,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": hndlr.cmd().WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}))
|
||||
return
|
||||
|
|
|
@ -18,14 +18,14 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
HelpCommand Command = "help"
|
||||
TribeCommand Command = "tribe"
|
||||
TopODACommand Command = "topoda"
|
||||
TopODDCommand Command = "topodd"
|
||||
TopODSCommand Command = "topods"
|
||||
TopODCommand Command = "topod"
|
||||
TopPointsCommand Command = "toppoints"
|
||||
AuthorCommand Command = "author"
|
||||
cmdHelp command = "help"
|
||||
cmdTribe command = "tribe"
|
||||
cmdTopODA command = "topoda"
|
||||
cmdTopODD command = "topodd"
|
||||
cmdTopODS command = "topods"
|
||||
cmdTopOD command = "topod"
|
||||
cmdTopPoints command = "toppoints"
|
||||
cmdAuthor command = "author"
|
||||
)
|
||||
|
||||
type hndlrHelp struct {
|
||||
|
@ -34,8 +34,8 @@ type hndlrHelp struct {
|
|||
|
||||
var _ commandHandler = &hndlrHelp{}
|
||||
|
||||
func (hndlr *hndlrHelp) cmd() Command {
|
||||
return HelpCommand
|
||||
func (hndlr *hndlrHelp) cmd() command {
|
||||
return cmdHelp
|
||||
}
|
||||
|
||||
func (hndlr *hndlrHelp) requireAdmPermissions() bool {
|
||||
|
@ -54,37 +54,37 @@ func (hndlr *hndlrHelp) execute(ctx *commandCtx, m *discordgo.MessageCreate, arg
|
|||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpTribeTopODA,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": TribeCommand.WithPrefix(hndlr.cfg.CommandPrefix) + " " + TopODACommand.String(),
|
||||
"Command": cmdTribe.WithPrefix(hndlr.cfg.CommandPrefix) + " " + cmdTopODA.String(),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpTribeTopODD,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": TribeCommand.WithPrefix(hndlr.cfg.CommandPrefix) + " " + TopODDCommand.String(),
|
||||
"Command": cmdTribe.WithPrefix(hndlr.cfg.CommandPrefix) + " " + cmdTopODD.String(),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpTribeTopODS,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": TribeCommand.WithPrefix(hndlr.cfg.CommandPrefix) + " " + TopODSCommand.String(),
|
||||
"Command": cmdTribe.WithPrefix(hndlr.cfg.CommandPrefix) + " " + cmdTopODS.String(),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpTribeTopOD,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": TribeCommand.WithPrefix(hndlr.cfg.CommandPrefix) + " " + TopODCommand.String(),
|
||||
"Command": cmdTribe.WithPrefix(hndlr.cfg.CommandPrefix) + " " + cmdTopOD.String(),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpTribeTopPoints,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": TribeCommand.WithPrefix(hndlr.cfg.CommandPrefix) + " " + TopPointsCommand.String(),
|
||||
"Command": cmdTribe.WithPrefix(hndlr.cfg.CommandPrefix) + " " + cmdTopPoints.String(),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpAuthor,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": AuthorCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdAuthor.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
@ -103,63 +103,63 @@ func (hndlr *hndlrHelp) execute(ctx *commandCtx, m *discordgo.MessageCreate, arg
|
|||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpAddGroup,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": AddGroupCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdAddGroup.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpGroups,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpDeleteGroup,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": DeleteGroupCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdDeleteGroup.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpShowEnnobledBarbs,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": ShowEnnobledBarbariansCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdShowEnnobledBarbarians.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpObserve,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": ObserveCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdObserve.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpGroups,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": ObservationsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdObservations.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpDeleteObservation,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": DeleteObservationCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"ObservationsCommand": ObservationsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdDeleteObservation.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"ObservationsCommand": cmdObservations.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpConqueredVillages,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": ConqueredVillagesCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdConqueredVillages.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpDisableConqueredVillages,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": DisableConqueredVillagesCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdDisableConqueredVillages.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
@ -175,41 +175,41 @@ func (hndlr *hndlrHelp) execute(ctx *commandCtx, m *discordgo.MessageCreate, arg
|
|||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpLostVillages,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": LostVillagesCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdLostVillages.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpDisableLostVillages,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": DisableLostVillagesCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdDisableLostVillages.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpShowInternals,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": ShowInternalsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": GroupsCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdShowInternals.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"GroupsCommand": cmdGroups.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpChangageLanguage,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": ChangeLanguageCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdChangeLanguage.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Languages": getAvailableLanguages(),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpCoordsTranslation,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": CoordsTranslationCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdCoordsTranslation.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.HelpDisableCoordsTranslation,
|
||||
TemplateData: map[string]interface{}{
|
||||
"Command": DisableCoordsTranslationCommand.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
"Command": cmdDisableCoordsTranslation.WithPrefix(hndlr.cfg.CommandPrefix),
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
@ -239,8 +239,8 @@ type hndlrAuthor struct {
|
|||
|
||||
var _ commandHandler = &hndlrAuthor{}
|
||||
|
||||
func (hndlr *hndlrAuthor) cmd() Command {
|
||||
return AuthorCommand
|
||||
func (hndlr *hndlrAuthor) cmd() command {
|
||||
return cmdAuthor
|
||||
}
|
||||
|
||||
func (hndlr *hndlrAuthor) requireAdmPermissions() bool {
|
||||
|
@ -259,8 +259,8 @@ type hndlrTribe struct {
|
|||
|
||||
var _ commandHandler = &hndlrTribe{}
|
||||
|
||||
func (hndlr *hndlrTribe) cmd() Command {
|
||||
return TribeCommand
|
||||
func (hndlr *hndlrTribe) cmd() command {
|
||||
return cmdTribe
|
||||
}
|
||||
|
||||
func (hndlr *hndlrTribe) requireAdmPermissions() bool {
|
||||
|
@ -273,7 +273,7 @@ func (hndlr *hndlrTribe) execute(ctx *commandCtx, m *discordgo.MessageCreate, ar
|
|||
return
|
||||
}
|
||||
|
||||
command := Command(args[0])
|
||||
command := command(args[0])
|
||||
server := args[1]
|
||||
page, err := strconv.Atoi(args[2])
|
||||
if err != nil || page <= 0 {
|
||||
|
@ -324,31 +324,31 @@ func (hndlr *hndlrTribe) execute(ctx *commandCtx, m *discordgo.MessageCreate, ar
|
|||
title := ""
|
||||
sort := ""
|
||||
switch command {
|
||||
case TopODACommand:
|
||||
case cmdTopODA:
|
||||
filter.RankAttGTE = 1
|
||||
sort = "rankAtt ASC"
|
||||
title = ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.TribeTitleOrderedByODA,
|
||||
})
|
||||
case TopODDCommand:
|
||||
case cmdTopODD:
|
||||
filter.RankDefGTE = 1
|
||||
sort = "rankDef ASC"
|
||||
title = ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.TribeTitleOrderedByODD,
|
||||
})
|
||||
case TopODSCommand:
|
||||
case cmdTopODS:
|
||||
filter.RankSupGTE = 1
|
||||
sort = "rankSup ASC"
|
||||
title = ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.TribeTitleOrderedByODS,
|
||||
})
|
||||
case TopODCommand:
|
||||
case cmdTopOD:
|
||||
filter.RankTotalGTE = 1
|
||||
sort = "rankTotal ASC"
|
||||
title = ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.TribeTitleOrderedByOD,
|
||||
})
|
||||
case TopPointsCommand:
|
||||
case cmdTopPoints:
|
||||
sort = "rank ASC"
|
||||
title = ctx.localizer.MustLocalize(&i18n.LocalizeConfig{
|
||||
MessageID: message.TribeTitleOrderedByPoints,
|
||||
|
@ -419,19 +419,19 @@ func (hndlr *hndlrTribe) execute(ctx *commandCtx, m *discordgo.MessageCreate, ar
|
|||
rank := 0
|
||||
score := 0
|
||||
switch command {
|
||||
case TopODACommand:
|
||||
case cmdTopODA:
|
||||
rank = player.RankAtt
|
||||
score = player.ScoreAtt
|
||||
case TopODDCommand:
|
||||
case cmdTopODD:
|
||||
rank = player.RankDef
|
||||
score = player.ScoreDef
|
||||
case TopODSCommand:
|
||||
case cmdTopODS:
|
||||
rank = player.RankSup
|
||||
score = player.ScoreSup
|
||||
case TopODCommand:
|
||||
case cmdTopOD:
|
||||
rank = player.RankTotal
|
||||
score = player.ScoreTotal
|
||||
case TopPointsCommand:
|
||||
case cmdTopPoints:
|
||||
rank = player.Rank
|
||||
score = player.Points
|
||||
}
|
||||
|
|
|
@ -157,10 +157,7 @@ func (s *Session) handleNewMessage(_ *discordgo.Session, m *discordgo.MessageCre
|
|||
|
||||
h := s.handlers.find(s.cfg.CommandPrefix, parts[0])
|
||||
if h != nil {
|
||||
if h.requireAdmPermissions() {
|
||||
if m.GuildID == "" {
|
||||
return
|
||||
}
|
||||
if h.requireAdmPermissions() && m.GuildID != "" {
|
||||
has, err := s.memberHasPermission(m.GuildID, m.Author.ID, discordgo.PermissionAdministrator)
|
||||
if err != nil || !has {
|
||||
return
|
||||
|
|
Reference in New Issue