Skip to content

Commit b9f4aa4

Browse files
committed
rename keep option
1 parent 5cc55db commit b9f4aa4

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

services/spam-ban/__snapshots__/spam-banning.service.test.js.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ exports[`Banning spammer in other channels Asks for confirmation if not in autom
9090
{
9191
"components": [
9292
{
93-
"custom_id": "dontDeleteMessages",
93+
"custom_id": "keepMessages",
9494
"emoji": undefined,
9595
"label": "Don't delete messages",
9696
"style": 4,
@@ -116,7 +116,7 @@ exports[`Banning spammer in other channels Asks for confirmation if not in autom
116116
],
117117
"content": "Would you like to delete messages from the user being banned?",
118118
"ephemeral": true,
119-
"withReponse": true,
119+
"withResponse": true,
120120
}
121121
`;
122122

@@ -133,7 +133,7 @@ exports[`Banning spammer in other channels Bans user and deletes their messages
133133
{
134134
"components": [
135135
{
136-
"custom_id": "dontDeleteMessages",
136+
"custom_id": "keepMessages",
137137
"emoji": undefined,
138138
"label": "Don't delete messages",
139139
"style": 4,
@@ -159,7 +159,7 @@ exports[`Banning spammer in other channels Bans user and deletes their messages
159159
],
160160
"content": "Would you like to delete messages from the user being banned?",
161161
"ephemeral": true,
162-
"withReponse": true,
162+
"withResponse": true,
163163
}
164164
`;
165165

@@ -176,7 +176,7 @@ exports[`Banning spammer in other channels Bans user and does not delete their m
176176
{
177177
"components": [
178178
{
179-
"custom_id": "dontDeleteMessages",
179+
"custom_id": "keepMessages",
180180
"emoji": undefined,
181181
"label": "Don't delete messages",
182182
"style": 4,
@@ -202,7 +202,7 @@ exports[`Banning spammer in other channels Bans user and does not delete their m
202202
],
203203
"content": "Would you like to delete messages from the user being banned?",
204204
"ephemeral": true,
205-
"withReponse": true,
205+
"withResponse": true,
206206
}
207207
`;
208208

@@ -212,7 +212,7 @@ exports[`Banning spammer in other channels Cancels the action if the cancel butt
212212
{
213213
"components": [
214214
{
215-
"custom_id": "dontDeleteMessages",
215+
"custom_id": "keepMessages",
216216
"emoji": undefined,
217217
"label": "Don't delete messages",
218218
"style": 4,
@@ -238,7 +238,7 @@ exports[`Banning spammer in other channels Cancels the action if the cancel butt
238238
],
239239
"content": "Would you like to delete messages from the user being banned?",
240240
"ephemeral": true,
241-
"withReponse": true,
241+
"withResponse": true,
242242
}
243243
`;
244244

@@ -248,7 +248,7 @@ exports[`Banning spammer in other channels Cancels the action if the response ti
248248
{
249249
"components": [
250250
{
251-
"custom_id": "dontDeleteMessages",
251+
"custom_id": "keepMessages",
252252
"emoji": undefined,
253253
"label": "Don't delete messages",
254254
"style": 4,
@@ -274,7 +274,7 @@ exports[`Banning spammer in other channels Cancels the action if the response ti
274274
],
275275
"content": "Would you like to delete messages from the user being banned?",
276276
"ephemeral": true,
277-
"withReponse": true,
277+
"withResponse": true,
278278
}
279279
`;
280280

services/spam-ban/spam-banning.service.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class SpamBanningService {
8181
}
8282

8383
static async #AskForDeleteMessages(interaction) {
84-
const dontDeleteMessages = new ButtonBuilder()
85-
.setCustomId('dontDeleteMessages')
84+
const keepMessages = new ButtonBuilder()
85+
.setCustomId('keepMessages')
8686
.setLabel("Don't delete messages")
8787
.setStyle(ButtonStyle.Danger);
8888

@@ -97,7 +97,7 @@ class SpamBanningService {
9797
.setStyle(ButtonStyle.Secondary);
9898

9999
const row = new ActionRowBuilder().addComponents(
100-
dontDeleteMessages,
100+
keepMessages,
101101
deleteMessages,
102102
cancel,
103103
);
@@ -106,19 +106,14 @@ class SpamBanningService {
106106
content: 'Would you like to delete messages from the user being banned?',
107107
components: [row],
108108
ephemeral: true,
109-
withReponse: true,
109+
withResponse: true,
110110
});
111111

112112
try {
113113
const option = await response.awaitMessageComponent({ time: 60_000 });
114114

115-
if (option.customId === 'deleteMessages') {
116-
return { result: 'deleteMessages' };
117-
}
118-
if (option.customId === 'dontDeleteMessages') {
119-
return { result: 'dontDeleteMessages' };
120-
}
121-
return { result: 'cancel' };
115+
return { result: option.customId };
116+
122117
} catch {
123118
return { result: 'timeout' };
124119
}

services/spam-ban/spam-banning.service.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@ describe('Banning spammer in other channels', () => {
161161
});
162162

163163
it('Bans user and does not delete their messages if keep message button clicked', async () => {
164-
interactionMock.setMessageComponentReturn('dontDeleteMessages');
164+
interactionMock.setMessageComponentReturn('keepMessages');
165165
await SpamBanningService.handleInteraction(interactionMock);
166166
expect(interactionMock.guild.members.ban).toHaveBeenCalledTimes(1);
167167
expect(interactionMock.getBanArg()).toMatchSnapshot();
168168
expect(interactionMock.getReplyArg()).toMatchSnapshot();
169169
});
170170

171171
it('Still deletes the message that triggered the interaction', async () => {
172-
interactionMock.setMessageComponentReturn('dontDeleteMessages');
172+
interactionMock.setMessageComponentReturn('keepMessages');
173173
await SpamBanningService.handleInteraction(interactionMock);
174174
expect(interactionMock.message.delete).toHaveBeenCalledTimes(1);
175175
});

0 commit comments

Comments
 (0)