aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/admin/roleAll.ts3
-rw-r--r--src/commands/info/ping.ts41
-rw-r--r--src/commands/leveling/levelRoles.ts2
-rw-r--r--src/commands/leveling/setLevel.ts13
-rw-r--r--src/commands/leveling/setXp.ts11
-rw-r--r--src/commands/moulberry-bush/moulHammer.ts7
-rw-r--r--src/commands/moulberry-bush/rule.ts33
7 files changed, 51 insertions, 59 deletions
diff --git a/src/commands/admin/roleAll.ts b/src/commands/admin/roleAll.ts
index fdf153a..7cb7346 100644
--- a/src/commands/admin/roleAll.ts
+++ b/src/commands/admin/roleAll.ts
@@ -1,4 +1,5 @@
import { AllowedMentions, BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import assert from 'assert';
import { ApplicationCommandOptionType, PermissionFlagsBits, type GuildMember } from 'discord.js';
export default class RoleAllCommand extends BushCommand {
@@ -39,7 +40,7 @@ export default class RoleAllCommand extends BushCommand {
}
public override async exec(message: BushMessage | BushSlashMessage, args: { role: ArgType<'role'>; bots: ArgType<'boolean'> }) {
- if (!message.inGuild()) return await message.util.reply(`${util.emojis.error} This command can only be run in a server.`);
+ assert(message.inGuild());
if (!message.member!.permissions.has(PermissionFlagsBits.Administrator) && !message.member!.user.isOwner())
return await message.util.reply(`${util.emojis.error} You must have admin perms to use this command.`);
if (message.util.isSlashMessage(message)) await message.interaction.deferReply();
diff --git a/src/commands/info/ping.ts b/src/commands/info/ping.ts
index 086a77a..af0fa98 100644
--- a/src/commands/info/ping.ts
+++ b/src/commands/info/ping.ts
@@ -1,5 +1,5 @@
import { BushCommand, type BushMessage, type BushSlashMessage } from '#lib';
-import { EmbedBuilder, PermissionFlagsBits, type Message } from 'discord.js';
+import { EmbedBuilder, PermissionFlagsBits } from 'discord.js';
export default class PingCommand extends BushCommand {
public constructor() {
@@ -16,41 +16,32 @@ export default class PingCommand extends BushCommand {
}
public override async exec(message: BushMessage) {
- const sentMessage = (await message.util.send('Pong!')) as Message;
- const timestamp: number = message.editedTimestamp ? message.editedTimestamp : message.createdTimestamp;
- const botLatency = `${'```'}\n ${Math.round(sentMessage.createdTimestamp - timestamp)}ms ${'```'}`;
- const apiLatency = `${'```'}\n ${Math.round(message.client.ws.ping)}ms ${'```'}`;
- const embed = new EmbedBuilder()
- .setTitle('Pong! 🏓')
- .addFields([
- { name: 'Bot Latency', value: botLatency, inline: true },
- { name: 'API Latency', value: apiLatency, inline: true }
- ])
- .setFooter({ text: message.author.username, iconURL: message.author.displayAvatarURL() })
- .setColor(util.colors.default)
- .setTimestamp();
- await sentMessage.edit({
- content: null,
- embeds: [embed]
- });
+ const timestamp1 = message.editedTimestamp ? message.editedTimestamp : message.createdTimestamp;
+ const msg = await message.util.reply('Pong!');
+ const timestamp2 = msg.editedTimestamp ? msg.editedTimestamp : msg.createdTimestamp;
+ void this.command(message, timestamp2 - timestamp1);
}
public override async execSlash(message: BushSlashMessage) {
- const timestamp1 = message.interaction.createdTimestamp;
- await message.interaction.reply('Pong!');
- const timestamp2 = await message.interaction.fetchReply().then((m) => (m as Message).createdTimestamp);
- const botLatency = `${'```'}\n ${Math.round(timestamp2 - timestamp1)}ms ${'```'}`;
- const apiLatency = `${'```'}\n ${Math.round(client.ws.ping)}ms ${'```'}`;
+ const timestamp1 = message.createdTimestamp;
+ const msg = (await message.util.reply({ content: 'Pong!', fetchReply: true })) as BushMessage;
+ const timestamp2 = msg.editedTimestamp ? msg.editedTimestamp : msg.createdTimestamp;
+ void this.command(message, timestamp2 - timestamp1);
+ }
+
+ private command(message: BushMessage | BushSlashMessage, msgLatency: number) {
+ const botLatency = util.format.codeBlock(`${Math.round(msgLatency)}ms`);
+ const apiLatency = util.format.codeBlock(`${Math.round(message.client.ws.ping)}ms`);
const embed = new EmbedBuilder()
.setTitle('Pong! 🏓')
.addFields([
{ name: 'Bot Latency', value: botLatency, inline: true },
{ name: 'API Latency', value: apiLatency, inline: true }
])
- .setFooter({ text: message.interaction.user.username, iconURL: message.interaction.user.displayAvatarURL() })
+ .setFooter({ text: message.author.username, iconURL: message.author.displayAvatarURL() })
.setColor(util.colors.default)
.setTimestamp();
- await message.interaction.editReply({
+ return message.util.reply({
content: null,
embeds: [embed]
});
diff --git a/src/commands/leveling/levelRoles.ts b/src/commands/leveling/levelRoles.ts
index 6886337..9fe7dd0 100644
--- a/src/commands/leveling/levelRoles.ts
+++ b/src/commands/leveling/levelRoles.ts
@@ -49,7 +49,7 @@ export default class LevelRolesCommand extends BushCommand {
return await reply(`${util.emojis.error} This command can only be run in servers with the leveling feature enabled.`);
}
- if (args.level < 1) return await reply(`${util.emojis.error} You cannot set a level role less that 1.`);
+ if (args.level < 1) return await reply(`${util.emojis.error} You cannot set a level role less than **1**.`);
if (args.role) {
if (args.role.managed)
diff --git a/src/commands/leveling/setLevel.ts b/src/commands/leveling/setLevel.ts
index 30bbb72..ac7df57 100644
--- a/src/commands/leveling/setLevel.ts
+++ b/src/commands/leveling/setLevel.ts
@@ -45,18 +45,11 @@ export default class SetLevelCommand extends BushCommand {
if (isNaN(level) || !Number.isInteger(level))
return await message.util.reply(`${util.emojis.error} Provide a valid number to set the user's level to.`);
if (level > 6553 || level < 0)
- return await message.util.reply(`${util.emojis.error} You cannot set a level higher than **6553**.`);
+ return await message.util.reply(`${util.emojis.error} You cannot set a level higher than **6,553**.`);
const [levelEntry] = await Level.findOrBuild({
- where: {
- user: user.id,
- guild: message.guild.id
- },
- defaults: {
- user: user.id,
- guild: message.guild.id,
- xp: 0
- }
+ where: { user: user.id, guild: message.guild.id },
+ defaults: { user: user.id, guild: message.guild.id, xp: 0 }
});
await levelEntry.update({ xp: Level.convertLevelToXp(level), user: user.id, guild: message.guild.id });
return await message.util.send({
diff --git a/src/commands/leveling/setXp.ts b/src/commands/leveling/setXp.ts
index e26cdcc..1f7c981 100644
--- a/src/commands/leveling/setXp.ts
+++ b/src/commands/leveling/setXp.ts
@@ -50,17 +50,12 @@ export default class SetXpCommand extends BushCommand {
);
const [levelEntry] = await Level.findOrBuild({
- where: {
- user: user.id,
- guild: message.guild.id
- },
- defaults: {
- user: user.id,
- guild: message.guild.id
- }
+ where: { user: user.id, guild: message.guild.id },
+ defaults: { user: user.id, guild: message.guild.id }
});
await levelEntry.update({ xp: xp, user: user.id, guild: message.guild.id });
+
return await message.util.send({
content: `Successfully set <@${user.id}>'s xp to ${util.format.input(
levelEntry.xp.toLocaleString()
diff --git a/src/commands/moulberry-bush/moulHammer.ts b/src/commands/moulberry-bush/moulHammer.ts
index 7a5a91c..a5d2c27 100644
--- a/src/commands/moulberry-bush/moulHammer.ts
+++ b/src/commands/moulberry-bush/moulHammer.ts
@@ -1,4 +1,5 @@
import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib';
+import assert from 'assert';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
export default class MoulHammerCommand extends BushCommand {
@@ -20,6 +21,7 @@ export default class MoulHammerCommand extends BushCommand {
}
],
slash: true,
+ channel: 'guild',
slashGuilds: ['516977525906341928'],
restrictedGuilds: ['516977525906341928'],
clientPermissions: (m) => util.clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true),
@@ -28,7 +30,10 @@ export default class MoulHammerCommand extends BushCommand {
}
public override async exec(message: BushMessage | BushSlashMessage, { user }: { user: ArgType<'user'> }) {
- await message.delete();
+ assert(message.inGuild());
+
+ if (message.channel.permissionsFor(message.guild.members.me!).has('ManageMessages')) await message.delete().catch(() => {});
+
const embed = new EmbedBuilder()
.setTitle('L')
.setDescription(`${user.username} got moul'ed <:wideberry1:756223352598691942><:wideberry2:756223336832303154>`)
diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts
index df6ba88..cd9994f 100644
--- a/src/commands/moulberry-bush/rule.ts
+++ b/src/commands/moulberry-bush/rule.ts
@@ -1,21 +1,25 @@
import { AllowedMentions, BushCommand, BushSlashMessage, type BushMessage, type OptArgType } from '#lib';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
+import { stripIndent } from '../../lib/common/tags.js';
const rules = [
{
title: "1.) Follow Discord's TOS",
- description:
- "Be sure to follow discord's TOS found at <https://discordapp.com/tos>, you must be 13 to use discord so if you admit to being under 13 you will be banned from the server."
+ description: stripIndent`
+ Be sure to follow discord's TOS found at <https://discordapp.com/tos>,\
+ you must be 13 to use discord so if you admit to being under 13 you will be banned from the server.`
},
{
title: '2.) Be Respectful',
- description:
- 'Racist, sexist, homophobic, xenophobic, transphobic, ableist, hate speech, slurs, or any other derogatory, toxic, or discriminatory behavior will not be tolerated.'
+ description: stripIndent`
+ Racist, sexist, homophobic, xenophobic, transphobic, ableist, hate speech, slurs, or any other derogatory, \
+ toxic, or discriminatory behavior will not be tolerated.`
},
{
title: '3.) No Spamming',
- description:
- 'Including but not limited to: any messages that do not contribute to the conversation, repeated messages, linebreaking, randomly tagging users, and chat flood.'
+ description: stripIndent`
+ Including but not limited to: any messages that do not contribute to the conversation, repeated messages, \
+ linebreaking, randomly tagging users, and chat flood.`
},
{
title: '4.) English',
@@ -23,8 +27,9 @@ const rules = [
},
{
title: '5.) Safe for Work',
- description:
- 'Please keep NSFW and NSFL content out of this server, avoid borderline images as well as keeping your status, profile picture, and banner SFW.'
+ description: stripIndent`
+ Please keep NSFW and NSFL content out of this server, avoid borderline images as well as keeping your status, \
+ profile picture, and banner SFW.`
},
{
title: '6.) No Advertising',
@@ -32,13 +37,14 @@ const rules = [
},
{
title: '7.) Impersonation',
- description: 'Do not try to impersonate others for the express intent of being deceitful, defamation , and/or personal gain.'
+ description: 'Do not try to impersonate others for the express intent of being deceitful, defamation, and/or personal gain.'
},
{ title: '8.) Swearing', description: 'Swearing is allowed only when not used as an insult.' },
{
title: "9.) Sending media that are able to crash a user's Discord",
- description:
- "Sending videos, GIFs, emojis, etc. that are able to crash someone's discord will result in a **permanent** ban that cannot be appealed."
+ description: stripIndent`
+ Sending videos, GIFs, emojis, etc. that are able to crash someone's discord will result in a \
+ **permanent** ban that cannot be appealed.`
},
{
title: '10.) No Backseat Moderating',
@@ -46,8 +52,9 @@ const rules = [
},
{
title: '11.) Staff may moderate at their discretion',
- description:
- 'If there are loopholes in our rules, the staff team may moderate based on what they deem appropriate. The staff team holds final discretion.'
+ description: stripIndent`
+ If there are loopholes in our rules, the staff team may moderate based on what they deem appropriate. \
+ The staff team holds final discretion.`
}
];