aboutsummaryrefslogtreecommitdiff
path: root/src/commands/moulberry-bush
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/moulberry-bush')
-rw-r--r--src/commands/moulberry-bush/capePerms.ts33
-rw-r--r--src/commands/moulberry-bush/level.ts8
-rw-r--r--src/commands/moulberry-bush/report.ts121
-rw-r--r--src/commands/moulberry-bush/rule.ts25
4 files changed, 140 insertions, 47 deletions
diff --git a/src/commands/moulberry-bush/capePerms.ts b/src/commands/moulberry-bush/capePerms.ts
index b19d3bc..08b42ff 100644
--- a/src/commands/moulberry-bush/capePerms.ts
+++ b/src/commands/moulberry-bush/capePerms.ts
@@ -4,34 +4,6 @@ import { MessageEmbed } from 'discord.js';
import got from 'got';
export default class CapePermissionsCommand extends BushCommand {
- private nameMap = {
- patreon1: 'Patreon Tier 1',
- patreon2: 'Patreon Tier 2',
- fade: 'Fade',
- contrib: 'Contributor',
- nullzee: 'Patreon Tier 1',
- gravy: 'Patreon Tier 1',
- space: 'Patreon Tier 1',
- mcworld: 'Patreon Tier 1',
- lava: 'Patreon Tier 1',
- packshq: 'Patreon Tier 1',
- mbstaff: 'Patreon Tier 1',
- thebakery: 'Patreon Tier 1',
- negative: 'Patreon Tier 1',
- void: 'Patreon Tier 1',
- ironmoon: 'Patreon Tier 1',
- krusty: 'Patreon Tier 1',
- furf: 'Patreon Tier 1',
- soldier: 'Patreon Tier 1',
- dsm: 'Patreon Tier 1',
- zera: 'Patreon Tier 1',
- tunnel: 'Patreon Tier 1',
- alexxoffi: 'Patreon Tier 1',
- parallax: 'Patreon Tier 1',
- jakethybro: 'Patreon Tier 1',
- planets: 'Patreon Tier 1'
- };
-
public constructor() {
super('capepermissions', {
aliases: ['capeperms', 'capeperm', 'capepermissions'],
@@ -80,7 +52,7 @@ export default class CapePermissionsCommand extends BushCommand {
let capeperms: Capeperms, uuid: string;
try {
- uuid = await this.client.util.mcUUID(args.ign);
+ uuid = await this.client.util.findUUID(args.ign);
} catch (e) {
return await message.util.reply(
`${this.client.util.emojis.error} \`${args.ign}\` doesn't appear to be a valid username.`
@@ -88,7 +60,7 @@ export default class CapePermissionsCommand extends BushCommand {
}
try {
- capeperms = await got.get('https://moulberry.codes/permscapes.json').json();
+ capeperms = await got.get('http://moulberry.codes/permscapes.json').json();
} catch (error) {
capeperms = null;
}
@@ -105,6 +77,7 @@ export default class CapePermissionsCommand extends BushCommand {
index = i;
break;
}
+ continue;
}
if (index == null)
return await message.util.reply(
diff --git a/src/commands/moulberry-bush/level.ts b/src/commands/moulberry-bush/level.ts
index fc1e93e..86ab985 100644
--- a/src/commands/moulberry-bush/level.ts
+++ b/src/commands/moulberry-bush/level.ts
@@ -1,4 +1,4 @@
-import { BushCommand, BushMessage, BushSlashMessage, BushUser, Level } from '@lib';
+import { BushCommand, BushGuild, BushMessage, BushSlashMessage, BushUser, Level } from '@lib';
/*
import canvas from 'canvas';
import { MessageAttachment } from 'discord.js';
@@ -127,8 +127,8 @@ export default class LevelCommand extends BushCommand {
return image.toBuffer();
} */
- private async getResponse(user: BushUser): Promise<string> {
- const userLevelRow = await Level.findByPk(user.id);
+ private async getResponse(user: BushUser, guild: BushGuild): Promise<string> {
+ const userLevelRow = await Level.findOne({ where: { user: user.id, guild: guild.id } });
if (userLevelRow) {
return `${user ? `${user.tag}'s` : 'Your'} level is ${userLevelRow.level} (${userLevelRow.xp} XP)`;
} else {
@@ -143,6 +143,6 @@ export default class LevelCommand extends BushCommand {
// 'lel.png'
// )
// );
- await message.reply(await this.getResponse(user || message.author));
+ await message.reply(await this.getResponse(user || message.author, message.guild));
}
}
diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts
new file mode 100644
index 0000000..ebc8f1d
--- /dev/null
+++ b/src/commands/moulberry-bush/report.ts
@@ -0,0 +1,121 @@
+import { Constants } from 'discord-akairo';
+import { GuildMember, MessageEmbed, TextChannel } from 'discord.js';
+import moment from 'moment';
+import { AllowedMentions, BushCommand, BushMessage } from '../../lib';
+
+export default class ReportCommand extends BushCommand {
+ public constructor() {
+ super('report', {
+ aliases: ['report'],
+ category: "Moulberry's Bush",
+ description: {
+ content: 'A command to report a user..',
+ usage: 'report <user> <reason/evidence>',
+ examples: ['report IRONM00N']
+ },
+ args: [
+ {
+ id: 'member',
+ type: Constants.ArgumentTypes.MEMBER,
+ match: Constants.ArgumentMatches.PHRASE,
+ prompt: {
+ start: 'Who would you like to report?',
+ retry: `{error} Choose a valid user to report.`,
+ optional: false
+ }
+ },
+ {
+ id: 'evidence',
+ type: Constants.ArgumentTypes.STRING,
+ match: Constants.ArgumentMatches.REST,
+ prompt: {
+ start: 'What evidence do you have?',
+ retry: `{error} Provide what did they do wrong.`,
+ optional: true
+ }
+ }
+ ],
+ clientPermissions: ['EMBED_LINKS', 'SEND_MESSAGES'],
+ channel: 'guild',
+ restrictedGuilds: ['516977525906341928'],
+ slash: true,
+ slashOptions: [
+ {
+ name: 'user',
+ description: 'The user you would like to report.',
+ type: 'USER',
+ required: true
+ },
+ {
+ name: 'evidence',
+ description: 'What did the user do wrong?',
+ type: 'STRING',
+ required: false
+ }
+ ],
+ slashGuilds: ['516977525906341928']
+ });
+ }
+
+ public async exec(message: BushMessage, { member, evidence }: { member: GuildMember; evidence: string }): Promise<unknown> {
+ if (message.guild.id != this.client.consts.mappings.guilds.bush)
+ return await message.util.reply(`${this.client.util.emojis.error} This command can only be run in Moulberry's bush.`);
+ if (!member) return await message.util.reply(`${this.client.util.emojis.error} Choose someone to report`);
+ if (member.user.id === '322862723090219008')
+ return await message.util.reply({
+ content: `Thank you for your report! We take these allegations very seriously and have reported <@${member.user.id}> to the FBI!`,
+ allowedMentions: AllowedMentions.none()
+ });
+ if (member.user.bot)
+ return await message.util.reply(
+ `${this.client.util.emojis.error} You cannot report a bot <:WeirdChamp:756283321301860382>.`
+ );
+
+ //// if (!evidence) evidence = 'No Evidence.';
+ //todo: Add channel id to db instead of hard coding it & allow in any guild
+ //The formatting of the report is mostly copied from carl since it is pretty good when it actually works
+ const reportEmbed = new MessageEmbed()
+ .setFooter(`Reporter ID: ${message.author.id} Reported ID: ${member.user.id}`)
+ .setTimestamp()
+ .setAuthor(`Report From: ${message.author.tag}`, message.author.avatarURL({ dynamic: true }))
+ .setTitle('New Report')
+ .setColor(this.client.util.colors.red)
+ .setDescription(evidence)
+ .addField(
+ 'Reporter',
+ `**Name:**${message.author.tag} <@${message.author.id}>\n**Joined:** ${moment(
+ message.member.joinedTimestamp
+ ).fromNow()}\n**Created:** ${moment(message.author.createdTimestamp).fromNow()}\n**Sent From**: <#${
+ message.channel.id
+ }> [Jump to context](${message.url})`,
+ true
+ )
+ .addField(
+ 'Reported User',
+ `**Name:**${member.user.tag} <@${member.user.id}>\n**Joined:** ${moment(
+ member.joinedTimestamp
+ ).fromNow()}\n**Created:** ${moment(member.user.createdTimestamp).fromNow()}`,
+ true
+ );
+
+ //reusing code pog
+ if (message.attachments.size > 0) {
+ const fileName = message.attachments.first().name.toLowerCase();
+ if (fileName.endsWith('.png') || fileName.endsWith('.jpg') || fileName.endsWith('.gif') || fileName.endsWith('.webp')) {
+ reportEmbed.setImage(message.attachments.first().url);
+ } else {
+ reportEmbed.addField('Attachment', message.attachments.first().url);
+ }
+ }
+ const reportChannel = <TextChannel>this.client.channels.cache.get('782972723654688848');
+ await reportChannel.send({ embeds: [reportEmbed] }).then(async (ReportMessage) => {
+ try {
+ await ReportMessage.react(this.client.util.emojis.success);
+ await ReportMessage.react(this.client.util.emojis.error);
+ } catch {
+ this.client.console.warn('ReportCommand', 'Could not react to report message.');
+ }
+ });
+ return await message.util.reply('Successfully made a report.');
+ }
+}
diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts
index a2b8c78..1681a1b 100644
--- a/src/commands/moulberry-bush/rule.ts
+++ b/src/commands/moulberry-bush/rule.ts
@@ -1,6 +1,6 @@
-import { AllowedMentions, BushCommand, BushMessage, BushSlashMessage } from '@lib';
import { Argument, Constants } from 'discord-akairo';
import { MessageEmbed, User } from 'discord.js';
+import { AllowedMentions, BushCommand, BushMessage } from '../../lib';
const rules = [
{
@@ -106,10 +106,7 @@ export default class RuleCommand extends BushCommand {
});
}
- public async exec(
- message: BushMessage | BushSlashMessage,
- { rule, user }: { rule: undefined | number; user: User }
- ): Promise<unknown> {
+ 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 }))
@@ -133,19 +130,21 @@ export default class RuleCommand extends BushCommand {
return;
async function respond(): Promise<unknown> {
if (!user) {
- // If the original message was a reply -> imitate it
- (message as BushMessage).reference?.messageId && !message.util.isSlash
- ? await message.channel.messages.fetch((message as BushMessage).reference.messageId).then(async (message) => {
- await message.util.reply({ embeds: [rulesEmbed], allowedMentions: AllowedMentions.users() });
- })
- : await message.util.send({ embeds: [rulesEmbed], allowedMentions: AllowedMentions.users() });
+ 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 as BushMessage).reference?.messageId && !message.util.isSlash
+ return message.reference?.messageId && !message.util.isSlash
? await message.util.send({
content: `<@!${user.id}>`,
embeds: [rulesEmbed],
allowedMentions: AllowedMentions.users(),
- reply: { messageReference: (message as BushMessage).reference.messageId }
+ reply: { messageReference: message.reference.messageId }
})
: await message.util.send({
content: `<@!${user.id}>`,