Skip to content

Commit d72ad66

Browse files
committed
fix automod buttons
1 parent c253ea0 commit d72ad66

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

dbot/commands/report.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ func CreateReport(b *dbot.Bot, settings model.GuildSetting, reportID int32, cont
103103
discord.ButtonComponent{
104104
Style: discord.ButtonStyleSuccess,
105105
Label: "Confirm",
106-
CustomID: fmt.Sprintf("cmd:report:confirm:%d", reportID),
106+
CustomID: fmt.Sprintf("handler:report-confirm:%d", reportID),
107107
},
108108
discord.ButtonComponent{
109109
Style: discord.ButtonStyleDanger,
110110
Label: "Delete",
111-
CustomID: fmt.Sprintf("cmd:report:delete:%d", reportID),
111+
CustomID: fmt.Sprintf("handler:report-delete:%d", reportID),
112112
},
113113
},
114114
},

dbot/commands/report_components.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,36 @@ import (
1818

1919
func ReportAction(b *dbot.Bot) handler.Component {
2020
return handler.Component{
21-
Name: "action",
21+
Name: "report-action",
2222
Handler: reportActionHandler(b),
2323
}
2424
}
2525

2626
func ReportConfirm(b *dbot.Bot) handler.Component {
2727
return handler.Component{
28-
Name: "confirm",
28+
Name: "report-confirm",
2929
Handler: reportConfirmHandler(b),
3030
}
3131
}
3232

3333
func ReportDelete(b *dbot.Bot) handler.Component {
3434
return handler.Component{
35-
Name: "delete",
35+
Name: "report-delete",
3636
Handler: reportDeleteHandler(b),
3737
}
3838
}
3939

4040
func ReportActionConfirm(b *dbot.Bot) handler.Modal {
4141
return handler.Modal{
42-
Name: "action-confirm",
42+
Name: "report-action-confirm",
4343
Handler: reportActionConfirmHandler(b),
4444
}
4545
}
4646

4747
func reportConfirmHandler(b *dbot.Bot) handler.ComponentHandler {
4848
return func(e *events.ComponentInteractionCreate) error {
4949
args := strings.Split(e.Data.CustomID(), ":")
50-
reportID, err := parseReportID(args[0])
50+
reportID, err := parseReportID(args[2])
5151
if err != nil {
5252
return err
5353
}
@@ -131,7 +131,7 @@ func reportConfirmHandler(b *dbot.Bot) handler.ComponentHandler {
131131
Components: &[]discord.ContainerComponent{
132132
discord.ActionRowComponent{
133133
discord.SelectMenuComponent{
134-
CustomID: fmt.Sprintf("cmd:report:action:%d", reportID),
134+
CustomID: fmt.Sprintf("handler:report-action:%d", reportID),
135135
Placeholder: "Select an action",
136136
MinValues: json.NewPtr(1),
137137
MaxValues: 1,
@@ -146,7 +146,7 @@ func reportConfirmHandler(b *dbot.Bot) handler.ComponentHandler {
146146
func reportDeleteHandler(b *dbot.Bot) handler.ComponentHandler {
147147
return func(e *events.ComponentInteractionCreate) error {
148148
args := strings.Split(e.Data.CustomID(), ":")
149-
reportID, err := parseReportID(args[0])
149+
reportID, err := parseReportID(args[2])
150150
if err != nil {
151151
return err
152152
}
@@ -181,7 +181,7 @@ func reportActionHandler(b *dbot.Bot) handler.ComponentHandler {
181181
return func(e *events.ComponentInteractionCreate) error {
182182

183183
args := strings.Split(e.Data.CustomID(), ":")
184-
reportID, err := parseReportID(args[0])
184+
reportID, err := parseReportID(args[2])
185185
if err != nil {
186186
return err
187187
}
@@ -252,7 +252,7 @@ func reportActionHandler(b *dbot.Bot) handler.ComponentHandler {
252252

253253
case "timeout":
254254
return e.CreateModal(discord.ModalCreate{
255-
CustomID: fmt.Sprintf("cmd:report:action-confirm:timeout:%s", report.UserID),
255+
CustomID: fmt.Sprintf("handler:report-action-confirm:timeout:%s", report.UserID),
256256
Title: "Timeout User",
257257
Components: []discord.ContainerComponent{
258258
discord.ActionRowComponent{
@@ -281,7 +281,7 @@ func reportActionHandler(b *dbot.Bot) handler.ComponentHandler {
281281

282282
case "kick":
283283
return e.CreateModal(discord.ModalCreate{
284-
CustomID: fmt.Sprintf("cmd:report:action-confirm:kick:%s", report.UserID),
284+
CustomID: fmt.Sprintf("handler:report-action-confirm:kick:%s", report.UserID),
285285
Title: "Kick User",
286286
Components: []discord.ContainerComponent{
287287
discord.ActionRowComponent{
@@ -299,7 +299,7 @@ func reportActionHandler(b *dbot.Bot) handler.ComponentHandler {
299299

300300
case "ban":
301301
return e.CreateModal(discord.ModalCreate{
302-
CustomID: fmt.Sprintf("cmd:report:action-confirm:ban:%s", report.UserID),
302+
CustomID: fmt.Sprintf("handler:report-action-confirm:ban:%s", report.UserID),
303303
Title: "Ban User",
304304
Components: []discord.ContainerComponent{
305305
discord.ActionRowComponent{
@@ -341,11 +341,11 @@ func reportActionHandler(b *dbot.Bot) handler.ComponentHandler {
341341
func reportActionConfirmHandler(b *dbot.Bot) handler.ModalHandler {
342342
return func(e *events.ModalSubmitInteractionCreate) error {
343343
args := strings.Split(e.Data.CustomID, ":")
344-
userID := snowflake.MustParse(args[1])
344+
userID := snowflake.MustParse(args[3])
345345
reason := e.Data.Text("reason")
346346

347347
var content string
348-
switch args[0] {
348+
switch args[2] {
349349
case "timeout":
350350
until := time.Now()
351351
duration, err := time.ParseDuration(e.Data.Text("duration"))

dbot/commands/settings.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ func Settings(b *dbot.Bot) handler.Command {
2828
Description: "Disables moderation",
2929
},
3030
{
31-
Name: "log-channel",
32-
Description: "Set the channel to log moderation actions",
31+
Name: "enable",
32+
Description: "Enables & sets the channel to log moderation actions to",
3333
Options: []discord.ApplicationCommandOption{
3434
discord.ApplicationCommandOptionChannel{
3535
Name: "channel",
@@ -44,8 +44,8 @@ func Settings(b *dbot.Bot) handler.Command {
4444
DefaultMemberPermissions: json.NewOptional(discord.PermissionManageServer),
4545
},
4646
CommandHandlers: map[string]handler.CommandHandler{
47-
"moderation/disable": settingsModerationDisableHandler(b),
48-
"moderation/log-channel": settingsModerationLogChannelHandler(b),
47+
"moderation/disable": settingsModerationDisableHandler(b),
48+
"moderation/enable": settingsModerationEnableHandler(b),
4949
},
5050
}
5151
}
@@ -67,7 +67,7 @@ func settingsModerationDisableHandler(b *dbot.Bot) handler.CommandHandler {
6767
}
6868
}
6969

70-
func settingsModerationLogChannelHandler(b *dbot.Bot) handler.CommandHandler {
70+
func settingsModerationEnableHandler(b *dbot.Bot) handler.CommandHandler {
7171
return func(e *events.ApplicationCommandInteractionCreate) error {
7272
data := e.SlashCommandInteractionData()
7373
settings, err := b.DB.GuildSettings().Get(*e.GuildID())

0 commit comments

Comments
 (0)