From 768f2cf139b6da1b69ad4b6d417a6379eb79ccf9 Mon Sep 17 00:00:00 2001 From: Hipperooni Date: Mon, 2 Oct 2023 18:43:06 +1100 Subject: [PATCH] Trivia, small fixes Re-enabled Trivia Stopped Verified role from being removed during tripsit session (stops welcome messages) Added code for /voice add (disabled) Removed /voice radio (just way too buggy) Small edit to welcome message --- src/discord/commands/guild/d.rpg.ts | 10 +- src/discord/commands/guild/d.voice.ts | 132 +++++++++++++++--------- src/discord/events/guildMemberUpdate.ts | 2 +- src/discord/utils/tents.ts | 1 - src/discord/utils/tripsitme.ts | 8 +- 5 files changed, 91 insertions(+), 62 deletions(-) diff --git a/src/discord/commands/guild/d.rpg.ts b/src/discord/commands/guild/d.rpg.ts index 689475191..f96263604 100644 --- a/src/discord/commands/guild/d.rpg.ts +++ b/src/discord/commands/guild/d.rpg.ts @@ -1939,7 +1939,7 @@ export async function rpgArcade( .addComponents( customButton(`rpgCoinFlip,user:${interaction.user.id}`, 'CoinFlip', 'buttonCoinflip', ButtonStyle.Secondary), customButton(`rpgRoulette,user:${interaction.user.id}`, 'Roulette', 'buttonRoulette', ButtonStyle.Secondary), - // customButton(`rpgTrivia,user:${interaction.user.id}`, 'Trivia', 'buttonTrivia', ButtonStyle.Secondary), + customButton(`rpgTrivia,user:${interaction.user.id}`, 'Trivia', 'buttonTrivia', ButtonStyle.Secondary), // customButton(`rpgBlackjack,user:${interaction.user.id}`, 'Blackjack', '🃏', ButtonStyle.Primary), // customButton(`rpgSlots,user:${interaction.user.id}`, 'Slots', '🎰', ButtonStyle.Primary), customButton(`rpgTown,user:${interaction.user.id}`, 'Town', 'buttonTown', ButtonStyle.Primary), @@ -3171,10 +3171,10 @@ export const dRpg: SlashCommand = { .setDescription('Go to the coinflip game')) .addSubcommand(subcommand => subcommand .setName('roulette') - .setDescription('Go to the roulette game')), - // .addSubcommand(subcommand => subcommand - // .setName('trivia') - // .setDescription('Go to the trivia parlor')), + .setDescription('Go to the roulette game')) + .addSubcommand(subcommand => subcommand + .setName('trivia') + .setDescription('Go to the trivia parlor')), async execute(interaction) { log.info(F, await commandContext(interaction)); const channelRpg = await interaction.guild?.channels.fetch(env.CHANNEL_TRIPTOWN as string) as TextChannel; diff --git a/src/discord/commands/guild/d.voice.ts b/src/discord/commands/guild/d.voice.ts index b0a2ea7e0..f8cf95a8b 100644 --- a/src/discord/commands/guild/d.voice.ts +++ b/src/discord/commands/guild/d.voice.ts @@ -1,7 +1,4 @@ import { - VoiceChannel, - ChannelType, - Guild, VoiceChannel, ChannelType, Guild, @@ -18,7 +15,7 @@ import commandContext from '../../utils/context'; const F = f(__filename); -type VoiceActions = 'lock' | 'hide' | 'ban' | 'rename' | 'mute' | 'cohost' | 'radio' | 'bitrate'; +type VoiceActions = 'lock' | 'hide' | 'add' | 'ban' | 'rename' | 'mute' | 'cohost' | 'radio' | 'bitrate'; async function tentRename( voiceChannel: VoiceBasedChannel, @@ -34,30 +31,27 @@ async function tentRename( .setDescription(`${voiceChannel} has been renamed to ${newName}`); } -// async function tentLock( -// voiceChannel: VoiceBasedChannel, -// ):Promise { -// let verb = ''; - -// if ( -// voiceChannel -// .permissionsFor(voiceChannel.guild.roles.everyone) -// .has(PermissionsBitField.Flags.ViewChannel) === true -// ) { -// voiceChannel.permissionOverwrites.edit(voiceChannel.guild.roles.everyone, { ViewChannel: false }); -// verb = 'hidden'; -// } else { -// voiceChannel.permissionOverwrites.edit(voiceChannel.guild.roles.everyone, { ViewChannel: true }); -// verb = 'unhidden'; -// } - -// // log.debug(F, `Channel is now ${verb}`); - -// return embedTemplate() -// .setTitle('Success') -// .setColor(Colors.Green) -// .setDescription(`${voiceChannel} has been ${verb}`); -// } +async function tentLock( + voiceChannel: VoiceBasedChannel, +):Promise { + let verb = ''; + if ( + voiceChannel + .permissionsFor(voiceChannel.guild.roles.everyone) + .has(PermissionsBitField.Flags.Connect) === true + ) { + voiceChannel.permissionOverwrites.edit(voiceChannel.guild.roles.everyone, { Connect: false }); + verb = 'locked'; + } else { + voiceChannel.permissionOverwrites.edit(voiceChannel.guild.roles.everyone, { Connect: true }); + verb = 'unlocked'; + } + // log.debug(F, `Channel is now ${verb}`); + return embedTemplate() + .setTitle('Success') + .setColor(Colors.Green) + .setDescription(`${voiceChannel} has been ${verb}`); +} async function tentHide( voiceChannel: VoiceBasedChannel, @@ -84,21 +78,49 @@ async function tentHide( .setDescription(`${voiceChannel} has been ${verb}`); } +// async function tentAdd( +// voiceChannel: VoiceBasedChannel, +// target: GuildMember, +// ):Promise { +// let verb = ''; +// +// if (voiceChannel.permissionsFor(target).has(PermissionsBitField.Flags.ViewChannel) === false){ +// return embedTemplate() +// .setTitle('Error') +// .setColor(Colors.Red) +// .setDescription(`${target} is banned from ${voiceChannel}, unban them first!`); +// } +// +// if (!voiceChannel.permissionsFor(target).has(PermissionsBitField.Flags.ViewChannel) === true){ +// voiceChannel.permissionOverwrites.create(target, { ViewChannel: true, Connect: true }); +// verb = 'added'; +// } else { +// voiceChannel.permissionOverwrites.delete(target); +// verb = 'unadded'; +// } +// // log.debug(F, `${target.displayName} is now ${verb}`); +// +// return embedTemplate() +// .setTitle('Success') +// .setColor(Colors.Green) +// .setDescription(`${target} has been ${verb} from ${voiceChannel}`); +// } + async function tentBan( voiceChannel: VoiceBasedChannel, target: GuildMember, ):Promise { let verb = ''; - if (voiceChannel.permissionsFor(target).has(PermissionsBitField.Flags.ViewChannel) === true) { + if (!voiceChannel.permissionsFor(target).has(PermissionsBitField.Flags.ViewChannel) === false) { voiceChannel.permissionOverwrites.edit(target, { ViewChannel: false, Connect: false }); if (target.voice.channel === voiceChannel) { target.voice.setChannel(null); } - verb = 'banned and hidden'; + verb = 'banned and disconnected'; } else { - voiceChannel.permissionOverwrites.edit(target, { ViewChannel: true, Connect: true }); - verb = 'unbanned and unhidden'; + voiceChannel.permissionOverwrites.delete(target);; + verb = 'unbanned'; } // log.debug(F, `${target.displayName} is now ${verb}`); @@ -166,12 +188,22 @@ export const dVoice: SlashCommand = { .setName('name') .setDescription('The new name for your Tent') .setRequired(true))) + .addSubcommand(subcommand => subcommand + .setName('lock') + .setDescription('Lock/Unlock the Tent')) .addSubcommand(subcommand => subcommand .setName('hide') - .setDescription('Hide/Unhide the Tent from the channel list')) + .setDescription('Remove the Tent from the channel list')) + // .addSubcommand(subcommand => subcommand + // .setName('add') + // .setDescription('Allow a user to join your Tent when locked or hidden') + // .addUserOption(option => option + // .setName('target') + // .setDescription('The user to add/unadd') + // .setRequired(true))) .addSubcommand(subcommand => subcommand .setName('ban') - .setDescription('Ban/Unban and hide a user from your Tent') + .setDescription('Ban and disconnect a user from your Tent') .addUserOption(option => option .setName('target') .setDescription('The user to ban/unban') @@ -185,7 +217,7 @@ export const dVoice: SlashCommand = { .setRequired(true))) .addSubcommand(subcommand => subcommand .setName('cohost') - .setDescription('Make another member a co-host in your Tent') + .setDescription('Make another user able to use /voice commands') .addUserOption(option => option .setName('target') .setDescription('The user to make co-host') @@ -260,25 +292,31 @@ export const dVoice: SlashCommand = { return false; } - // // Check if the target user is a moderator - // if (target.roles.cache.has(env.ROLE_MODERATOR)) { - // await interaction.editReply({ embeds: [embed.setDescription('You cannot ban a moderator!')] }); - // return false; - // } + // Check if the target user is a moderator + if (target){ + if (target.roles.cache.has(env.ROLE_MODERATOR)) { + await interaction.editReply({ embeds: [embed.setDescription('You cannot do that to a moderator!')] }); + return false; + } + } // log.debug(F, `Command: ${command}`); if (command === 'rename') { embed = await tentRename(voiceChannel, newName); } - // if (command === 'lock') { - // embed = await tentLock(voiceChannel); - // } + if (command === 'lock') { + embed = await tentLock(voiceChannel); + } if (command === 'hide') { embed = await tentHide(voiceChannel); } + // if (command === 'add') { + // embed = await tentAdd(voiceChannel, target); + // } + if (command === 'ban') { embed = await tentBan(voiceChannel, target); } @@ -291,14 +329,6 @@ export const dVoice: SlashCommand = { embed = await tentCohost(voiceChannel, target); } - if (command === 'radio') { - embed = await tentRadio(voiceChannel, stationid, guild); - } - - if (command === 'bitrate') { - embed = await tentBitrate(voiceChannel, bitrate); - } - await interaction.editReply({ embeds: [embed] }); return true; }, diff --git a/src/discord/events/guildMemberUpdate.ts b/src/discord/events/guildMemberUpdate.ts index 93e331274..5db5488f8 100644 --- a/src/discord/events/guildMemberUpdate.ts +++ b/src/discord/events/guildMemberUpdate.ts @@ -340,7 +340,7 @@ async function addedVerified( await channelLounge.send({ content: stripIndents`**${greeting}** - Be safe, have fun, /report any issues! + Be safe, have fun, and don't forget to visit the for more information! *${await topic()}*`, }); diff --git a/src/discord/utils/tents.ts b/src/discord/utils/tents.ts index 81b1413d1..39eadf185 100644 --- a/src/discord/utils/tents.ts +++ b/src/discord/utils/tents.ts @@ -107,7 +107,6 @@ export async function pitchTent( - You can pick up this role in - **Modify your tent** - - \`/voice radio\` - Borrow a radio bot for your tent - \`/voice bitrate\` - Change the bitrate of your tent - \`/voice rename\` - Choose a new name for your tent diff --git a/src/discord/utils/tripsitme.ts b/src/discord/utils/tripsitme.ts index d8ac8915c..cafe624f0 100644 --- a/src/discord/utils/tripsitme.ts +++ b/src/discord/utils/tripsitme.ts @@ -94,11 +94,11 @@ const mindsetRoles = [ env.ROLE_SOBER, ]; -// const otherRoles = [ -// env.ROLE_VERIFIED, -// ]; +const otherRoles = [ + env.ROLE_VERIFIED, +]; -const ignoredRoles = `${teamRoles},${colorRoles},${mindsetRoles}`; +const ignoredRoles = `${teamRoles},${colorRoles},${mindsetRoles},${otherRoles}`; const guildOnly = 'This must be performed in a guild!'; const memberOnly = 'This must be performed by a member of a guild!';