Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency @sapphire/framework to v4 #208

Merged
merged 6 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@
"dependencies": {
"@discordjs/collection": "1.3.0",
"@octokit/rest": "19.0.5",
"@sapphire/decorators": "5.0.0",
"@sapphire/discord-utilities": "2.12.0",
"@sapphire/discord.js-utilities": "5.1.2",
"@sapphire/decorators": "6.0.0",
"@sapphire/discord-utilities": "3.0.0",
"@sapphire/discord.js-utilities": "6.0.1",
"@sapphire/fetch": "2.4.1",
"@sapphire/framework": "3.2.0",
"@sapphire/framework": "4.0.2",
"@sapphire/pieces": "3.6.0",
"@sapphire/plugin-editable-commands": "2.0.1",
"@sapphire/plugin-editable-commands": "3.0.0",
"@sapphire/plugin-logger": "3.0.1",
"@sapphire/plugin-subcommands": "3.2.4",
"@sapphire/plugin-subcommands": "4.0.0",
"@sapphire/stopwatch": "1.5.0",
"@sapphire/time-utilities": "1.7.8",
"@sapphire/type": "2.3.0",
"@sapphire/utilities": "3.11.0",
"axios": "0.27.2",
"axios": "1.2.2",
"canvas": "2.11.0",
"chart.js": "3.9.1",
"chart.js": "4.1.2",
"chartjs-node-canvas": "4.1.6",
"chartjs-plugin-datalabels": "2.2.0",
"colorette": "2.0.19",
"common-tags": "1.8.2",
"discord.js": "13.12.0",
"discord.js": "14.7.1",
"dotenv-cra": "3.0.2",
"module-alias": "2.2.2",
"mongodb": "4.13.0",
Expand All @@ -54,8 +55,8 @@
"eslint": "8.32.0",
"eslint-plugin-deprecation": "1.3.3",
"npm-run-all": "4.1.5",
"rimraf": "^3.0.2",
"tsc-watch": "5.0.3",
"rimraf": "4.0.6",
"tsc-watch": "6.0.0",
"tslib": "2.4.1",
"typescript": "4.9.4"
},
Expand Down
4 changes: 2 additions & 2 deletions src/arguments/color.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Argument } from '@sapphire/framework';
import { ColorResolvable, Util } from 'discord.js';
import { ColorResolvable, resolveColor } from 'discord.js';

