mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 08:20:58 -05:00
Sync event handler from TAEMBO/IRTGaming-bot
This commit is contained in:
parent
3b460eadf8
commit
d407dac74f
@ -10,7 +10,7 @@ export default {
|
|||||||
let messagesArray: Array<string> = [];
|
let messagesArray: Array<string> = [];
|
||||||
|
|
||||||
if (user){
|
if (user){
|
||||||
(interaction.channel as Discord.TextChannel).messages.fetch({limit: 100}).then((msgs)=>{
|
(interaction.channel as Discord.TextChannel).messages.fetch({limit: amount}).then((msgs)=>{
|
||||||
const msgList = msgs.filter(x=>x.author.id == user.id);
|
const msgList = msgs.filter(x=>x.author.id == user.id);
|
||||||
(interaction.channel as Discord.TextChannel).bulkDelete(msgList);
|
(interaction.channel as Discord.TextChannel).bulkDelete(msgList);
|
||||||
})
|
})
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord, { AuditLogEvent } from 'discord.js';
|
import Discord, { AuditLogEvent } from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'guildBanAdd',
|
async run(client:TClient, member:Discord.GuildMember){
|
||||||
execute: async(client:TClient, member:Discord.GuildMember)=>{
|
|
||||||
if (member.guild?.id != client.config.mainServer.id) return;
|
if (member.guild?.id != client.config.mainServer.id) return;
|
||||||
const fetchBanlog = await member.guild.fetchAuditLogs({
|
const fetchBanlog = await member.guild.fetchAuditLogs({
|
||||||
limit: 1,
|
limit: 1,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord, { AuditLogEvent } from 'discord.js';
|
import Discord, { AuditLogEvent } from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'guildBanRemove',
|
async run(client:TClient, member:Discord.GuildMember){
|
||||||
execute: async(client:TClient, member:Discord.GuildMember)=>{
|
|
||||||
if (member.guild?.id != client.config.mainServer.id) return;
|
if (member.guild?.id != client.config.mainServer.id) return;
|
||||||
const fetchUnbanlog = await member.guild.fetchAuditLogs({
|
const fetchUnbanlog = await member.guild.fetchAuditLogs({
|
||||||
limit: 1,
|
limit: 1,
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'guildMemberAdd',
|
async run(client:TClient, member:Discord.GuildMember){
|
||||||
execute: async(client:TClient, member:Discord.GuildMember)=>{
|
|
||||||
//if (member.partial) return;
|
//if (member.partial) return;
|
||||||
if (
|
if (
|
||||||
member.partial
|
member.partial
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'guildMemberRemove',
|
async run(client:TClient, member:Discord.GuildMember){
|
||||||
execute: async(client:TClient, member:Discord.GuildMember)=>{
|
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
if (
|
if (
|
||||||
!member.joinedTimestamp
|
!member.joinedTimestamp
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'guildMemberUpdate',
|
async run(client:TClient, oldMember:Discord.GuildMember, newMember:Discord.GuildMember){
|
||||||
execute: async(client:TClient, oldMember:Discord.GuildMember, newMember:Discord.GuildMember)=>{
|
|
||||||
if (oldMember.guild.id != client.config.mainServer.id) return;
|
if (oldMember.guild.id != client.config.mainServer.id) return;
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
const channel = (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel)
|
const channel = (client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel)
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'interactionCreate',
|
async run(client:TClient, interaction:Discord.ChatInputCommandInteraction){
|
||||||
execute: async(client:TClient, interaction:Discord.ChatInputCommandInteraction)=>{
|
|
||||||
if (!interaction.inGuild() || !interaction.inCachedGuild() || !interaction.command) return;
|
if (!interaction.inGuild() || !interaction.inCachedGuild() || !interaction.command) return;
|
||||||
if (interaction.isCommand()){
|
if (interaction.isCommand()){
|
||||||
const commandFile = client.commands.get(interaction.commandName);
|
const commandFile = client.commands.get(interaction.commandName);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'inviteCreate',
|
async run(client:TClient, invite: Discord.Invite){
|
||||||
execute: async(client:TClient, invite: Discord.Invite)=>{
|
|
||||||
if (!invite.guild) return;
|
if (!invite.guild) return;
|
||||||
const newInvites = await (invite.guild as Discord.Guild).invites.fetch();
|
const newInvites = await (invite.guild as Discord.Guild).invites.fetch();
|
||||||
newInvites.forEach(inv=>client.invites.set(inv.code,{uses: inv.code, creator: inv.inviterId}))
|
newInvites.forEach(inv=>client.invites.set(inv.code,{uses: inv.code, creator: inv.inviterId}))
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'inviteDelete',
|
async run(client:TClient, invite: Discord.Invite){
|
||||||
execute: async(client:TClient, invite: Discord.Invite)=>{
|
|
||||||
client.invites.delete(invite.code)
|
client.invites.delete(invite.code)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,7 @@
|
|||||||
import Discord, { ChannelType } from 'discord.js';
|
import Discord, { ChannelType } from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'messageCreate',
|
async run(client:TClient, message:Discord.Message){
|
||||||
execute: async(client:TClient, message:Discord.Message)=>{
|
|
||||||
if (
|
if (
|
||||||
message.author.bot
|
message.author.bot
|
||||||
|| message.channel.type === ChannelType.DM
|
|| message.channel.type === ChannelType.DM
|
||||||
@ -153,7 +152,7 @@ export default {
|
|||||||
message.reply(`Night **${message.member.displayName}**`)
|
message.reply(`Night **${message.member.displayName}**`)
|
||||||
}
|
}
|
||||||
// Failsafe thingy (Toastproof maybe)
|
// Failsafe thingy (Toastproof maybe)
|
||||||
if (message.content.startsWith('!!!_wepanikfrfr') && client.config.eval.whitelist.includes(message.author.id)){
|
if (message.content.startsWith('!!_wepanikfrfr') && client.config.eval.whitelist.includes(message.author.id)){
|
||||||
(client.guilds.cache.get(message.guildId) as Discord.Guild).commands.set(client.registry).then(()=>message.reply('How did you manage to lose the commands??? Anyways, it\'s re-registered now.')).catch((e:Error)=>message.reply(`Failed to deploy slash commands:\n\`\`\`${e.message}\`\`\``));
|
(client.guilds.cache.get(message.guildId) as Discord.Guild).commands.set(client.registry).then(()=>message.reply('How did you manage to lose the commands??? Anyways, it\'s re-registered now.')).catch((e:Error)=>message.reply(`Failed to deploy slash commands:\n\`\`\`${e.message}\`\`\``));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'messageDelete',
|
async run(client:TClient, msg:Discord.Message){
|
||||||
execute: async(client:TClient, msg:Discord.Message)=>{
|
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
const channel = client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel;
|
const channel = client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel;
|
||||||
const disabledChannels = [
|
const disabledChannels = [
|
||||||
|
@ -1,15 +1,11 @@
|
|||||||
import Discord, { Message, Snowflake } from 'discord.js';
|
import Discord from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'messageDeleteBulk',
|
async run(client:TClient, messages:Discord.Collection<string, Discord.Message<boolean>>){
|
||||||
execute: async(client:TClient, messages:Discord.Collection<Snowflake, Message>)=>{
|
|
||||||
const channel = client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel;
|
const channel = client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel;
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
let msgArray: Array<string> = [];
|
if ((client.guilds.cache.get('929807948748832798') as Discord.Guild)?.id != client.config.mainServer.id) return;
|
||||||
messages.forEach((m)=>{
|
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setTitle(`${messages.size} messages were purged`).setDescription(`\`\`\`${messages.map((msgs)=>`${msgs.member.displayName}: ${msgs.content}`).reverse().join('\n').slice(0,3900)}\`\`\``).addFields({name: 'Channel', value: `<#${(messages.first() as Discord.Message).channel.id}>`});
|
||||||
msgArray.push(`${m.author.username}: ${m.content}`);
|
|
||||||
});
|
|
||||||
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setTitle(`${messages.size} messages were purged`).setDescription(`\`\`\`${msgArray.reverse().join('\n')}\`\`\``.slice(0,3900)).addFields({name: 'Channel', value: `<#${(messages.first() as Discord.Message).channel.id}>`});
|
|
||||||
channel.send({embeds: [embed]})
|
channel.send({embeds: [embed]})
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,8 +1,7 @@
|
|||||||
import Discord, { ActionRowBuilder, ButtonBuilder } from 'discord.js';
|
import Discord, { ActionRowBuilder, ButtonBuilder } from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'messageUpdate',
|
async run(client:TClient, oldMsg:Discord.Message, newMsg:Discord.Message){
|
||||||
execute: async(client:TClient, oldMsg:Discord.Message, newMsg:Discord.Message)=>{
|
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
const disabledChannels = [
|
const disabledChannels = [
|
||||||
'548032776830582794', '541677709487505408'
|
'548032776830582794', '541677709487505408'
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import Discord, { AuditLogEvent } from 'discord.js';
|
import Discord, { AuditLogEvent } from 'discord.js';
|
||||||
import { TClient } from '../client';
|
import { TClient } from '../client';
|
||||||
export default {
|
export default {
|
||||||
name: 'roleUpdate',
|
async run(client:TClient, oldRole:Discord.Role, newRole:Discord.Role){
|
||||||
execute: async(client:TClient, oldRole:Discord.Role, newRole:Discord.Role)=>{
|
|
||||||
const fetchRoleUpdoot = await client.guilds.cache.get(oldRole.guild.id).fetchAuditLogs({
|
const fetchRoleUpdoot = await client.guilds.cache.get(oldRole.guild.id).fetchAuditLogs({
|
||||||
limit: 1,
|
limit: 1,
|
||||||
type: AuditLogEvent.RoleUpdate
|
type: AuditLogEvent.RoleUpdate
|
||||||
|
11
src/index.ts
11
src/index.ts
@ -14,7 +14,7 @@ client.on('ready', async()=>{
|
|||||||
}, 60000);
|
}, 60000);
|
||||||
// ['929807948748832798', '468835415093411861', '1058183358267543552', '549114074273677314'] - 0=Dev Server, 1=Main Server, 2=Throne, 3=Toast's test server
|
// ['929807948748832798', '468835415093411861', '1058183358267543552', '549114074273677314'] - 0=Dev Server, 1=Main Server, 2=Throne, 3=Toast's test server
|
||||||
if (client.config.botSwitches.registerCommands){
|
if (client.config.botSwitches.registerCommands){
|
||||||
['929807948748832798', '468835415093411861', '1058183358267543552'].forEach((guildId)=>(client.guilds.cache.get(guildId) as Discord.Guild).commands.set(client.registry).catch((e:Error)=>{
|
['929807948748832798'].forEach((guildId)=>(client.guilds.cache.get(guildId) as Discord.Guild).commands.set(client.registry).catch((e:Error)=>{
|
||||||
console.log(`Couldn't register slash commands for ${guildId} because`, e.stack);
|
console.log(`Couldn't register slash commands for ${guildId} because`, e.stack);
|
||||||
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send(`Cannot register slash commands for **${client.guilds.cache.get(guildId).name}** (\`${guildId}\`):\n\`\`\`${e.message}\`\`\``)
|
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send(`Cannot register slash commands for **${client.guilds.cache.get(guildId).name}** (\`${guildId}\`):\n\`\`\`${e.message}\`\`\``)
|
||||||
}));
|
}));
|
||||||
@ -33,11 +33,16 @@ client.on('ready', async()=>{
|
|||||||
(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``);
|
(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``);
|
||||||
|
|
||||||
// Event handler
|
// Event handler
|
||||||
const eventFiles = fs.readdirSync('src/events').filter(file=>file.endsWith('.ts'));
|
fs.readdirSync('src/events').forEach((file)=>{
|
||||||
|
const eventFile = require(`./events/${file}`);
|
||||||
|
client.on(file.replace('.ts', ''), async(...args)=>eventFile.default.run(client,...args));
|
||||||
|
});
|
||||||
|
|
||||||
|
/*const eventFiles = fs.readdirSync('src/events').filter(file=>file.endsWith('.ts'));
|
||||||
eventFiles.forEach((file)=>{
|
eventFiles.forEach((file)=>{
|
||||||
const event = require(`./events/${file}`);
|
const event = require(`./events/${file}`);
|
||||||
client.on(event.default.name, async(...args)=>event.default.execute(client, ...args));
|
client.on(event.default.name, async(...args)=>event.default.execute(client, ...args));
|
||||||
});
|
});*/
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle errors
|
// Handle errors
|
||||||
|
Loading…
Reference in New Issue
Block a user