aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moulberry-bush/rule.ts
diff options
context:
space:
mode:
authorIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-24 00:56:16 -0400
committerIRONM00N <64110067+IRONM00N@users.noreply.github.com>2021-06-24 00:56:16 -0400
commit4176b6258e44e4a095376aaf0f4c687244243a69 (patch)
tree3b9144be9a2045483c90d92fff05b3ca0b288e52 /src/commands/moulberry-bush/rule.ts
parente80446e23060c0325bbd6db620920d86694ec3ce (diff)
downloadtanzanite-4176b6258e44e4a095376aaf0f4c687244243a69.tar.gz
tanzanite-4176b6258e44e4a095376aaf0f4c687244243a69.tar.bz2
tanzanite-4176b6258e44e4a095376aaf0f4c687244243a69.zip
feat(*): Began working on other punishment commands etc
Diffstat (limited to 'src/commands/moulberry-bush/rule.ts')
-rw-r--r--src/commands/moulberry-bush/rule.ts228
1 files changed, 107 insertions, 121 deletions
diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts
index e9b09eb..3cd9ec6 100644
--- a/src/commands/moulberry-bush/rule.ts
+++ b/src/commands/moulberry-bush/rule.ts
@@ -1,69 +1,60 @@
-import { Argument } from 'discord-akairo';
-import { CommandInteraction, Message, MessageEmbed, User } from 'discord.js';
-import { SlashCommandOption } from '../../lib/extensions/BushClientUtil';
+import { Argument, Constants } from 'discord-akairo';
+import { MessageEmbed, User } from 'discord.js';
import { BushCommand } from '../../lib/extensions/BushCommand';
-import { BushSlashMessage } from '../../lib/extensions/BushInteractionMessage';
+import { BushMessage } from '../../lib/extensions/BushMessage';
+import AllowedMentions from '../../lib/utils/AllowedMentions';
+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."
+ },
+ {
+ 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.'
+ },
+ {
+ title: '3.) No Spamming',
+ description:
+ 'Including but not limited to: any messages that do not contribute to the conversation, repeated messages, randomly tagging users, and chat flood.'
+ },
+ {
+ title: '4.) English',
+ description: 'The primary language of the server is English, please keep all discussions in English.'
+ },
+ {
+ 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.'
+ },
+ {
+ title: '6.) No Advertising',
+ description: 'Do not promote anything without prior approval from a staff member, this includes DM advertising.'
+ },
+ {
+ title: '7.) Impersonation',
+ 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."
+ },
+ {
+ title: '10.) No Backseat Moderating',
+ description: 'If you see a rule being broken be broken, please report it using: `-report <user> [evidence]`.'
+ },
+ {
+ 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.'
+ }
+];
export default class RuleCommand extends BushCommand {
- private rules = [
- {
- title: "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."
- },
- {
- title: 'Be Respectful',
- description:
- 'Racist, sexist, homophobic, xenophobic, transphobic, ableist, hate speech, slurs, or any other derogatory, toxic, or discriminatory behavior will not be tolerated.'
- },
- {
- title: 'No Spamming',
- description:
- 'Including but not limited to: any messages that do not contribute to the conversation, repeated messages, randomly tagging users, and chat flood.'
- },
- {
- title: 'English',
- description: 'The primary language of the server is English, please keep all discussions in English.'
- },
- {
- title: 'Safe for Work',
- description:
- 'Please keep NSFW and NSFL content out of this server, avoid borderline images as well as keeping your status and profile picture SFW.'
- },
- {
- title: 'No Advertising',
- description: 'Do not promote anything without prior approval from a staff member, this includes DM advertising.'
- },
- {
- title: 'Impersonation',
- description:
- 'Do not try to impersonate others for the express intent of being deceitful, defamation , and/or personal gain.'
- },
- {
- title: 'Swearing',
- description: 'Swearing is allowed only when not used as an insult.'
- },
- {
- title: 'Only ping @emergency in emergencies',
- description:
- 'Pinging <@&833802660209229854> for no reason will result in severe punishment. <@&833802660209229854> is only to be pinged in true emergencies.'
- },
- {
- title: 'No Backseat Moderating',
- description: 'If you see a rule being broken be broken, please report it using: `-report <user> [evidence]`.'
- },
- {
- title: '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.'
- },
- {
- title: "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** mute that cannot be appealed."
- }
- ];
-
public constructor() {
super('rule', {
aliases: ['rule', 'rules'],
@@ -76,98 +67,93 @@ export default class RuleCommand extends BushCommand {
args: [
{
id: 'rule',
- type: Argument.range('number', 1, 12, true),
+ type: Argument.range(Constants.ArgumentTypes.INTEGER, 1, rules.length, true),
+ match: Constants.ArgumentMatches.PHRASE,
prompt: {
start: 'What rule would you like to have cited?',
retry: '{error} Choose a valid rule.',
optional: true
- },
- default: undefined
+ }
},
{
id: 'user',
type: 'user',
+ match: Constants.ArgumentMatches.PHRASE,
prompt: {
start: 'What user would you like to mention?',
retry: '{error} Choose a valid user to mention.',
optional: true
- },
- default: undefined
+ }
}
],
clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'],
channel: 'guild',
+ restrictedGuilds: ['516977525906341928'],
+ slash: true,
slashOptions: [
{
- type: 'INTEGER',
name: 'rule',
- description: 'The rule to show',
+ description: 'The rule you would you like to have cited',
+ type: 'INTEGER',
required: false
},
{
- type: 'USER',
name: 'user',
- description: 'The user to ping',
+ description: 'The user you would like to mention.',
+ type: 'USER',
required: false
}
],
- slash: true
+ slashGuilds: ['516977525906341928']
});
}
- private getResponse(
- message: Message | CommandInteraction,
- rule?: number,
- user?: User
- ): { content?: string; embeds?: MessageEmbed[] } | [string, MessageEmbed] {
- if (
- message.guild.id !== '516977525906341928' &&
- !this.client.ownerID.includes(message instanceof Message ? message.author.id : message.user.id)
- ) {
- return { content: `${this.client.util.emojis.error} This command can only be run in Moulberry's Bush.` };
- }
- let rulesEmbed = new MessageEmbed().setColor('ef3929');
- if (message instanceof Message) {
- rulesEmbed = rulesEmbed.setFooter(`Triggered by ${message.author.tag}`, message.author.avatarURL({ dynamic: true }));
+
+ public async exec(message: BushMessage, { rule, user }: { rule: undefined | number; user: User }): Promise<unknown> {
+ const rulesEmbed = new MessageEmbed()
+ .setColor('ef3929')
+ .setFooter(`Triggered by ${message.author.tag}`, message.author.avatarURL({ dynamic: true }))
+ .setTimestamp();
+
+ if (rule > 12 || rule < 1) {
+ rule = undefined;
}
if (rule) {
- const foundRule = this.rules[rule - 1];
- rulesEmbed.addField(`${rule}) ${foundRule.title}`, foundRule.description);
+ if (rules[rule - 1]?.title && rules[rule - 1]?.description)
+ rulesEmbed.addField(rules[rule - 1].title, rules[rule - 1].description);
} else {
- for (const curRule of this.rules) {
- rulesEmbed.addField(`${this.rules.indexOf(curRule) + 1}) ${curRule.title}`, curRule.description);
+ for (let i = 0; i < rules.length; i++) {
+ if (rules[i]?.title && rules[i]?.description) rulesEmbed.addField(rules[i].title, rules[i].description);
}
}
- if (!user) {
- return { embeds: [rulesEmbed] };
- } else {
- return [`<@!${user.id}>`, rulesEmbed];
- }
- }
- public async exec(message: Message, { rule, user }: { rule?: number; user?: User }): Promise<void> {
- const response = this.getResponse(message, rule, user);
- if (Array.isArray(response)) {
- await message.util.send({
- content: response[0],
- embeds: [response[1]]
- });
- } else {
- await message.util.send(response);
+ await respond();
+ if (!message.util.isSlash) {
+ await message.delete().catch(() => {});
}
- await message.delete().catch(() => undefined);
- }
-
- public async execSlash(
- message: BushSlashMessage,
- { rule, user }: { rule?: SlashCommandOption<number>; user?: SlashCommandOption<void> }
- ): Promise<void> {
- const response = this.getResponse(message.interaction, rule?.value, user?.user);
- if (Array.isArray(response)) {
- await message.interaction.reply({
- content: response[0],
- embeds: [response[1]]
- });
- } else {
- await message.interaction.reply(response);
+ return;
+ async function respond(): Promise<unknown> {
+ if (!user) {
+ return (
+ // If the original message was a reply -> imitate it
+ message.reference?.messageID && !message.util.isSlash
+ ? await message.channel.messages.fetch(message.reference.messageID).then(async (message) => {
+ await message.util.reply({ embeds: [rulesEmbed], allowedMentions: AllowedMentions.users() });
+ })
+ : await message.util.send({ embeds: [rulesEmbed], allowedMentions: AllowedMentions.users() })
+ );
+ } else {
+ return message.reference?.messageID && !message.util.isSlash
+ ? await message.util.send({
+ content: `<@!${user.id}>`,
+ embeds: [rulesEmbed],
+ allowedMentions: AllowedMentions.users(),
+ reply: { messageReference: message.reference.messageID }
+ })
+ : await message.util.send({
+ content: `<@!${user.id}>`,
+ embeds: [rulesEmbed],
+ allowedMentions: AllowedMentions.users()
+ });
+ }
}
}
}