mirror of
https://github.com/Burn-E99/GroupUp.git
synced 2026-01-08 04:17:54 -05:00
Started work on WL Event system, minor update to other files for consistency
db.ts, setup.ts, delete.ts: change lfgSettings to use generator function for map key joinEvent.ts: add first half of WL system, add system to reduce spam/abuse of this system. commandUtils.ts: fix sendDirectMessage to return right promise
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import config from '../../config.ts';
|
||||
import { ApplicationCommandFlags, ApplicationCommandTypes, Bot, Interaction, InteractionResponseTypes } from '../../deps.ts';
|
||||
import { failColor, safelyDismissMsg, somethingWentWrong, successColor } from '../commandUtils.ts';
|
||||
import { dbClient, lfgChannelSettings, queries } from '../db.ts';
|
||||
import { dbClient, generateGuildSettingKey, lfgChannelSettings, queries } from '../db.ts';
|
||||
import { CommandDetails } from '../types/commandTypes.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
@ -16,7 +16,8 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||
dbClient.execute(queries.callIncCnt('cmd-delete')).catch((e) => utils.commonLoggers.dbError('delete.ts', 'call sproc INC_CNT on', e));
|
||||
|
||||
if (interaction.guildId && interaction.channelId) {
|
||||
if (!lfgChannelSettings.has(`${interaction.guildId}-${interaction.channelId}`)) {
|
||||
const lfgChannelSettingKey = generateGuildSettingKey(interaction.guildId, interaction.channelId);
|
||||
if (!lfgChannelSettings.has(lfgChannelSettingKey)) {
|
||||
// Cannot delete a lfg channel that has not been set up
|
||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
@ -43,7 +44,7 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||
somethingWentWrong(bot, interaction, 'deleteDBDeleteFail');
|
||||
return;
|
||||
}
|
||||
lfgChannelSettings.delete(`${interaction.guildId}-${interaction.channelId}`);
|
||||
lfgChannelSettings.delete(lfgChannelSettingKey);
|
||||
|
||||
// Complete the interaction
|
||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
|
||||
@ -14,7 +14,7 @@ import {
|
||||
OverwriteTypes,
|
||||
} from '../../deps.ts';
|
||||
import { failColor, infoColor2, safelyDismissMsg, somethingWentWrong, successColor } from '../commandUtils.ts';
|
||||
import { dbClient, lfgChannelSettings, queries } from '../db.ts';
|
||||
import { dbClient, generateGuildSettingKey, lfgChannelSettings, queries } from '../db.ts';
|
||||
import { CommandDetails } from '../types/commandTypes.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { customId as gameSelId } from '../buttons/event-creation/step1-gameSelection.ts';
|
||||
@ -64,7 +64,8 @@ const execute = async (bot: Bot, interaction: Interaction) => {
|
||||
const setupOpts = interaction.data?.options?.[0];
|
||||
|
||||
if (setupOpts?.name && interaction.channelId && interaction.guildId) {
|
||||
if (lfgChannelSettings.has(`${interaction.guildId}-${interaction.channelId}`)) {
|
||||
const lfgChannelSettingKey = generateGuildSettingKey(interaction.guildId, interaction.channelId);
|
||||
if (lfgChannelSettings.has(lfgChannelSettingKey)) {
|
||||
// Cannot setup a lfg channel that is already set up
|
||||
bot.helpers.sendInteractionResponse(interaction.id, interaction.token, {
|
||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||
@ -260,7 +261,7 @@ The Discord Slash Command system will ensure you provide all the required detail
|
||||
return;
|
||||
}
|
||||
// Store the ids to the active map
|
||||
lfgChannelSettings.set(`${interaction.guildId}-${interaction.channelId}`, {
|
||||
lfgChannelSettings.set(lfgChannelSettingKey, {
|
||||
managed: setupOpts.name === withMgrRole,
|
||||
managerRoleId,
|
||||
logChannelId,
|
||||
|
||||
Reference in New Issue
Block a user