mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 16:54:16 +02:00
fix(arabot): deleted channel errors
This commit is contained in:
parent
502d5c5cdf
commit
cf8142b86a
@ -17,8 +17,8 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { VoiceChannel } from 'discord.js';
|
|
||||||
import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';
|
import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks';
|
||||||
|
import { ChannelType } from 'discord.js';
|
||||||
|
|
||||||
export class VerifyTimeout extends ScheduledTask {
|
export class VerifyTimeout extends ScheduledTask {
|
||||||
public constructor(
|
public constructor(
|
||||||
@ -32,15 +32,22 @@ export class VerifyTimeout extends ScheduledTask {
|
|||||||
// Get the guild where the user is in
|
// Get the guild where the user is in
|
||||||
let channel = this.container.client.channels.cache.get(
|
let channel = this.container.client.channels.cache.get(
|
||||||
payload.channelId,
|
payload.channelId,
|
||||||
) as VoiceChannel | undefined;
|
);
|
||||||
if (channel === undefined) {
|
if (channel === undefined) {
|
||||||
channel = (await this.container.client.channels.fetch(
|
const channelFetch = await this.container.client.channels.fetch(
|
||||||
payload.channelId,
|
payload.channelId,
|
||||||
)) as VoiceChannel | undefined;
|
).catch(() => null);
|
||||||
if (channel === undefined) {
|
if (channelFetch === null) {
|
||||||
this.container.logger.error('verifyTimeout: Channel not found!');
|
this.container.logger.error('verifyTimeout: Channel not found!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channel = channelFetch;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel.type !== ChannelType.GuildVoice) {
|
||||||
|
this.container.logger.error('verifyTimeout: Channel is not a voice channel!');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel.members.size < 2 && channel.members.has(payload.userId)) {
|
if (channel.members.size < 2 && channel.members.has(payload.userId)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user