Add LFG channel cleaning and @mention command
This commit is contained in:
parent
00a98db405
commit
4011cf74d6
|
@ -3,6 +3,7 @@ import { dbClient } from '../src/db.ts';
|
||||||
|
|
||||||
console.log('Attempting to insert default actions into command_cnt');
|
console.log('Attempting to insert default actions into command_cnt');
|
||||||
const actions = [
|
const actions = [
|
||||||
|
'msg-mention',
|
||||||
'cmd-delete',
|
'cmd-delete',
|
||||||
'cmd-info',
|
'cmd-info',
|
||||||
'cmd-report',
|
'cmd-report',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ApplicationCommandFlags, Bot, CreateMessage, Interaction, InteractionResponseTypes } from '../deps.ts';
|
import { ApplicationCommandFlags, Bot, CreateMessage, Embed, Interaction, InteractionResponseTypes } from '../deps.ts';
|
||||||
import config from '../config.ts';
|
import config from '../config.ts';
|
||||||
import { generateGuildSettingKey, lfgChannelSettings } from './db.ts';
|
import { generateGuildSettingKey, lfgChannelSettings } from './db.ts';
|
||||||
import utils from './utils.ts';
|
import utils from './utils.ts';
|
||||||
|
@ -64,3 +64,17 @@ export const sendDirectMessage = async (bot: Bot, userId: bigint, message: Creat
|
||||||
// Actually send the DM
|
// Actually send the DM
|
||||||
return bot.helpers.sendMessage(userDmChannel?.id || 0n, message);
|
return bot.helpers.sendMessage(userDmChannel?.id || 0n, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Info Embed Object (for info command and @mention command)
|
||||||
|
export const infoEmbed: Embed = {
|
||||||
|
color: infoColor2,
|
||||||
|
title: `${config.name}, the LFG bot`,
|
||||||
|
description: `${config.name} is developed by Ean AKA Burn_E99.
|
||||||
|
Want to check out my source code? Check it out [here](${config.links.sourceCode}).
|
||||||
|
Need help with this bot? Join my support server [here](${config.links.supportServer}).
|
||||||
|
|
||||||
|
Ran into a bug? Report it to my developers using \`/report [issue description]\`.`,
|
||||||
|
footer: {
|
||||||
|
text: `Current Version: ${config.version}`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import config from '../../config.ts';
|
import config from '../../config.ts';
|
||||||
import { ApplicationCommandTypes, Bot, Interaction, InteractionResponseTypes } from '../../deps.ts';
|
import { ApplicationCommandTypes, Bot, Interaction, InteractionResponseTypes } from '../../deps.ts';
|
||||||
import { infoColor2, isLFGChannel } from '../commandUtils.ts';
|
import { infoEmbed, isLFGChannel } from '../commandUtils.ts';
|
||||||
import { dbClient, queries } from '../db.ts';
|
import { dbClient, queries } from '../db.ts';
|
||||||
import { CommandDetails } from '../types/commandTypes.ts';
|
import { CommandDetails } from '../types/commandTypes.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from '../utils.ts';
|
||||||
|
@ -20,18 +20,7 @@ const execute = (bot: Bot, interaction: Interaction) => {
|
||||||
type: InteractionResponseTypes.ChannelMessageWithSource,
|
type: InteractionResponseTypes.ChannelMessageWithSource,
|
||||||
data: {
|
data: {
|
||||||
flags: isLFGChannel(interaction.guildId || 0n, interaction.channelId || 0n),
|
flags: isLFGChannel(interaction.guildId || 0n, interaction.channelId || 0n),
|
||||||
embeds: [{
|
embeds: [infoEmbed],
|
||||||
color: infoColor2,
|
|
||||||
title: `${config.name}, the LFG bot`,
|
|
||||||
description: `${config.name} is developed by Ean AKA Burn_E99.
|
|
||||||
Want to check out my source code? Check it out [here](${config.links.sourceCode}).
|
|
||||||
Need help with this bot? Join my support server [here](${config.links.supportServer}).
|
|
||||||
|
|
||||||
Ran into a bug? Report it to my developers using \`/report [issue description]\`.`,
|
|
||||||
footer: {
|
|
||||||
text: `Current Version: ${config.version}`,
|
|
||||||
},
|
|
||||||
}],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
).catch((e: Error) => utils.commonLoggers.interactionSendError('info.ts', interaction, e));
|
).catch((e: Error) => utils.commonLoggers.interactionSendError('info.ts', interaction, e));
|
||||||
|
|
|
@ -1,11 +1,31 @@
|
||||||
import config from '../../config.ts';
|
import config from '../../config.ts';
|
||||||
|
import utils from '../utils.ts';
|
||||||
import { Bot, botId, Message } from '../../deps.ts';
|
import { Bot, botId, Message } from '../../deps.ts';
|
||||||
|
import { infoEmbed } from '../commandUtils.ts';
|
||||||
|
import { dbClient, generateGuildSettingKey, lfgChannelSettings, queries } from '../db.ts';
|
||||||
|
|
||||||
export const messageCreate = async (bot: Bot, message: Message) => {
|
export const messageCreate = async (bot: Bot, message: Message) => {
|
||||||
|
// Delete all messages sent to a LFG Channel
|
||||||
|
if (lfgChannelSettings.has(generateGuildSettingKey(message.guildId || 0n, message.channelId))) {
|
||||||
|
bot.helpers.deleteMessage(message.channelId, message.id, 'Cleaning LFG Channel').catch((e: Error) => utils.commonLoggers.messageDeleteError('messageCreate.ts', 'Clean LFG Channel', e));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore all messages that are not commands
|
// Ignore all messages that are not commands
|
||||||
if (message.content.indexOf(config.prefix) !== 0) {
|
if (message.content.indexOf(config.prefix) !== 0) {
|
||||||
// Handle @bot messages
|
// Handle @bot messages
|
||||||
if (message.mentionedUserIds[0] === botId && (message.content.trim().startsWith(`<@${botId}>`) || message.content.trim().startsWith(`<@!${botId}>`))) {
|
if (message.mentionedUserIds[0] === botId && (message.content.trim().startsWith(`<@${botId}>`) || message.content.trim().startsWith(`<@!${botId}>`))) {
|
||||||
|
dbClient.execute(queries.callIncCnt('msg-mention')).catch((e) => utils.commonLoggers.dbError('info.ts', 'call sproc INC_CNT on', e));
|
||||||
|
bot.helpers.sendMessage(message.channelId, {
|
||||||
|
embeds: [infoEmbed],
|
||||||
|
messageReference: {
|
||||||
|
messageId: message.id,
|
||||||
|
channelId: message.channelId,
|
||||||
|
guildId: message.guildId,
|
||||||
|
failIfNotExists: false,
|
||||||
|
},
|
||||||
|
}).catch((e: Error) => utils.commonLoggers.messageSendError('messageCreate.ts', '@mention', e));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return as we are done handling this command
|
// return as we are done handling this command
|
||||||
|
|
Loading…
Reference in New Issue