mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-07-16 16:21:00 +02:00
fix(arabot): add check for deleted channel when replying
This commit is contained in:
parent
76f8aa369c
commit
26ea2ba996
@ -68,7 +68,6 @@ export class UnRestrictCommand extends Command {
|
|||||||
await interaction.reply({
|
await interaction.reply({
|
||||||
content: 'Error fetching user!',
|
content: 'Error fetching user!',
|
||||||
ephemeral: true,
|
ephemeral: true,
|
||||||
fetchReply: true,
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -77,9 +76,8 @@ export class UnRestrictCommand extends Command {
|
|||||||
|
|
||||||
const info = await this.unRestrictRun(user?.id, mod.user.id, guild);
|
const info = await this.unRestrictRun(user?.id, mod.user.id, guild);
|
||||||
|
|
||||||
await interaction.reply({
|
await interaction.editReply({
|
||||||
content: info.message,
|
content: info.message,
|
||||||
fetchReply: true,
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,16 +109,26 @@ export class UnRestrictCommand extends Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const info = await this.unRestrictRun(user?.id, mod.user.id, guild);
|
const channelRun = message.channel;
|
||||||
|
|
||||||
|
const info = await this.unRestrictRun(user?.id, mod.user.id, guild, channelRun.id);
|
||||||
|
|
||||||
|
if (!info.runInVeganRestrict) {
|
||||||
await message.reply(info.message);
|
await message.reply(info.message);
|
||||||
await message.react(info.success ? '✅' : '❌');
|
await message.react(info.success ? '✅' : '❌');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async unRestrictRun(userId: Snowflake, modId: Snowflake, guild: Guild) {
|
private async unRestrictRun(
|
||||||
|
userId: Snowflake,
|
||||||
|
modId: Snowflake,
|
||||||
|
guild: Guild,
|
||||||
|
channelRun: Snowflake | null = null,
|
||||||
|
) {
|
||||||
const info = {
|
const info = {
|
||||||
message: '',
|
message: '',
|
||||||
success: false,
|
success: false,
|
||||||
|
runInVeganRestrict: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let user = guild.client.users.cache.get(userId);
|
let user = guild.client.users.cache.get(userId);
|
||||||
@ -206,6 +214,9 @@ export class UnRestrictCommand extends Command {
|
|||||||
const textChannel = c as TextChannel;
|
const textChannel = c as TextChannel;
|
||||||
// Checks if the channel topic has the user's snowflake
|
// Checks if the channel topic has the user's snowflake
|
||||||
if (textChannel.topic?.includes(userId)) {
|
if (textChannel.topic?.includes(userId)) {
|
||||||
|
if (textChannel.id === channelRun) {
|
||||||
|
info.runInVeganRestrict = true;
|
||||||
|
}
|
||||||
topic = textChannel.topic.split(' ');
|
topic = textChannel.topic.split(' ');
|
||||||
const vcId = topic[topic.indexOf(userId) + 1];
|
const vcId = topic[topic.indexOf(userId) + 1];
|
||||||
const voiceChannel = guild.channels.cache.get(vcId);
|
const voiceChannel = guild.channels.cache.get(vcId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user