mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-19 12:54:17 +02:00
feat(arabot): add beginning of verification walkthrough
This commit is contained in:
parent
8d39539fef
commit
092dcce2fe
@ -18,7 +18,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { container, Listener } from '@sapphire/framework';
|
import { container, Listener } from '@sapphire/framework';
|
||||||
import type { VoiceChannel, CategoryChannel, VoiceState } from 'discord.js';
|
import type {
|
||||||
|
VoiceChannel,
|
||||||
|
CategoryChannel,
|
||||||
|
VoiceState,
|
||||||
|
TextChannel,
|
||||||
|
GuildMember,
|
||||||
|
} from 'discord.js';
|
||||||
|
import {
|
||||||
|
ButtonInteraction,
|
||||||
|
Constants,
|
||||||
|
MessageActionRow,
|
||||||
|
MessageButton,
|
||||||
|
MessageEmbed,
|
||||||
|
} from 'discord.js';
|
||||||
import { maxVCs } from '../../utils/verificationConfig';
|
import { maxVCs } from '../../utils/verificationConfig';
|
||||||
import { joinVerification, startVerification } from '../../utils/database/verification';
|
import { joinVerification, startVerification } from '../../utils/database/verification';
|
||||||
import IDs from '../../utils/ids';
|
import IDs from '../../utils/ids';
|
||||||
@ -32,6 +45,13 @@ export default class VerificationJoinVCListener extends Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async run(oldState: VoiceState, newState: VoiceState) {
|
public async run(oldState: VoiceState, newState: VoiceState) {
|
||||||
|
// If the event was not a user joining the channel
|
||||||
|
if (oldState.channel?.parent?.id === IDs.categories.verification
|
||||||
|
|| newState.channel?.parent?.id !== IDs.categories.verification
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Variable if this channel is a Verifiers only VC
|
// Variable if this channel is a Verifiers only VC
|
||||||
let verifier = false;
|
let verifier = false;
|
||||||
|
|
||||||
@ -56,13 +76,6 @@ export default class VerificationJoinVCListener extends Listener {
|
|||||||
const currentChannel = currentChannelGuild as VoiceChannel;
|
const currentChannel = currentChannelGuild as VoiceChannel;
|
||||||
const category = categoryGuild as CategoryChannel;
|
const category = categoryGuild as CategoryChannel;
|
||||||
|
|
||||||
// If the event was not a user joining the channel
|
|
||||||
if (oldState.channel?.parent?.id === category.id
|
|
||||||
|| channel.parent?.id !== category.id
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checks if a verifier has joined
|
// Checks if a verifier has joined
|
||||||
if (channel.members.size === 2) {
|
if (channel.members.size === 2) {
|
||||||
await newState.channel!.permissionOverwrites.set([
|
await newState.channel!.permissionOverwrites.set([
|
||||||
@ -132,6 +145,8 @@ export default class VerificationJoinVCListener extends Listener {
|
|||||||
// Send a message that someone wants to be verified
|
// Send a message that someone wants to be verified
|
||||||
await verificationText.send(`${member.user} wants to be verified in ${channel}
|
await verificationText.send(`${member.user} wants to be verified in ${channel}
|
||||||
\n<@&${IDs.roles.staff.verifier}> <@&${IDs.roles.staff.trialVerifier}>`);
|
\n<@&${IDs.roles.staff.verifier}> <@&${IDs.roles.staff.trialVerifier}>`);
|
||||||
|
|
||||||
|
await this.verificationProcess(member, verificationText, channel.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new channel for others to join
|
// Create a new channel for others to join
|
||||||
@ -205,4 +220,119 @@ export default class VerificationJoinVCListener extends Listener {
|
|||||||
]);
|
]);
|
||||||
await currentChannel.setUserLimit(0);
|
await currentChannel.setUserLimit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async verificationProcess(
|
||||||
|
user: GuildMember,
|
||||||
|
channel: TextChannel,
|
||||||
|
id: string,
|
||||||
|
) {
|
||||||
|
const embedColor = '#0099ff';
|
||||||
|
const { displayName } = user;
|
||||||
|
|
||||||
|
// Create an embeds for each page
|
||||||
|
const initialEmbed = new MessageEmbed()
|
||||||
|
.setColor(embedColor)
|
||||||
|
.setTitle(`Do you think ${displayName} is definitely vegan?`);
|
||||||
|
|
||||||
|
const activistEmbed = new MessageEmbed()
|
||||||
|
.setColor(embedColor)
|
||||||
|
.setTitle('Offer to ask questions for Activist. Do you think they should get it?');
|
||||||
|
|
||||||
|
const noActivistEmbed = new MessageEmbed()
|
||||||
|
.setColor(embedColor)
|
||||||
|
.setTitle('Do some activism, asking Activist questions. Now which role should they get?');
|
||||||
|
|
||||||
|
/*
|
||||||
|
const vegCuriousEmbed = new MessageEmbed()
|
||||||
|
.setColor(embedColor)
|
||||||
|
.setTitle('Should this user get Veg Curious?');
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Create buttons to delete or cancel the deletion
|
||||||
|
const initialButtons = new MessageActionRow<MessageButton>()
|
||||||
|
.addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`yesVegan${id}`)
|
||||||
|
.setLabel('Yes')
|
||||||
|
.setStyle(Constants.MessageButtonStyles.SUCCESS),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`noVegan${id}`)
|
||||||
|
.setLabel('No')
|
||||||
|
.setStyle(Constants.MessageButtonStyles.DANGER),
|
||||||
|
);
|
||||||
|
|
||||||
|
const activistButtons = new MessageActionRow<MessageButton>()
|
||||||
|
.addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`yesActivist${id}`)
|
||||||
|
.setLabel('Yes')
|
||||||
|
.setStyle(Constants.MessageButtonStyles.SUCCESS),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`noActivist${id}`)
|
||||||
|
.setLabel('No')
|
||||||
|
.setStyle(Constants.MessageButtonStyles.DANGER),
|
||||||
|
);
|
||||||
|
|
||||||
|
const noActivistButtons = new MessageActionRow<MessageButton>()
|
||||||
|
.addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`vegan${id}`)
|
||||||
|
.setLabel('Vegan')
|
||||||
|
.setStyle(Constants.MessageButtonStyles.SUCCESS),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`convinced${id}`)
|
||||||
|
.setLabel('Convinced')
|
||||||
|
.setStyle(Constants.MessageButtonStyles.SECONDARY),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`notVegan${id}`)
|
||||||
|
.setLabel('Non-vegan')
|
||||||
|
.setStyle(Constants.MessageButtonStyles.DANGER),
|
||||||
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
|
const vegCuriousButtons = new MessageActionRow<MessageButton>()
|
||||||
|
.addComponents(
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`yesVegCurious${id}`)
|
||||||
|
.setLabel('Yes')
|
||||||
|
.setStyle(Constants.MessageButtonStyles.SUCCESS),
|
||||||
|
new MessageButton()
|
||||||
|
.setCustomId(`noVegCurious${id}`)
|
||||||
|
.setLabel('No')
|
||||||
|
.setStyle(Constants.MessageButtonStyles.DANGER),
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Sends the note to verify this note is to be deleted
|
||||||
|
const message = await channel.send({
|
||||||
|
embeds: [initialEmbed],
|
||||||
|
components: [initialButtons],
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen for the button presses
|
||||||
|
const collector = channel.createMessageComponentCollector({
|
||||||
|
max: 2, // Maximum of 1 button press
|
||||||
|
});
|
||||||
|
|
||||||
|
// Button pressed
|
||||||
|
collector.on('collect', async (button: ButtonInteraction) => {
|
||||||
|
// Select roles
|
||||||
|
// Definitely vegan?
|
||||||
|
if (button.customId === `yesVegan${id}`) {
|
||||||
|
await button.deferUpdate();
|
||||||
|
await message.edit({
|
||||||
|
embeds: [activistEmbed],
|
||||||
|
components: [activistButtons],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Not as vegan
|
||||||
|
if (button.customId === `noVegan${id}`) {
|
||||||
|
await button.deferUpdate();
|
||||||
|
await message.edit({
|
||||||
|
embeds: [noActivistEmbed],
|
||||||
|
components: [noActivistButtons],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,14 @@ export class VerificationLeaveVCListener extends Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async run(oldState: VoiceState, newState: VoiceState) {
|
public async run(oldState: VoiceState, newState: VoiceState) {
|
||||||
|
// If the event was not a user joining the channel
|
||||||
|
if (oldState.channel?.parent?.id !== IDs.categories.verification
|
||||||
|
|| newState.channel?.parent?.id === IDs.categories.verification
|
||||||
|
|| oldState.channel.members.size > 0
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let verifier = false;
|
let verifier = false;
|
||||||
|
|
||||||
// Check for undefined variables
|
// Check for undefined variables
|
||||||
@ -60,14 +68,6 @@ export class VerificationLeaveVCListener extends Listener {
|
|||||||
verifier = true;
|
verifier = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the event was not a user joining the channel
|
|
||||||
if (channel.parent?.id !== IDs.categories.verification
|
|
||||||
|| newState.channel?.parent?.id === IDs.categories.verification
|
|
||||||
|| channel.members.size > 0
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow more people to join VC if there are less than 10 VCs
|
// Allow more people to join VC if there are less than 10 VCs
|
||||||
|
|
||||||
if (!verifier) {
|
if (!verifier) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user