Compare commits
No commits in common. "b0407db9bbc7fee197a883cd862bca57e5db3a4b" and "4f2c1862443915f0dedb584d11d790d241fe887a" have entirely different histories.
b0407db9bb
...
4f2c186244
5 changed files with 1 additions and 50 deletions
|
@ -49,11 +49,6 @@ export default class Timeout extends Command {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (targetUser.user.bot) {
|
|
||||||
await interaction.reply('Cannot timeout bots.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// General Variables
|
// General Variables
|
||||||
const targetMember = targetUser.member as GuildMember;
|
const targetMember = targetUser.member as GuildMember;
|
||||||
const reason = reasonInput && reasonInput.value ? reasonInput.value.toString() : null;
|
const reason = reasonInput && reasonInput.value ? reasonInput.value.toString() : null;
|
||||||
|
|
|
@ -35,8 +35,4 @@ export default class StringTools {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReplaceAll(str: string, find: string, replace: string) {
|
|
||||||
return str.replace(new RegExp(find, 'g'), replace);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,10 +1,8 @@
|
||||||
import StringTools from "./StringTools";
|
|
||||||
|
|
||||||
export default class TimeLengthInput {
|
export default class TimeLengthInput {
|
||||||
public readonly value: string;
|
public readonly value: string;
|
||||||
|
|
||||||
constructor(input: string) {
|
constructor(input: string) {
|
||||||
this.value = StringTools.ReplaceAll(input, ',', '');
|
this.value = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetDays(): number {
|
public GetDays(): number {
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { CoreClient } from "./client/client";
|
||||||
import * as dotenv from "dotenv";
|
import * as dotenv from "dotenv";
|
||||||
import registry from "./registry";
|
import registry from "./registry";
|
||||||
import { IntentsBitField } from "discord.js";
|
import { IntentsBitField } from "discord.js";
|
||||||
import StringTools from "./helpers/StringTools";
|
|
||||||
|
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
|
|
|
@ -360,43 +360,6 @@ describe('execute', () => {
|
||||||
expect(interaction.reply).toBeCalledWith('Fields are required.');
|
expect(interaction.reply).toBeCalledWith('Fields are required.');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN targetUser is a bot, EXPECT error', async () => {
|
|
||||||
const interaction = {
|
|
||||||
reply: jest.fn(),
|
|
||||||
guild: mock<Guild>(),
|
|
||||||
guildId: 'guildId',
|
|
||||||
options: {
|
|
||||||
get: jest.fn((value: string): CommandInteractionOption<CacheType> | null => {
|
|
||||||
switch (value) {
|
|
||||||
case 'target':
|
|
||||||
return {
|
|
||||||
user: {
|
|
||||||
bot: true,
|
|
||||||
} as User,
|
|
||||||
member: {} as GuildMember
|
|
||||||
} as CommandInteractionOption;
|
|
||||||
case 'length':
|
|
||||||
return {
|
|
||||||
value: '1m',
|
|
||||||
} as CommandInteractionOption;
|
|
||||||
case 'reason':
|
|
||||||
return {
|
|
||||||
value: 'Test reason',
|
|
||||||
} as CommandInteractionOption;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
} as unknown as CommandInteraction;
|
|
||||||
|
|
||||||
const command = new Timeout();
|
|
||||||
|
|
||||||
await command.execute(interaction);
|
|
||||||
|
|
||||||
expect(interaction.reply).toBeCalledWith('Cannot timeout bots.');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('GIVEN targetMember IS NOT manageable by the bot, EXPECT insufficient permissions error', async () => {
|
test('GIVEN targetMember IS NOT manageable by the bot, EXPECT insufficient permissions error', async () => {
|
||||||
const command = new Timeout();
|
const command = new Timeout();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue