hullcss-discord-bot/events/messageCreate.js

52 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-05-10 01:17:25 +01:00
const client = require("../index");
2022-06-01 21:17:26 +01:00
require("dotenv").config();
const discord = require('discord.js');
2022-05-10 01:17:25 +01:00
client.on("messageCreate", async (message) => {
2022-06-01 21:17:26 +01:00
if(message.channel.id == "969944638498680875")
{
2022-06-02 02:14:39 +01:00
const row = new discord.MessageActionRow()
2022-06-01 23:03:30 +01:00
.addComponents(
2022-06-02 02:14:39 +01:00
new discord.MessageButton()
2022-06-01 23:03:30 +01:00
.setCustomId('CloseThread')
.setEmoji('<:archive:937932140014866492> ')
.setLabel('Archive Thread')
.setStyle('SUCCESS')
)
const thread = message.startThread({
name: `${message.author.tag} - ${message}`,
2022-06-01 21:17:26 +01:00
autoArchiveDuration: 60,
type: 'GUILD_PUBLIC_THREAD'
});
2022-06-01 23:03:30 +01:00
(await thread).send({
content: `Hey <@${message.author.id}>! I've automatically created this thread from your message to keep the channel clean and keep messages condensed.
\nIt is recommended that you change the Notification Settings for this thread to All Messages so that you get a notification when someone has responded to your query.
\nPinging <@&904354161561309184> so that they see this as well!`,
components: [row]
});
(await thread).leave();
}
2022-05-10 01:17:25 +01:00
if (
message.author.bot ||
!message.guild ||
2022-05-24 00:38:47 +01:00
!message.content.toLowerCase().startsWith(process.env.PREFIX)
2022-05-10 01:17:25 +01:00
)
return;
const [cmd, ...args] = message.content
2022-05-24 00:38:47 +01:00
.slice(process.env.PREFIX.length)
2022-05-10 01:17:25 +01:00
.trim()
.split(/ +/g);
const command = client.commands.get(cmd.toLowerCase()) || client.commands.find(c => c.aliases?.includes(cmd.toLowerCase()));
if (!command) return;
await command.run(client, message, args);
2022-05-14 19:17:06 +01:00
2022-05-10 01:17:25 +01:00
});