feat(arabot): make vcs when creating groups in outreach

This commit is contained in:
Anthony Berg 2024-02-13 21:36:41 +00:00
parent c82d256be4
commit f4655829e2
6 changed files with 73 additions and 7 deletions

View File

@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `channelId` to the `StatRole` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "StatRole" ADD COLUMN "channelId" TEXT NOT NULL;

View File

@ -222,9 +222,10 @@ model Stat {
} }
model StatRole { model StatRole {
stat Stat @relation(fields: [statId], references: [id]) stat Stat @relation(fields: [statId], references: [id])
statId Int @id statId Int @id
roleId String roleId String
channelId String
} }
model ParticipantStat { model ParticipantStat {

View File

@ -19,7 +19,7 @@
import { Subcommand } from '@sapphire/plugin-subcommands'; import { Subcommand } from '@sapphire/plugin-subcommands';
import { RegisterBehavior } from '@sapphire/framework'; import { RegisterBehavior } from '@sapphire/framework';
import type { Snowflake } from 'discord.js'; import { ChannelType, PermissionsBitField, Snowflake } from 'discord.js';
import { updateUser } from '#utils/database/dbExistingUser'; import { updateUser } from '#utils/database/dbExistingUser';
import { import {
addStatUser, addStatUser,
@ -207,7 +207,7 @@ export class OutreachCommand extends Subcommand {
if (!mod.roles.cache.has(IDs.roles.staff.outreachLeader)) { if (!mod.roles.cache.has(IDs.roles.staff.outreachLeader)) {
await interaction.reply({ await interaction.reply({
content: 'You need to be an Outreach Coordinator to run this command!', content: 'You need to be an Outreach Leader to run this command!',
ephemeral: true, ephemeral: true,
}); });
return; return;
@ -274,7 +274,8 @@ export class OutreachCommand extends Subcommand {
stat.forEach(({ role }) => { stat.forEach(({ role }) => {
if (role !== null) { if (role !== null) {
guild.roles.delete(role.roleId); guild.roles.delete(role.roleId); // Delete role
guild.channels.delete(role.channelId); // Delete VC
} }
}); });
@ -387,14 +388,66 @@ export class OutreachCommand extends Subcommand {
await updateUser(leaderMember); await updateUser(leaderMember);
// Create role for group
const role = await guild.roles.create({ const role = await guild.roles.create({
name: `Outreach Group ${groupNo}`, name: `Outreach Group ${groupNo}`,
mentionable: true,
}); });
await createStat(event.id, leader.id, role.id); // Create a voice channel for group
const channel = await guild.channels.create({
name: `Outreach Group ${groupNo}`,
type: ChannelType.GuildVoice,
parent: IDs.categories.activism,
permissionOverwrites: [
{
id: guild.roles.everyone,
deny: [
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.Connect,
PermissionsBitField.Flags.ViewChannel,
],
},
{
id: IDs.roles.vegan.activist,
allow: [PermissionsBitField.Flags.ViewChannel],
},
{
id: role.id, // Permissions for the specific group
allow: [
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.Connect,
],
},
{
id: IDs.roles.staff.outreachLeader,
allow: [
PermissionsBitField.Flags.SendMessages,
PermissionsBitField.Flags.Connect,
],
},
],
});
// Create stats in database
await createStat(event.id, leader.id, role.id, channel.id);
// Give group leader role
await leaderMember.roles.add(role); await leaderMember.roles.add(role);
// Send message in VC with a welcome and reminder
await channel.send(
`Welcome ${role}, ${leaderMember} is going to be the leader of your group!\n\n` +
'Remember to keep track of stats during activism with `/outreach group update` and' +
'to have these questions in mind whilst doing activism:\n' +
'- How many said would go vegan?\n' +
'- How many seriously considered being vegan?\n' +
'- How many people had anti-vegan viewpoints?\n' +
'- How many thanked you for the conversation?\n' +
'- How many said they would watch a vegan documentary?\n' +
'- How many got educated on veganism or the animal industry?',
);
await interaction.editReply({ await interaction.editReply({
content: `Created a group with the leader being ${leader}`, content: `Created a group with the leader being ${leader}`,
}); });

View File

@ -85,6 +85,7 @@ export async function createStat(
eventId: number, eventId: number,
leaderId: Snowflake, leaderId: Snowflake,
roleId: Snowflake, roleId: Snowflake,
channelId: Snowflake,
) { ) {
await container.database.stat.create({ await container.database.stat.create({
data: { data: {
@ -110,6 +111,7 @@ export async function createStat(
role: { role: {
create: { create: {
roleId, roleId,
channelId,
}, },
}, },
}, },

View File

@ -133,6 +133,7 @@ const devIDs = {
staff: '999431676058927253', staff: '999431676058927253',
modMail: '1095453371411996762', modMail: '1095453371411996762',
verification: '999431677006860409', verification: '999431677006860409',
activism: '999431677795389549',
diversity: '999431679053660185', diversity: '999431679053660185',
private: '999431679527628818', private: '999431679527628818',
restricted: '999431679812845654', restricted: '999431679812845654',

View File

@ -135,6 +135,7 @@ let IDs = {
staff: '768685283583328257', staff: '768685283583328257',
modMail: '867077297664426006', modMail: '867077297664426006',
verification: '797505409073676299', verification: '797505409073676299',
activism: '873918877019545640',
diversity: '933078380394459146', diversity: '933078380394459146',
private: '992581296901599302', private: '992581296901599302',
restricted: '809765577236283472', restricted: '809765577236283472',