aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moderation
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-14 22:51:48 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-14 22:51:48 -0400
commitd055e0dbb86ef7fd4ee96a1531b51181e825fb4b (patch)
treee2ed9e956f2d8167e7f225383f9917e66d2a2803 /src/commands/moderation
parent335f7c30994fc8c4e787f407dfd4c2de63b400e3 (diff)
downloadtanzanite-d055e0dbb86ef7fd4ee96a1531b51181e825fb4b.tar.gz
tanzanite-d055e0dbb86ef7fd4ee96a1531b51181e825fb4b.tar.bz2
tanzanite-d055e0dbb86ef7fd4ee96a1531b51181e825fb4b.zip
made a few changes
Diffstat (limited to 'src/commands/moderation')
-rw-r--r--src/commands/moderation/ban.ts16
-rw-r--r--src/commands/moderation/kick.ts12
-rw-r--r--src/commands/moderation/modlog.ts79
-rw-r--r--src/commands/moderation/role.ts52
4 files changed, 79 insertions, 80 deletions
diff --git a/src/commands/moderation/ban.ts b/src/commands/moderation/ban.ts
index 0d57203..f843ac4 100644
--- a/src/commands/moderation/ban.ts
+++ b/src/commands/moderation/ban.ts
@@ -1,12 +1,10 @@
-import { User } from 'discord.js';
-import { Guild } from '../../lib/models';
-import { BushCommand } from '../../lib/extensions/BushCommand';
-import { Ban, Modlog, ModlogType } from '../../lib/models';
+import { ApplicationCommandOptionType } from 'discord-api-types';
+import { CommandInteraction, Message, User } from 'discord.js';
import moment from 'moment';
-import { Message } from 'discord.js';
-import { CommandInteraction } from 'discord.js';
+import { BushCommand } from '../../lib/extensions/BushCommand';
+import { BushInteractionMessage } from '../../lib/extensions/BushInteractionMessage';
import { SlashCommandOption } from '../../lib/extensions/Util';
-import { ApplicationCommandOptionType } from 'discord-api-types';
+import { Ban, Guild, Modlog, ModlogType } from '../../lib/models';
const durationAliases: Record<string, string[]> = {
weeks: ['w', 'weeks', 'week', 'wk', 'wks'],
@@ -170,7 +168,7 @@ export default class BanCommand extends BushCommand {
}
async execSlash(
- message: CommandInteraction,
+ message: BushInteractionMessage,
{
user,
reason,
@@ -181,7 +179,7 @@ export default class BanCommand extends BushCommand {
time: SlashCommandOption<string>;
}
): Promise<void> {
- for await (const response of this.genResponses(message, user.user, reason?.value, time?.value)) {
+ for await (const response of this.genResponses(message.interaction, user.user, reason?.value, time?.value)) {
await message.reply(response);
}
}
diff --git a/src/commands/moderation/kick.ts b/src/commands/moderation/kick.ts
index c5581f6..eed0122 100644
--- a/src/commands/moderation/kick.ts
+++ b/src/commands/moderation/kick.ts
@@ -1,8 +1,8 @@
+import { ApplicationCommandOptionType } from 'discord-api-types';
+import { CommandInteraction, GuildMember, Message } from 'discord.js';
import { BushCommand } from '../../lib/extensions/BushCommand';
+import { BushInteractionMessage } from '../../lib/extensions/BushInteractionMessage';
import { Guild, Modlog, ModlogType } from '../../lib/models';
-import { GuildMember, Message } from 'discord.js';
-import { ApplicationCommandOptionType } from 'discord-api-types';
-import { CommandInteraction } from 'discord.js';
export default class KickCommand extends BushCommand {
constructor() {
@@ -100,9 +100,9 @@ export default class KickCommand extends BushCommand {
}
}
- async execSlash(message: CommandInteraction, { user, reason }: { user: GuildMember; reason?: string }): Promise<void> {
- for await (const response of this.genResponses(message, user, reason)) {
- await message.reply(response);
+ async execSlash(message: BushInteractionMessage, { user, reason }: { user: GuildMember; reason?: string }): Promise<void> {
+ for await (const response of this.genResponses(message.interaction, user, reason)) {
+ await message.interaction.reply(response);
}
}
}
diff --git a/src/commands/moderation/modlog.ts b/src/commands/moderation/modlog.ts
index 806c00a..862a26d 100644
--- a/src/commands/moderation/modlog.ts
+++ b/src/commands/moderation/modlog.ts
@@ -1,10 +1,9 @@
-import { BushCommand } from '../../lib/extensions/BushCommand';
-import { Message } from 'discord.js';
-import { Modlog } from '../../lib/models';
-import { MessageEmbed } from 'discord.js';
-import moment from 'moment';
import { stripIndent } from 'common-tags';
import { Argument } from 'discord-akairo';
+import { Message, MessageEmbed } from 'discord.js';
+import moment from 'moment';
+import { BushCommand } from '../../lib/extensions/BushCommand';
+import { Modlog } from '../../lib/models';
export default class ModlogCommand extends BushCommand {
constructor() {
@@ -87,10 +86,10 @@ export default class ModlogCommand extends BushCommand {
})
);
if (page) {
- await message.util.send(embedPages[page - 1]);
+ await message.util.send({ embeds: [embedPages[page - 1]] });
return;
} else {
- await message.util.send(embedPages[0]);
+ await message.util.send({ embeds: [embedPages[0]] });
return;
}
} else if (search) {
@@ -99,38 +98,40 @@ export default class ModlogCommand extends BushCommand {
await message.util.send('That modlog does not exist.');
return;
}
- await message.util.send(
- new MessageEmbed({
- title: `Modlog ${entry.id}`,
- fields: [
- {
- name: 'Type',
- value: entry.type.toLowerCase(),
- inline: true
- },
- {
- name: 'Duration',
- value: `${entry.duration ? moment.duration(entry.duration, 'milliseconds').humanize() : 'N/A'}`,
- inline: true
- },
- {
- name: 'Reason',
- value: `${entry.reason || 'None given'}`,
- inline: true
- },
- {
- name: 'Moderator',
- value: `<@!${entry.moderator}> (${entry.moderator})`,
- inline: true
- },
- {
- name: 'User',
- value: `<@!${entry.user}> (${entry.user})`,
- inline: true
- }
- ]
- })
- );
+ await message.util.send({
+ embeds: [
+ new MessageEmbed({
+ title: `Modlog ${entry.id}`,
+ fields: [
+ {
+ name: 'Type',
+ value: entry.type.toLowerCase(),
+ inline: true
+ },
+ {
+ name: 'Duration',
+ value: `${entry.duration ? moment.duration(entry.duration, 'milliseconds').humanize() : 'N/A'}`,
+ inline: true
+ },
+ {
+ name: 'Reason',
+ value: `${entry.reason || 'None given'}`,
+ inline: true
+ },
+ {
+ name: 'Moderator',
+ value: `<@!${entry.moderator}> (${entry.moderator})`,
+ inline: true
+ },
+ {
+ name: 'User',
+ value: `<@!${entry.user}> (${entry.user})`,
+ inline: true
+ }
+ ]
+ })
+ ]
+ });
}
}
}
diff --git a/src/commands/moderation/role.ts b/src/commands/moderation/role.ts
index b01d578..8951560 100644
--- a/src/commands/moderation/role.ts
+++ b/src/commands/moderation/role.ts
@@ -1,8 +1,8 @@
/* eslint-disable @typescript-eslint/no-empty-function */
+import { ApplicationCommandOptionType } from 'discord-api-types';
+import { GuildMember, Message, Role } from 'discord.js';
import { BushCommand } from '../../lib/extensions/BushCommand';
import AllowedMentions from '../../lib/utils/AllowedMentions';
-import { Message, Role, GuildMember } from 'discord.js';
-import { ApplicationCommandOptionType } from 'discord-api-types';
export default class RoleCommand extends BushCommand {
private roleWhitelist: Record<string, string[]> = {
@@ -77,43 +77,39 @@ export default class RoleCommand extends BushCommand {
if (!message.member.permissions.has('MANAGE_ROLES') && !this.client.ownerID.includes(message.author.id)) {
const mappedRole = this.client.util.moulberryBushRoleMap.find((m) => m.id === role.id);
if (!mappedRole || !this.roleWhitelist[mappedRole.name]) {
- return message.util.reply(
- `<:error:837123021016924261> <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`,
- {
- allowedMentions: AllowedMentions.none()
- }
- );
+ return message.util.reply({
+ content: `<:error:837123021016924261> <@&${role.id}> is not whitelisted, and you do not have manage roles permission.`,
+ allowedMentions: AllowedMentions.none()
+ });
}
const allowedRoles = this.roleWhitelist[mappedRole.name].map((r) => {
return this.client.util.moulberryBushRoleMap.find((m) => m.name === r).id;
});
if (!message.member.roles.cache.some((role) => allowedRoles.includes(role.id))) {
- return message.util.reply(
- `<:error:837123021016924261> <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`,
- {
- allowedMentions: AllowedMentions.none()
- }
- );
+ return message.util.reply({
+ content: `<:error:837123021016924261> <@&${role.id}> is whitelisted, but you do not have any of the roles required to manage it.`,
+ allowedMentions: AllowedMentions.none()
+ });
}
}
if (!this.client.ownerID.includes(message.author.id)) {
if (role.comparePositionTo(message.member.roles.highest) >= 0) {
- return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is higher or equal to your highest role.`, {
+ return message.util.reply({
+ content: `<:error:837123021016924261> <@&${role.id}> is higher or equal to your highest role.`,
allowedMentions: AllowedMentions.none()
});
}
if (role.comparePositionTo(message.guild.me.roles.highest) >= 0) {
- return message.util.reply(`<:error:837123021016924261> <@&${role.id}> is higher or equal to my highest role.`, {
+ return message.util.reply({
+ content: `<:error:837123021016924261> <@&${role.id}> is higher or equal to my highest role.`,
allowedMentions: AllowedMentions.none()
});
}
if (role.managed) {
- await message.util.reply(
- `<:error:837123021016924261> <@&${role.id}> is managed by an integration and cannot be managed.`,
- {
- allowedMentions: AllowedMentions.none()
- }
- );
+ await message.util.reply({
+ content: `<:error:837123021016924261> <@&${role.id}> is managed by an integration and cannot be managed.`,
+ allowedMentions: AllowedMentions.none()
+ });
}
}
// No checks if the user has MANAGE_ROLES
@@ -121,22 +117,26 @@ export default class RoleCommand extends BushCommand {
try {
await user.roles.remove(role.id);
} catch {
- return message.util.reply(`<:error:837123021016924261> Could not remove <@&${role.id}> from <@${user.id}>.`, {
+ return message.util.reply({
+ content: `<:error:837123021016924261> Could not remove <@&${role.id}> from <@${user.id}>.`,
allowedMentions: AllowedMentions.none()
});
}
- return message.util.reply(`<:checkmark:837109864101707807> Successfully removed <@&${role.id}> from <@${user.id}>!`, {
+ return message.util.reply({
+ content: `<:checkmark:837109864101707807> Successfully removed <@&${role.id}> from <@${user.id}>!`,
allowedMentions: AllowedMentions.none()
});
} else {
try {
await user.roles.add(role.id);
} catch {
- return message.util.reply(`<:error:837123021016924261> Could not add <@&${role.id}> to <@${user.id}>.`, {
+ return message.util.reply({
+ content: `<:error:837123021016924261> Could not add <@&${role.id}> to <@${user.id}>.`,
allowedMentions: AllowedMentions.none()
});
}
- return message.util.reply(`<:checkmark:837109864101707807> Successfully added <@&${role.id}> to <@${user.id}>!`, {
+ return message.util.reply({
+ content: `<:checkmark:837109864101707807> Successfully added <@&${role.id}> to <@${user.id}>!`,
allowedMentions: AllowedMentions.none()
});
}