mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 12:54:17 +02:00
feat(verification): add 15 minute timeout logic
This commit is contained in:
parent
ee27bb7582
commit
70854915af
@ -131,6 +131,13 @@ class VerificationJoinVCListener extends Listener {
|
|||||||
IDs.roles.nonvegan.convinced,
|
IDs.roles.nonvegan.convinced,
|
||||||
IDs.roles.nonvegan.vegCurious,
|
IDs.roles.nonvegan.vegCurious,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Start 15-minute timer if verifier does not join
|
||||||
|
// @ts-ignore
|
||||||
|
this.container.tasks.create('verifyTimeout', {
|
||||||
|
userId: member.id,
|
||||||
|
guildId: guild.id,
|
||||||
|
}, 30_000);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check how many voice channels there are
|
// Check how many voice channels there are
|
||||||
|
56
src/scheduled-tasks/verifyTimeout.ts
Normal file
56
src/scheduled-tasks/verifyTimeout.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
/*
|
||||||
|
Animal Rights Advocates Discord Bot
|
||||||
|
Copyright (C) 2022 Anthony Berg
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
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';
|
||||||
|
|
||||||
|
export class VerifyTimeout extends ScheduledTask {
|
||||||
|
public constructor(context: ScheduledTask.Context, options: ScheduledTask.Options) {
|
||||||
|
super(context, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async run(payload: { channelId: string, userId: string }) {
|
||||||
|
// Get the guild where the user is in
|
||||||
|
let channel = this.container.client.channels.cache.get(payload.channelId) as VoiceChannel | undefined;
|
||||||
|
if (channel === undefined) {
|
||||||
|
channel = await this.container.client.channels.fetch(payload.channelId) as VoiceChannel | undefined;
|
||||||
|
if (channel === undefined) {
|
||||||
|
console.error('verifyTimeout: Channel not found!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel.members.size < 2 && channel.members.has(payload.userId)) {
|
||||||
|
const user = channel.members.get(payload.userId);
|
||||||
|
if (user === undefined) {
|
||||||
|
console.error('verifyTimeout: GuildMember not found!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await user.voice.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@sapphire/plugin-scheduled-tasks' {
|
||||||
|
interface ScheduledTasks {
|
||||||
|
verifyUnblock: never;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default VerifyTimeout;
|
Loading…
x
Reference in New Issue
Block a user