Skip to content

Commit

Permalink
fix: 🚑️ fix bad reply function
Browse files Browse the repository at this point in the history
  • Loading branch information
swiizyy committed Aug 25, 2023
1 parent 8d3d2a0 commit 2efa9b8
Show file tree
Hide file tree
Showing 33 changed files with 81 additions and 59 deletions.
2 changes: 1 addition & 1 deletion src/commands/general/birthday/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export class ListCommand extends Command {

const { embed, components } = await generateBirthdayList(1, interaction.guild);

return reply({ components, embeds: [generateDefaultEmbed(embed)] });
return reply(interaction, { components, embeds: [generateDefaultEmbed(embed)] });
}
}
4 changes: 2 additions & 2 deletions src/commands/general/birthday/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export class ListCommand extends Command {
command: BirthdayApplicationCommandMentions.Update,
});

if (!birthday) return reply(interactionProblem(alreadyRegistered));
if (!birthday) return reply(interaction, interactionProblem(alreadyRegistered));

const success = await resolveKey(interaction, 'commands/birthday:register.success', options);

await updateBirthdayOverview(birthday.guildId);
return reply(interactionSuccess(success));
return reply(interaction, interactionSuccess(success));
}
}
7 changes: 5 additions & 2 deletions src/commands/general/birthday/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ export class ListCommand extends Command {

if (isNullish(birthday)) {
const message = await resolveKey(interaction, 'commands/birthday:remove.notRegistered', options);
return reply(interactionProblem(message));
return reply(interaction, interactionProblem(message));
}

await updateBirthdayOverview(birthday.guildId);
return reply(interactionSuccess(await resolveKey(interaction, 'commands/birthday:remove.success', options)));
return reply(
interaction,
interactionSuccess(await resolveKey(interaction, 'commands/birthday:remove.success', options)),
);
}
}
3 changes: 2 additions & 1 deletion src/commands/general/birthday/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class ShowCommand extends Command {

if (isNullish(birthday)) {
return reply(
interaction,
interactionProblem(
await resolveKey(interaction, 'commands/birthday:show.notRegistered', {
command: BirthdayApplicationCommandMentions.Register,
Expand All @@ -47,7 +48,7 @@ export class ShowCommand extends Command {
}),
]);

return reply({
return reply(interaction, {
embeds: [
{
...defaultEmbed(),
Expand Down
2 changes: 1 addition & 1 deletion src/commands/general/birthday/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export class TestCommand extends Command {
userId: user.id,
});

return reply(interactionSuccess('Birthday Test Run!'));
return reply(interaction, interactionSuccess('Birthday Test Run!'));
}
}
8 changes: 6 additions & 2 deletions src/commands/general/birthday/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,18 @@ export class UpdateCommand extends Command {
const message = await resolveKey(interaction, 'commands/birthday:update.notRegistered', {
command: BirthdayApplicationCommandMentions.Register,
});
return reply(interactionProblem(message));
return reply(interaction, interactionProblem(message));
}

return reply(interactionProblem(await resolveKey(interaction, 'commands/birthday:update.notUpdated')));
return reply(
interaction,
interactionProblem(await resolveKey(interaction, 'commands/birthday:update.notUpdated')),
);
},
ok: async (birthday) => {
await updateBirthdayOverview(interaction.guildId);
return reply(
interaction,
interactionSuccess(
await resolveKey(interaction, 'commands/birthday:update.success', {
date: bold(formatDateForDisplay(birthday.birthday, true)),
Expand Down
11 changes: 7 additions & 4 deletions src/commands/general/blacklist/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class AddlacklistCommand extends Command {

if (options.context === 'author') {
const message = await resolveKey(interaction, 'commands/blacklist:add.cannotBlacklistSelf');
return reply(interactionProblem(message, true));
return reply(interaction, interactionProblem(message, true));
}

const data = { guildId: interaction.guildId, userId: user.id };
Expand All @@ -29,13 +29,16 @@ export class AddlacklistCommand extends Command {
err: async (error: Prisma.PrismaClientKnownRequestError) => {
if (error.code === PrismaErrorCodeEnum.UniqueConstraintFailed) {
const message = await resolveKey(interaction, 'commands/blacklist:add.alReadyBlacklisted', options);
return reply(interactionProblem(message));
return reply(interaction, interactionProblem(message));
}
return reply(interactionProblem(await resolveKey(interaction, 'commands/blacklist:add.notAdded')));
return reply(
interaction,
interactionProblem(await resolveKey(interaction, 'commands/blacklist:add.notAdded')),
);
},
ok: async () => {
const message = await resolveKey(interaction, 'commands/blacklist:add.success', options);
return reply(interactionSuccess(message));
return reply(interaction, interactionSuccess(message));
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/general/blacklist/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ListCommand extends Command {
const blacklistedUsers = await this.container.utilities.blacklist.get.BlacklistByGuildId(interaction.guildId);
const description = processBlacklistedUsers(blacklistedUsers);

return reply({
return reply(interaction, {
embeds: [
generateDefaultEmbed({
description,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/general/blacklist/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export class RemoveCommand extends Command {
);

if (isNullOrUndefinedOrEmpty(result))
return reply(interactionProblem(`${userMention(user.id)} is not blacklisted.`, true));
return reply(interaction, interactionProblem(`${userMention(user.id)} is not blacklisted.`, true));

return reply(interactionSuccess(`Removed ${userMention(user.id)} from the blacklist.`, true));
return reply(interaction, interactionSuccess(`Removed ${userMention(user.id)} from the blacklist.`, true));
}
}
7 changes: 6 additions & 1 deletion src/commands/general/config/announcementChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export class AnnouncementChannelCommand extends Command {

if (!hasPermissionInNewChannel) {
return reply(
interaction,
interactionProblem(` I don't have permission to send messages in ${channelMention(channel.id)}.`),
);
}
Expand All @@ -41,10 +42,14 @@ export class AnnouncementChannelCommand extends Command {

if (isNullOrUndefinedOrEmpty(birthday)) {
return reply(
interaction,
interactionProblem(`An error occurred while trying to update the config. Please try again later.`),
);
}

return reply(interactionSuccess(`Successfully set the announcement channel to ${channelMention(channel.id)}.`));
return reply(
interaction,
interactionSuccess(`Successfully set the announcement channel to ${channelMention(channel.id)}.`),
);
}
}
5 changes: 4 additions & 1 deletion src/commands/general/config/announcementMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,26 @@ export class AnnouncementMessageCommand extends Command {

if (!isPremium) {
return reply(
interaction,
interactionProblem(`This feature is currently in __Beta Stage__ and **Birthdayy Premium Only**.
If you are interested in using this and future features now already, you can support the Development on [Patreon](${PREMIUM_URL}).`),
);
}

if (message.length > EmbedLimits.MaximumDescriptionLength - 500) {
return reply(
interaction,
interactionProblem('The message you provided is too long. Please try again with a shorter message.'),
);
}
this.container.logger.info('MESSAGE: ', message);
try {
await this.container.utilities.guild.set.AnnouncementMessage(interaction.guildId, message);
return reply(interactionSuccess('You have successfully updated the announcement message.'));
return reply(interaction, interactionSuccess('You have successfully updated the announcement message.'));
} catch (error) {
this.container.logger.info('AnnouncementMessageCommand ~ overridechatInputRun ~ error:', error);
return reply(
interaction,
interactionProblem('An error occurred while trying to update the config. Please try again later.'),
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/general/config/birthdayRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export class ListCommand extends Command {
);

if (isNullOrUndefinedOrEmpty(guild)) {
return reply(interactionProblem('An error occurred while trying to update the config.'));
return reply(interaction, interactionProblem('An error occurred while trying to update the config.'));
}

return reply(interactionSuccess(`Successfully set the birthday role to ${roleMention(role.id)}.`));
return reply(interaction, interactionSuccess(`Successfully set the birthday role to ${roleMention(role.id)}.`));
}
}
2 changes: 1 addition & 1 deletion src/commands/general/config/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export class ListCommand extends Command {

const configEmbed = await generateConfigList(interaction.guildId, { guild: interaction.guild });

await reply({ embeds: [generateDefaultEmbed(configEmbed)] });
await reply(interaction, { embeds: [generateDefaultEmbed(configEmbed)] });
}
}
3 changes: 3 additions & 0 deletions src/commands/general/config/overviewChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class OverviewChannelCommand extends Command {

if (!hasWritingPermissionsInChannel) {
return reply(
interaction,
interactionProblem(`I don't have permission to send messages in ${channelMention(channel.id)}.`),
);
}
Expand All @@ -56,11 +57,13 @@ export class OverviewChannelCommand extends Command {

if (isNullOrUndefinedOrEmpty(result)) {
return reply(
interaction,
interactionProblem(`An error occurred while trying to update the config. Please try again later.`),
);
}

return reply(
interaction,
interactionSuccess(
`Successfully set the overview channel to ${channelMention(channel.id)} and the message to ${
message.url
Expand Down
9 changes: 6 additions & 3 deletions src/commands/general/config/pingRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class PingRoleCommand extends Command {
const role = interaction.options.getRole('role', true);
// check if role is everyone or here
if (role.id === interaction.guildId) {
return reply(interactionProblem('You can not set the ping role to @everyone or @here'));
return reply(interaction, interactionProblem('You can not set the ping role to @everyone or @here'));
// TODO: #32 Enable everyone and here to be pinged
}

Expand All @@ -35,9 +35,12 @@ export class PingRoleCommand extends Command {
);

if (isNullOrUndefinedOrEmpty(result)) {
return reply(interactionProblem('An error occurred while trying to update the config.'));
return reply(interaction, interactionProblem('An error occurred while trying to update the config.'));
}

return reply(interactionSuccess(`Successfully set the birthday ping role to ${roleMention(role.id)}`));
return reply(
interaction,
interactionSuccess(`Successfully set the birthday ping role to ${roleMention(role.id)}`),
);
}
}
7 changes: 5 additions & 2 deletions src/commands/general/config/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ export class ResetCommand extends Command {
);

if (isNullOrUndefinedOrEmpty(result)) {
return reply(interactionProblem(`An error occurred while trying to reset the ${configName} config.`));
return reply(
interaction,
interactionProblem(`An error occurred while trying to reset the ${configName} config.`),
);
}

return reply(interactionSuccess(`Successfully reset the ${configName} config.`));
return reply(interaction, interactionSuccess(`Successfully reset the ${configName} config.`));
}
}
3 changes: 2 additions & 1 deletion src/commands/general/config/timezone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ export class TimezoneCommand extends Command {
);

if (isNullOrUndefinedOrEmpty(result)) {
return reply(interactionProblem("I couldn't set the **Timezone**."));
return reply(interaction, interactionProblem("I couldn't set the **Timezone**."));
}

return reply(
interaction,
interactionSuccess(`The **Timezone** has been set to UTC${timezone >= 0 ? `+${timezone}` : timezone}.`),
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/general/guide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class GuideCommand extends Command {
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await thinking(interaction);
const embed = generateDefaultEmbed(GuideEmbed);
await reply({
await reply(interaction, {
embeds: [embed],
components: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/commands/general/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class HelpCommand extends Command {
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await thinking(interaction);
const embed = generateDefaultEmbed(HelpEmbed);
await reply({
await reply(interaction, {
embeds: [embed],
components: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/commands/general/invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class GuideCommand extends Command {
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await thinking(interaction);
const embed = generateDefaultEmbed(InviteEmbed);
await reply({
await reply(interaction, {
embeds: [embed],
components: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/commands/general/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ export class StatsCommand extends Command {
],
};
const embed = generateDefaultEmbed(embedRaw);
return reply({ embeds: [embed] });
return reply(interaction, { embeds: [embed] });
}
}
2 changes: 1 addition & 1 deletion src/commands/general/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class SupportCommand extends Command {
await docsButtonBuilder(interaction),
]);

return reply({
return reply(interaction, {
embeds: [embed],
components: [components],
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/general/vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class VoteCommand extends Command {
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await thinking(interaction);
const embed = generateDefaultEmbed(VoteEmbed);
return reply({
return reply(interaction, {
embeds: [embed],
});
}
Expand Down
5 changes: 3 additions & 2 deletions src/commands/internal/count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BOT_COLOR, generateDefaultEmbed, isNotCustom, reply } from '#utils';
import { getCommandGuilds } from '#utils/functions';
import { ApplyOptions } from '@sapphire/decorators';
import { Command } from '@sapphire/framework';
import type { ChatInputCommandInteraction } from 'discord.js';

@ApplyOptions<Command.Options>({
name: 'count',
Expand All @@ -28,8 +29,8 @@ export class CountCommand extends Command {
);
}

public override async chatInputRun() {
await reply({
public override async chatInputRun(interaction: ChatInputCommandInteraction) {
await reply(interaction, {
embeds: [
{
title: 'Discord Information',
Expand Down
4 changes: 2 additions & 2 deletions src/commands/internal/guildInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class GuildInfoCommand extends Command {
const guildDiscord = await this.container.client.guilds.fetch(guildId).catch(() => null);
const guildBirthdayCount = await this.container.utilities.birthday.get.BirthdayCountByGuildId(guildId);

if (!guildDatabase || !guildDiscord) return reply('Guild Infos not found');
if (!guildDatabase || !guildDiscord) return reply(interaction, 'Guild Infos not found');

const embed = generateDefaultEmbed({
fields: [
Expand Down Expand Up @@ -111,7 +111,7 @@ export class GuildInfoCommand extends Command {

const configEmbed = generateDefaultEmbed(await generateConfigList(guildId, { guild: guildDiscord }));

return reply({
return reply(interaction, {
content: `GuildInfos for ${guildDiscord.name}`,
embeds: [embed, configEmbed],
});
Expand Down
4 changes: 2 additions & 2 deletions src/commands/internal/toggle-premium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export class TogglePremiumCommand extends Command {
const guild = await getGuildInformation(guildId);
await thinking(interaction, true);
if (!guild) {
return reply(interactionProblem(`Guild ${inlineCode(guildId)} not found`, true));
return reply(interaction, interactionProblem(`Guild ${inlineCode(guildId)} not found`, true));
}
// set premium for guild to toggle
await this.container.utilities.guild.set.Premium(guildId, toggle);
return reply({
return reply(interaction, {
embeds: [
generateDefaultEmbed({
title: 'Toggle Premium',
Expand Down
2 changes: 1 addition & 1 deletion src/commands/premium/reminder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class GuideCommand extends Command {
public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
await thinking(interaction);
const embed = generateDefaultEmbed(InviteEmbed);
await reply({
await reply(interaction, {
embeds: [embed],
components: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tryout/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ export class TestCommand extends Command {
if (toggle.appEnv) fields.push({ name: 'APP ENV', value: inlineCode(APP_ENV) });
if (toggle.appEnv) fields.push({ name: 'isProduction', value: inlineCode(isProduction ? 'true' : 'false') });

return reply({ embeds: [generateDefaultEmbed({ title: 'test', fields })] });
return reply(interaction, { embeds: [generateDefaultEmbed({ title: 'test', fields })] });
}
}
Loading

0 comments on commit 2efa9b8

Please sign in to comment.