export class ColorArgument extends Argument<ColorResolvable> {

public run(parameter: string, context: Argument.Context) {
let color: ColorResolvable;

try {
color = Util.resolveColor(parameter.toUpperCase() as ColorResolvable);
color = resolveColor(parameter.toUpperCase() as ColorResolvable);
} catch {
return this.error({
context,
Expand Down
14 changes: 7 additions & 7 deletions src/commands/Fax Center/fax.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApplyOptions } from '@sapphire/decorators';
import type { Args, CommandOptions } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import { ColorResolvable, Message, MessageAttachment, MessageEmbed, TextChannel, Util } from 'discord.js';
import { ColorResolvable, Message, AttachmentBuilder, EmbedBuilder, TextChannel, cleanContent} from 'discord.js';
import { createCanvas, loadImage } from 'canvas';
import { SteveCommand } from '@lib/extensions/SteveCommand';

Expand Down Expand Up @@ -29,9 +29,9 @@ export class UserCommand extends SteveCommand {

const response = await send(msg, `Dialing ${faxNumber}...`);

let message = Util.cleanContent(await args.rest('string'), msg.channel).replace(/<a?(:[a-zA-Z0-9_-]{2,}:)\d+>/g, '$1');
let message = cleanContent(await args.rest('string'), msg.channel).replace(/<a?(:[a-zA-Z0-9_-]{2,}:)\d+>/g, '$1');

const attachments: Array<MessageAttachment> = [];
const attachments: Array<AttachmentBuilder> = [];

const canvas = createCanvas(WIDTH, HEIGHT);
const ctx = canvas.getContext('2d');
Expand All @@ -47,7 +47,7 @@ export class UserCommand extends SteveCommand {
ctx.font = '45px serif';
ctx.fillText(msg.author.username, WIDTH / 2, 100);

const pfp = await loadImage(msg.author.displayAvatarURL({ format: 'png' }));
const pfp = await loadImage(msg.author.displayAvatarURL());
ctx.save();
ctx.translate((HEADER_HEIGHT / 2) - 50, (HEADER_HEIGHT / 2) - 50);
ctx.beginPath();
Expand Down Expand Up @@ -83,7 +83,7 @@ export class UserCommand extends SteveCommand {
message = message.substring(result.length, message.length);

if (currentHeight >= HEIGHT - 25) {
attachments.push(new MessageAttachment(canvas.toBuffer(), `page${pageIdx++}.png`));
attachments.push(new AttachmentBuilder(canvas.toBuffer(), { name: `page${pageIdx++}.png` }));

ctx.resetTransform();

Expand All @@ -96,14 +96,14 @@ export class UserCommand extends SteveCommand {
}
}

attachments.push(new MessageAttachment(canvas.toBuffer(), `page${pageIdx++}.png`));
attachments.push(new AttachmentBuilder(canvas.toBuffer(), { name: `page${pageIdx++}.png` }));

if (attachments.length > 10) {
return response.edit("The fax machine doesn't have enough paper for a fax that long.");
}

const embeds = attachments.map((attachment) =>
new MessageEmbed()
new EmbedBuilder()
.setImage(`attachment://${attachment.name}`)
.setTimestamp(msg.createdTimestamp)
.setColor((recipient.embedColor || 0xadcb27) as ColorResolvable)
Expand Down
24 changes: 12 additions & 12 deletions src/commands/Fax Center/rolodex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApplyOptions } from '@sapphire/decorators';
import type { CommandOptions } from '@sapphire/framework';
import { chunk } from '@sapphire/utilities';
import { Collection, Message, MessageActionRow, MessageEmbed, MessageSelectMenu, User } from 'discord.js';
import { Collection, Message, ActionRowBuilder, EmbedBuilder, StringSelectMenuBuilder, User, ComponentType } from 'discord.js';
import { SteveCommand } from '@lib/extensions/SteveCommand';
import { getUser, sendLoadingMessage } from '@lib/utils';

Expand Down Expand Up @@ -31,15 +31,15 @@ export class UserCommand extends SteveCommand {
userMap.set(faxUser.fax.number, user);
}

const rows: MessageActionRow[] = [];
const rows: ActionRowBuilder<StringSelectMenuBuilder>[] = [];

const pages = chunk(
userMap.map((user, number) => ({ user, number })),
25
);

pages.forEach((page, idx) => {
const dropdown = new MessageSelectMenu()
const dropdown = new StringSelectMenuBuilder()
.setCustomId(`${msg.author.id}-${msg.id}|${idx}|FaxDeskSelect`)
.setPlaceholder('Select a user!');
page.forEach(({ user, number }) => {
Expand All @@ -50,18 +50,18 @@ export class UserCommand extends SteveCommand {
}
]);
});
rows.push(new MessageActionRow().addComponents(dropdown));
rows.push(new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(dropdown));
});

const coverEmbed = new MessageEmbed()
const coverEmbed = new EmbedBuilder()
.setTitle('The Rolodex')
.setThumbnail(
'https://cdn.discordapp.com/attachments/700378786012594268/733117912310612008/59fcd0a11ac53.png'
)
.setImage(
'https://cdn.discordapp.com/attachments/944669817137418333/947584420464955553/PinClipart.com_index-card-clip-art_1718271.png'
)
.setColor('DARK_AQUA')
.setColor('DarkAqua')
.setTimestamp();

await response.edit({
Expand All @@ -71,7 +71,7 @@ export class UserCommand extends SteveCommand {
});

const collector = response.createMessageComponentCollector({
componentType: 'SELECT_MENU',
componentType: ComponentType.StringSelect,
time: 60e3
});

Expand All @@ -97,19 +97,19 @@ export class UserCommand extends SteveCommand {
return;
}

const userEmbed = new MessageEmbed()
const userEmbed = new EmbedBuilder()
.setTitle('The Rolodex')
.setColor('DARK_AQUA')
.addField(user.tag, selected)
.setThumbnail(user.displayAvatarURL({ dynamic: true }));
.setColor('DarkAqua')
.addFields([{ name: user.tag, value: selected}])
.setThumbnail(user.displayAvatarURL());

interaction.update({ embeds: [userEmbed] });
});

collector.on('end', () => {
rows.forEach((row) => {
row.setComponents(
new MessageSelectMenu()
new StringSelectMenuBuilder()
.setDisabled(true)
.setPlaceholder('This selecty boi is off.')
.setCustomId('DISABLED')
Expand Down
10 changes: 5 additions & 5 deletions src/commands/Fax Center/setDesk.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApplyOptions } from '@sapphire/decorators';
import type { CommandOptions } from '@sapphire/framework';
import { Message, MessageActionRow, MessageSelectMenu, User } from 'discord.js';
import { Message, ActionRowBuilder, StringSelectMenuBuilder, User, ChannelType, ComponentType } from 'discord.js';
import { SteveCommand } from '@lib/extensions/SteveCommand';
import { getChannel, getGuild, sendLoadingMessage } from '@lib/utils';

Expand All @@ -17,7 +17,7 @@ export class UserCommand extends SteveCommand {
.find({ $nor: [{ 'channels.fax': { $exists: false } }, { 'channels.fax': { $size: 0 } }] })
.toArray();

const dropdown = new MessageSelectMenu()
const dropdown = new StringSelectMenuBuilder()
.setCustomId(`${msg.author.id}-${msg.id}|FaxDeskSelect`)
.setPlaceholder('Select where you want your faxes to be sent.')
.addOptions([
Expand All @@ -36,7 +36,7 @@ export class UserCommand extends SteveCommand {

dbGuild.channels.fax.forEach(async (channelId) => {
const channel = await getChannel(channelId);
if (!channel?.isText() || channel.type === 'DM' || channel.partial) return;
if (!channel?.isTextBased() || channel.type === ChannelType.DM || channel.partial) return;

dropdown.addOptions({
label: `#${channel.name}`,
Expand All @@ -46,11 +46,11 @@ export class UserCommand extends SteveCommand {
});
});

const actionRow = new MessageActionRow().addComponents(dropdown);
const actionRow = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(dropdown);

await response.edit({ content: 'You can send faxes to all these places!', components: [actionRow] });

const collector = response.createMessageComponentCollector({ componentType: 'SELECT_MENU', time: 60e3 });
const collector = response.createMessageComponentCollector({ componentType: ComponentType.StringSelect, time: 60e3 });

collector.on('collect', async (interaction) => {
await interaction.deferReply({ ephemeral: true });
Expand Down
6 changes: 3 additions & 3 deletions src/commands/General/discordstatus.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApplyOptions } from '@sapphire/decorators';
import type { CommandOptions } from '@sapphire/framework';
import axios from 'axios';
import { Message, MessageEmbed } from 'discord.js';
import { Message, EmbedBuilder } from 'discord.js';
import { SteveCommand } from '@lib/extensions/SteveCommand';
import { dateToTimestamp, sendLoadingMessage } from '@lib/utils';

Expand All @@ -24,8 +24,8 @@ export class UserCommand extends SteveCommand {
const ongoingIncidents = currentStatus.incidents.length > 0;
const isOnFire = !componentsOperational || ongoingIncidents || currentStatus.status.indicator !== 'none';

const embed = new MessageEmbed()
.setColor(isOnFire ? 'RED' : 'BLURPLE')
const embed = new EmbedBuilder()
.setColor(isOnFire ? 'Red' : 'Blurple')
.setTitle(isOnFire ? 'Discord is currently on fire' : currentStatus.status.description)
.setURL(currentStatus.page.url)
.setThumbnail(isOnFire
Expand Down
2 changes: 1 addition & 1 deletion src/commands/General/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class UserCommand extends SteveCommand {
}, { idHints: this.container.idHits.get(this.name) });
}

public override async chatInputRun(interaction: Command.ChatInputInteraction) {
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await interaction.reply('Ping?');
interaction.editReply(`Pong! (Roundtrip took: ${interaction.createdTimestamp - Date.now()
}ms. Heartbeat: ${Math.round(this.container.client.ws.ping)}ms.)`);
Expand Down
6 changes: 3 additions & 3 deletions src/commands/General/whois.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApplyOptions } from '@sapphire/decorators';
import { send } from '@sapphire/plugin-editable-commands';
import type { Args, CommandOptions } from '@sapphire/framework';
import { ColorResolvable, Message, MessageEmbed } from 'discord.js';
import { ColorResolvable, Message, EmbedBuilder } from 'discord.js';
import { SteveCommand } from '@lib/extensions/SteveCommand';
import { dateToTimestamp } from '@lib/utils';

Expand All @@ -28,8 +28,8 @@ export class UserCommand extends SteveCommand {

const targetData = await this.container.db.users.findOne({ id: target.id });

const embed = new MessageEmbed()
.setAuthor({ name: target.user.tag, iconURL: target.displayAvatarURL({ dynamic: true }) })
const embed = new EmbedBuilder()
.setAuthor({ name: target.user.tag, iconURL: target.displayAvatarURL() })
.setColor((targetData?.embedColor || 'AQUA') as ColorResolvable)
.addFields([
{ name: 'Display Name', value: target.displayName, inline: true },
Expand Down
6 changes: 3 additions & 3 deletions src/commands/Info/commit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApplyOptions } from '@sapphire/decorators';
import { Args, CommandOptions, UserError } from '@sapphire/framework';
import { Message, MessageEmbed } from 'discord.js';
import { Message, EmbedBuilder } from 'discord.js';
import { SteveCommand } from '@lib/extensions/SteveCommand';
import { execSync } from 'child_process';
import { send } from '@sapphire/plugin-editable-commands';
Expand Down Expand Up @@ -51,11 +51,11 @@ export class CommitCommand extends SteveCommand {
\`${message}\` by ${author} at ${dateToTimestamp(timestamp, 'f')}`);
});

const embed = new MessageEmbed()
const embed = new EmbedBuilder()
.setTitle(`Showing ${count} ${pluralize('commit', count)} on ${branch}`)
.setURL(`${this.homePage}/tree/${branch}`)
.setDescription(descriptions.join('\n'))
.setColor('AQUA');
.setColor('Aqua');


return send(msg, { embeds: [embed] });
Expand Down
11 changes: 6 additions & 5 deletions src/commands/Info/help.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ApplyOptions } from '@sapphire/decorators';
import type { Args, CommandOptions, DetailedDescriptionCommand, MessageCommandContext } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import { EmbedField, Message, MessageEmbed, Util } from 'discord.js';
import { EmbedField, Message, EmbedBuilder, ChannelType } from 'discord.js';
import { SteveCommand } from '@lib/extensions/SteveCommand';
import { splitMessage } from '@lib/utils';

@ApplyOptions<CommandOptions>({
description: `Shows info about ${process.env.BOT_NAME}'s commands.`,
Expand Down Expand Up @@ -57,14 +58,14 @@ export class UserCommand extends SteveCommand {
})
);

const splitStr = Util.splitMessage(helpStr, { char: '\n' });
const splitStr = splitMessage(helpStr);
let notified = false;
splitStr.forEach((helpMsg) => {
msg.author
.send(helpMsg)
.then(() => {
if (!notified) {
if (msg.channel.type !== 'DM') send(msg, '📥 | The list of commands you have access to has been sent to your DMs.');
if (msg.channel.type !== ChannelType.DM) send(msg, '📥 | The list of commands you have access to has been sent to your DMs.');
notified = true;
}
})
Expand Down Expand Up @@ -153,11 +154,11 @@ export class UserCommand extends SteveCommand {
});
}

const embed = new MessageEmbed()
const embed = new EmbedBuilder()
.setAuthor({ iconURL: msg.client.user?.avatarURL() ?? undefined, name: cmd.name })
.setTitle(cmd.description)
.addFields(fields)
.setColor('RANDOM');
.setColor('Random');

if (cmd.supportsChatInputCommands()) {
embed.setDescription(`<:supportsSlashCommands:1053479279343710328> You can also run ${cmd.name} using slash commands!`);
Expand Down
6 changes: 3 additions & 3 deletions src/commands/Info/snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ApplyOptions } from '@sapphire/decorators';
import { Args, UserError } from '@sapphire/framework';
import { send } from '@sapphire/plugin-editable-commands';
import type { SubcommandOptions } from '@sapphire/plugin-subcommands';
import { Message, MessageEmbed } from 'discord.js';
import { Message, EmbedBuilder } from 'discord.js';
import { SteveSubcommand } from '@lib/extensions/SteveSubcommand';
import { sendLoadingMessage } from '@lib/utils';

Expand Down Expand Up @@ -47,9 +47,9 @@ export class UserCommand extends SteveSubcommand {

const snips = await this.container.db.snips.find({ guildId: msg.guildId }).toArray();

const embed = new MessageEmbed()
const embed = new EmbedBuilder()
.setTitle('Snippets')
.setColor('DARK_VIVID_PINK')
.setColor('DarkVividPink')
.setDescription(`\`${snips.map(snip => snip.snipName).join('`, `')}\``);

return response.edit({ content: ' ', embeds: [embed] });
Expand Down
Loading