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/capes.ts2
-rw-r--r--src/commands/moulberry-bush/giveawayPing.ts8
-rw-r--r--src/commands/moulberry-bush/moulHammer.ts16
-rw-r--r--src/commands/moulberry-bush/neuRepo.ts193
-rw-r--r--src/commands/moulberry-bush/report.ts6
-rw-r--r--src/commands/moulberry-bush/rule.ts5
-rw-r--r--src/commands/moulberry-bush/serverStatus.ts2
-rw-r--r--src/commands/moulberry-bush/solved.ts44
8 files changed, 262 insertions, 14 deletions
diff --git a/src/commands/moulberry-bush/capes.ts b/src/commands/moulberry-bush/capes.ts
index 1db2f72..8693dba 100644
--- a/src/commands/moulberry-bush/capes.ts
+++ b/src/commands/moulberry-bush/capes.ts
@@ -12,7 +12,7 @@ import {
type OptArgType,
type SlashMessage
} from '#lib';
-import assert from 'assert';
+import assert from 'assert/strict';
import { ApplicationCommandOptionType, PermissionFlagsBits, type APIEmbed, type AutocompleteInteraction } from 'discord.js';
import Fuse from 'fuse.js';
import got from 'got';
diff --git a/src/commands/moulberry-bush/giveawayPing.ts b/src/commands/moulberry-bush/giveawayPing.ts
index d93e0c9..8f8941f 100644
--- a/src/commands/moulberry-bush/giveawayPing.ts
+++ b/src/commands/moulberry-bush/giveawayPing.ts
@@ -1,5 +1,5 @@
-import { AllowedMentions, BushCommand, clientSendAndPermCheck, emojis, type CommandMessage } from '#lib';
-import assert from 'assert';
+import { AllowedMentions, BushCommand, clientSendAndPermCheck, emojis, mappings, type CommandMessage } from '#lib';
+import assert from 'assert/strict';
import { PermissionFlagsBits } from 'discord.js';
export default class GiveawayPingCommand extends BushCommand {
@@ -24,8 +24,8 @@ export default class GiveawayPingCommand extends BushCommand {
cooldown: 1.44e7, //4 hours
ratelimit: 1,
editable: false,
- restrictedGuilds: ['516977525906341928'],
- restrictedChannels: ['767782084981817344', '833855738501267456']
+ restrictedGuilds: [mappings.guilds["Moulberry's Bush"]],
+ restrictedChannels: [mappings.channels['giveaways']]
});
}
diff --git a/src/commands/moulberry-bush/moulHammer.ts b/src/commands/moulberry-bush/moulHammer.ts
index 0eeb769..7bb514e 100644
--- a/src/commands/moulberry-bush/moulHammer.ts
+++ b/src/commands/moulberry-bush/moulHammer.ts
@@ -1,5 +1,13 @@
-import { BushCommand, clientSendAndPermCheck, colors, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
-import assert from 'assert';
+import {
+ BushCommand,
+ clientSendAndPermCheck,
+ colors,
+ mappings,
+ type ArgType,
+ type CommandMessage,
+ type SlashMessage
+} from '#lib';
+import assert from 'assert/strict';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
export default class MoulHammerCommand extends BushCommand {
@@ -22,8 +30,8 @@ export default class MoulHammerCommand extends BushCommand {
],
slash: true,
channel: 'guild',
- slashGuilds: ['516977525906341928'],
- restrictedGuilds: ['516977525906341928'],
+ slashGuilds: [mappings.guilds["Moulberry's Bush"]],
+ restrictedGuilds: [mappings.guilds["Moulberry's Bush"]],
clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true),
userPermissions: []
});
diff --git a/src/commands/moulberry-bush/neuRepo.ts b/src/commands/moulberry-bush/neuRepo.ts
new file mode 100644
index 0000000..d07ba53
--- /dev/null
+++ b/src/commands/moulberry-bush/neuRepo.ts
@@ -0,0 +1,193 @@
+import { BushCommand, clientSendAndPermCheck, type ArgType, type CommandMessage, type SlashMessage } from '#lib';
+import canvas from 'canvas';
+import {
+ ApplicationCommandOptionType,
+ AttachmentBuilder,
+ AutocompleteInteraction,
+ CacheType,
+ PermissionFlagsBits
+} from 'discord.js';
+import { dirname, join } from 'path';
+import tinycolor from 'tinycolor2';
+import { fileURLToPath } from 'url';
+import { formattingInfo, RawNeuItem } from '../../lib/common/util/Minecraft.js';
+
+export default class NeuRepoCommand extends BushCommand {
+ public static items: { name: string; id: string }[] = [];
+
+ public constructor() {
+ super('neuRepo', {
+ aliases: ['neu-repo', 'repo-item', 'neu-item', 'item-repo'],
+ category: "Moulberry's Bush",
+ description: 'Get information about an item from the NEU item repo.',
+ usage: ['neu-repo <item>'],
+ examples: ['neu-repo BARRIER'],
+ args: [
+ {
+ id: 'item',
+ description: 'The item id that you would like to find neu item information about.',
+ type: 'string',
+ prompt: 'What SkyBlock item would you like to get information about?',
+ retry: '{error} Pick a valid SkyBlock item ID. Try using the slash command for a better experience.',
+ slashType: ApplicationCommandOptionType.String,
+ autocomplete: true
+ }
+ /* {
+ id: 'dangerous',
+ description: 'Whether or not to use the dangerous branch.',
+ prompt: 'Would you like to use the dangerous branch instead of the master branch?',
+ match: 'flag',
+ flag: ['--dangerous', '-d'],
+ default: false,
+ optional: true,
+ slashType: ApplicationCommandOptionType.Boolean
+ } */
+ ],
+ slash: false,
+ clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true),
+ userPermissions: [],
+ ownerOnly: true,
+ hidden: true
+ });
+ }
+
+ public override async exec(
+ message: CommandMessage | SlashMessage,
+ args: { item: ArgType<'string'> /* dangerous: ArgType<'flag'> */ }
+ ) {
+ const itemPath = join(import.meta.url, '..', '..', '..', '..', '..', 'neu-item-repo-dangerous', 'items', `${args.item}.json`);
+ const item = (await import(itemPath, { assert: { type: 'json' } })).default as RawNeuItem;
+
+ const toolTip = this.toolTip(item);
+
+ return message.util.reply({
+ files: [new AttachmentBuilder(toolTip, { name: `${item.internalname}.png`, description: item.displayname })]
+ });
+ }
+
+ public toolTip(item: RawNeuItem): Buffer {
+ canvas.registerFont(join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..', '..', 'assets', 'Faithful.ttf'), {
+ family: 'Faithful'
+ });
+
+ const background = '#100010';
+
+ const width = 250;
+ const height = 250;
+ const scale = 10;
+
+ const itemRender = canvas.createCanvas(width, height),
+ ctx = itemRender.getContext('2d');
+
+ ctx.globalAlpha = 0.94;
+ ctx.fillStyle = background;
+
+ // top outside
+ ctx.fillRect(scale, 0, width - 2 * scale, scale);
+
+ // bottom outside
+ ctx.fillRect(scale, height - scale, width - 2 * scale, scale);
+
+ // left outside
+ ctx.fillRect(0, scale, scale, height - 2 * scale);
+
+ // right outside
+ ctx.fillRect(width - scale, scale, scale, height - 2 * scale);
+
+ // middle
+ ctx.fillRect(2 * scale, 2 * scale, width - 4 * scale, height - 4 * scale);
+
+ ctx.globalAlpha = 0.78;
+
+ const borderColorStart = parseInt(new tinycolor(this.getPrimaryColour(item.displayname)).toHex(), 16);
+ const borderColorEnd = ((borderColorStart & 0xfefefe) >> 1) | (borderColorStart & 0xff000000);
+
+ const borderColorStartStr = `#${borderColorStart.toString(16)}`;
+ const borderColorEndStr = `#${borderColorEnd.toString(16)}`;
+
+ ctx.fillStyle = borderColorStartStr;
+
+ // top highlight
+ ctx.fillRect(scale, scale, width - 2 * scale, scale);
+
+ // left highlight
+ ctx.fillRect(scale, 2 * scale, scale, height - 3 * scale);
+
+ // bottom highlight
+ {
+ const x = 2 * scale,
+ y = height - 2 * scale,
+ w = width - 3 * scale,
+ h = scale;
+ const gradient = ctx.createLinearGradient(x, y, x + w, y + h);
+ gradient.addColorStop(0, borderColorStartStr);
+ gradient.addColorStop(1, borderColorEndStr);
+ ctx.fillStyle = gradient;
+
+ ctx.fillRect(x, y, w, h);
+ }
+
+ // right highlight
+ {
+ const x = width - 2 * scale,
+ y = 2 * scale,
+ w = scale,
+ h = height - 4 * scale;
+ const gradient = ctx.createLinearGradient(x, y, x + w, y + h);
+ gradient.addColorStop(0, borderColorStartStr);
+ gradient.addColorStop(1, borderColorEndStr);
+ ctx.fillStyle = gradient;
+
+ ctx.fillRect(x, y, w, h);
+ }
+
+ item.displayname.split('');
+
+ return itemRender.toBuffer();
+ }
+
+ // stolen from NEU and modified
+ public getPrimaryColourCode(displayname: string): code {
+ let lastColourCode = -99;
+ let currentColour = 0;
+ const mostCommon = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
+ for (let i = 0; i < displayname.length; i++) {
+ const c = displayname.charAt(i);
+ if (c === '\u00A7') {
+ lastColourCode = i;
+ } else if (lastColourCode === i - 1) {
+ const colIndex = '0123456789abcdef'.indexOf(c);
+ if (colIndex >= 0) {
+ currentColour = colIndex;
+ } else {
+ currentColour = 0;
+ }
+ } else if ('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.indexOf(c) >= 0) {
+ if (currentColour > 0) {
+ mostCommon[currentColour] = mostCommon[currentColour]++;
+ }
+ }
+ }
+ let mostCommonCount = 0;
+ for (let index = 0; index < mostCommon.length; index++) {
+ if (mostCommon[index] > mostCommonCount) {
+ mostCommonCount = mostCommon[index];
+ currentColour = index;
+ }
+ }
+
+ return <code>'0123456789abcdef'.charAt(currentColour);
+ }
+
+ // stolen from NEU and modified
+ public getPrimaryColour(displayname: string) {
+ const code = this.getPrimaryColourCode(displayname);
+ return formattingInfo[`§${code}`].foregroundDarker;
+ }
+
+ public override async autocomplete(interaction: AutocompleteInteraction<CacheType>) {
+ return interaction.respond([{ name: 'Blazetekk™ Ham Radio', value: 'BLAZETEKK_HAM_RADIO' }]);
+ }
+}
+
+type code = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f';
diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts
index 13ef2b6..d0c4f33 100644
--- a/src/commands/moulberry-bush/report.ts
+++ b/src/commands/moulberry-bush/report.ts
@@ -4,12 +4,13 @@ import {
clientSendAndPermCheck,
colors,
emojis,
+ mappings,
timestampAndDelta,
type ArgType,
type CommandMessage
} from '#lib';
import { stripIndent } from '#tags';
-import assert from 'assert';
+import assert from 'assert/strict';
import { ApplicationCommandOptionType, EmbedBuilder, PermissionFlagsBits } from 'discord.js';
export default class ReportCommand extends BushCommand {
@@ -54,11 +55,12 @@ export default class ReportCommand extends BushCommand {
return await message.util.reply(`${emojis.error} This command can only be used in servers where reporting is enabled.`);
if (!member) return await message.util.reply(`${emojis.error} Choose someone to report`);
- if (member.user.id === '322862723090219008')
+ if (member.user.id === mappings.users['IRONM00N'])
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(`${emojis.error} You cannot report a bot <:WeirdChamp:756283321301860382>.`);
diff --git a/src/commands/moulberry-bush/rule.ts b/src/commands/moulberry-bush/rule.ts
index d58b78e..25a3ef0 100644
--- a/src/commands/moulberry-bush/rule.ts
+++ b/src/commands/moulberry-bush/rule.ts
@@ -3,6 +3,7 @@ import {
Arg,
BushCommand,
clientSendAndPermCheck,
+ mappings,
type CommandMessage,
type OptArgType,
type SlashMessage
@@ -98,11 +99,11 @@ export default class RuleCommand extends BushCommand {
}
],
slash: true,
- slashGuilds: ['516977525906341928'],
+ slashGuilds: [mappings.guilds["Moulberry's Bush"]],
channel: 'guild',
clientPermissions: (m) => clientSendAndPermCheck(m, [PermissionFlagsBits.EmbedLinks], true),
userPermissions: [],
- restrictedGuilds: ['516977525906341928']
+ restrictedGuilds: [mappings.guilds["Moulberry's Bush"]]
});
}
diff --git a/src/commands/moulberry-bush/serverStatus.ts b/src/commands/moulberry-bush/serverStatus.ts
index a4d5e45..1237b3f 100644
--- a/src/commands/moulberry-bush/serverStatus.ts
+++ b/src/commands/moulberry-bush/serverStatus.ts
@@ -1,5 +1,5 @@
import { BushCommand, clientSendAndPermCheck, colors, emojis, type CommandMessage } from '#lib';
-import assert from 'assert';
+import assert from 'assert/strict';
import { EmbedBuilder, PermissionFlagsBits } from 'discord.js';
import got from 'got';
diff --git a/src/commands/moulberry-bush/solved.ts b/src/commands/moulberry-bush/solved.ts
new file mode 100644
index 0000000..8e123c4
--- /dev/null
+++ b/src/commands/moulberry-bush/solved.ts
@@ -0,0 +1,44 @@
+import { BushCommand, clientSendAndPermCheck, emojis, mappings, type CommandMessage, type SlashMessage } from '#lib';
+import assert from 'assert/strict';
+
+export default class Solved extends BushCommand {
+ public constructor() {
+ super('solved', {
+ aliases: ['solved'],
+ category: "Moulberry's Bush",
+ description: 'A command to mark a support threads as solved.',
+ usage: ['solved'],
+ examples: ['solved'],
+ slash: true,
+ channel: 'guild',
+ clientPermissions: (m) => clientSendAndPermCheck(m),
+ userPermissions: [],
+ slashGuilds: [mappings.guilds["Moulberry's Bush"]],
+ restrictedGuilds: [mappings.guilds["Moulberry's Bush"]]
+ });
+ }
+
+ public override async exec(message: CommandMessage | SlashMessage) {
+ assert(message.inGuild());
+ assert(message.channel);
+
+ if (!message.channel.isThread()) return message.util.reply(`${emojis.error} This command can only be used in threads.`);
+
+ if (message.channel.parentId !== mappings.channels['neu-support'])
+ return message.util.reply(
+ `${emojis.error} This command can only be used in thread that are created in <#${mappings.channels['neu-support']}>.`
+ );
+
+ if (message.channel.name.startsWith('[Solved]')) return message.util.reply(`${emojis.error} This thread is already solved.`);
+
+ if (!message.channel.name.startsWith('Support'))
+ return message.util.reply(`${emojis.error} This thread is not a support thread.`);
+
+ const newName = `[Solved] ${message.channel.name}`;
+
+ await message.channel.setName(newName);
+ await message.util.reply(`${emojis.success} This thread has been marked as solved.`);
+
+ await message.channel.setArchived(true, `${message.author.tag} (${message.author.id}) marked this support thread as solved.`);
+ }
+}