Skip to content

Commit

Permalink
fix: fix /hub servers command
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Dec 17, 2023
1 parent 08da377 commit 681036a
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/commands/slash/Main/hub/servers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { t } from '../../../../utils/Locale.js';

export default class Servers extends Hub {
async execute(interaction: ChatInputCommandInteraction) {
await interaction.deferReply();

const hubOpt = interaction.options.getString('hub', true);
const serverOpt = interaction.options.getString('server');
const locale = interaction.user.locale;
Expand All @@ -18,39 +20,33 @@ export default class Servers extends Hub {
});

if (!hub) {
await interaction.reply({
embeds: [simpleEmbed(t({ phrase: 'hub.notFound', locale }))],
ephemeral: true,
});
await interaction.editReply({ embeds: [simpleEmbed(t({ phrase: 'hub.notFound', locale }))] });
return;
}
else if (
hub.ownerId !== interaction.user.id &&
!hub.moderators.some((mod) => mod.userId === interaction.user.id)
) {
await interaction.reply({
await interaction.editReply({
embeds: [simpleEmbed(t({ phrase: 'hub.notFound_mod', locale }))],
ephemeral: true,
});
return;
}

if (hub.connections.length === 0) {
await interaction.reply({
await interaction.editReply({
embeds: [simpleEmbed(t({ phrase: 'hub.servers.noConnections', locale }))],
ephemeral: true,
});
return;
}

if (serverOpt) {
const connection = hub.connections.find((con) => con.serverId === serverOpt);
if (!connection) {
return await interaction.reply({
return await interaction.editReply({
embeds: [
simpleEmbed(t({ phrase: 'hub.servers.notConnected', locale }, { hub: hub.name })),
],
ephemeral: true,
});
}
const server = await interaction.client.guilds.fetch(serverOpt).catch(() => null);
Expand All @@ -71,7 +67,7 @@ export default class Servers extends Hub {
),
);

await interaction.reply({ embeds: [embed] });
await interaction.editReply({ embeds: [embed] });
return;
}

Expand Down

0 comments on commit 681036a

Please sign in to comment.