feat(arabot): add deferred replies

This commit is contained in:
smyalygames 2023-02-28 02:44:32 +00:00
parent 5b5994eb47
commit e3e72ce483
9 changed files with 47 additions and 79 deletions

View File

@ -57,31 +57,27 @@ export class MoveAllCommand extends Command {
const { member } = interaction;
const { guild } = interaction;
await interaction.deferReply({ ephemeral: true });
if (channel.type !== ChannelType.GuildVoice
&& channel.type !== ChannelType.GuildStageVoice) {
await interaction.reply({
await interaction.editReply({
content: 'The channel you provided is not a voice channel!',
ephemeral: true,
fetchReply: true,
});
return;
}
// Checks if all the variables are of the right type
if (guild === null) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching guild!',
ephemeral: true,
fetchReply: true,
});
return;
}
if (member === null) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching your user',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -89,19 +85,15 @@ export class MoveAllCommand extends Command {
const mod = guild.members.cache.get(member.user.id);
if (mod === undefined) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching user from guild',
ephemeral: true,
fetchReply: true,
});
return;
}
if (mod.voice.channelId === null) {
await interaction.reply({
await interaction.editReply({
content: 'You need to be in a voice channel to run this command!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -110,10 +102,8 @@ export class MoveAllCommand extends Command {
if (voice === undefined
|| !voice.isVoiceBased()) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching your current voice channel!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -122,10 +112,8 @@ export class MoveAllCommand extends Command {
memberVC.voice.setChannel(channel.id);
});
await interaction.reply({
await interaction.editReply({
content: `Successfully moved ${voice.members.size} members to <#${channel.id}>!`,
ephemeral: true,
fetchReply: true,
});
}

View File

@ -77,12 +77,12 @@ export class PrivateCommand extends Subcommand {
const mod = interaction.member;
const { guild } = interaction;
await interaction.deferReply({ ephemeral: true });
// Checks if all the variables are of the right type
if (user === null || guild === null || mod === null) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching user!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -92,10 +92,8 @@ export class PrivateCommand extends Subcommand {
// Checks if guildMember is null
if (guildMember === undefined || modGuildMember === undefined) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching users!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -103,10 +101,8 @@ export class PrivateCommand extends Subcommand {
const [name, coordinator] = this.getCoordinator(modGuildMember);
if (this.checkPrivate(guildMember.id, coordinator, guild)) {
await interaction.reply({
await interaction.editReply({
content: 'A private channel already exists!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -206,10 +202,8 @@ export class PrivateCommand extends Subcommand {
await privateChannel.send({ embeds: [embed] });
await interaction.reply({
await interaction.editReply({
content: `Created the private channel: ${privateChannel}`,
fetchReply: true,
ephemeral: true,
});
}
@ -219,12 +213,12 @@ export class PrivateCommand extends Subcommand {
const mod = interaction.member;
const { guild, channel } = interaction;
await interaction.deferReply({ ephemeral: true });
// Checks if all the variables are of the right type
if (mod === null || guild === null || channel === null) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching user!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -233,10 +227,8 @@ export class PrivateCommand extends Subcommand {
// Checks if guildMember is null
if (modGuildMember === undefined) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching users!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -247,28 +239,22 @@ export class PrivateCommand extends Subcommand {
if (user === null) {
if (channel.type !== ChannelType.GuildText) {
await interaction.reply({
await interaction.editReply({
content: 'Please make sure you ran this command in the original private text channel!',
ephemeral: true,
fetchReply: true,
});
return;
}
if (channel.parentId !== IDs.categories.private) {
await interaction.reply({
await interaction.editReply({
content: 'Please make sure you ran this command in the original private text channel!',
ephemeral: true,
fetchReply: true,
});
return;
}
if (channel.topic === null) {
await interaction.reply({
await interaction.editReply({
content: 'There was an error with this channel\'s topic!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -290,10 +276,8 @@ export class PrivateCommand extends Subcommand {
.get(IDs.categories.private) as CategoryChannel | undefined;
if (category === undefined) {
await interaction.reply({
await interaction.editReply({
content: 'Could not find category!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -315,10 +299,8 @@ export class PrivateCommand extends Subcommand {
}
});
await interaction.reply({
await interaction.editReply({
content: `Successfully deleted the channel for ${user}`,
fetchReply: true,
ephemeral: true,
});
}

View File

@ -77,9 +77,11 @@ export class BanCommand extends Command {
return;
}
await interaction.deferReply();
const ban = await this.ban(user.id, mod.user.id, reason, guild);
await interaction.reply({ content: ban.message });
await interaction.editReply({ content: ban.message });
}
// Non Application Command method of banning a user

View File

@ -89,6 +89,8 @@ export class TempBanCommand extends Command {
return;
}
await interaction.deferReply();
const ban = await this.ban(user.id, mod.user.id, time, reason, guild);
await interaction.reply({ content: ban.message });

View File

@ -74,6 +74,8 @@ export class UnbanCommand extends Command {
return;
}
await interaction.deferReply();
const unban = await this.unban(user.id, mod.user.id, guild);
await interaction.reply({ content: unban.message });

View File

@ -312,6 +312,8 @@ export class RestrictCommand extends Command {
return;
}
await interaction.deferReply();
const info = await restrictRun(user?.id, mod.user.id, reason, guild);
await interaction.reply({

View File

@ -68,11 +68,12 @@ export class RestrictToleranceCommand extends Command {
return;
}
await interaction.deferReply();
const info = await restrictRun(user?.id, mod.user.id, reason, guild, true);
await interaction.reply({
content: info.message,
fetchReply: true,
});
}

View File

@ -69,12 +69,12 @@ export class RestrictToolsCommand extends Subcommand {
const modInteraction = interaction.member;
const { guild, channel } = interaction;
await interaction.deferReply({ ephemeral: true });
// Checks if all the variables are of the right type
if (modInteraction === null || guild === null || channel === null) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching user!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -83,10 +83,8 @@ export class RestrictToolsCommand extends Subcommand {
// Checks if guildMember is null
if (mod === undefined) {
await interaction.reply({
await interaction.editReply({
content: 'Error fetching moderator!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -95,19 +93,15 @@ export class RestrictToolsCommand extends Subcommand {
if (user === null) {
if (channel.type !== ChannelType.GuildText) {
await interaction.reply({
await interaction.editReply({
content: 'Please make sure you ran this command in the original restricted text channel!',
ephemeral: true,
fetchReply: true,
});
return;
}
if (channel.parentId !== IDs.categories.restricted) {
await interaction.reply({
await interaction.editReply({
content: 'Please make sure you ran this command in the original restricted text channel!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -118,19 +112,15 @@ export class RestrictToolsCommand extends Subcommand {
|| channel.id === IDs.channels.restricted.restricted
|| channel.id === IDs.channels.restricted.tolerance
) {
await interaction.reply({
await interaction.editReply({
content: 'You can\'t run this command these channels!',
ephemeral: true,
fetchReply: true,
});
return;
}
if (channel.topic === null) {
await interaction.reply({
await interaction.editReply({
content: 'There was an error with this channel\'s topic!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -153,10 +143,8 @@ export class RestrictToolsCommand extends Subcommand {
.get(IDs.categories.restricted) as CategoryChannel | undefined;
if (category === undefined) {
await interaction.reply({
await interaction.editReply({
content: 'Could not find category!',
ephemeral: true,
fetchReply: true,
});
return;
}
@ -178,9 +166,8 @@ export class RestrictToolsCommand extends Subcommand {
}
});
await interaction.reply({
await interaction.editReply({
content: `Successfully deleted the channel for ${user}`,
fetchReply: true,
});
}
}

View File

@ -73,6 +73,8 @@ export class UnRestrictCommand extends Command {
return;
}
await interaction.deferReply();
const info = await this.unRestrictRun(user?.id, mod.user.id, guild);
await interaction.reply({