mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-12-28 08:55:38 -05:00
Some improvements
This commit is contained in:
parent
cdf72bceb1
commit
bbf01dc7ba
@ -35,24 +35,6 @@ export default class Automoderator {
|
|||||||
clearTimeout(data.timeout);
|
clearTimeout(data.timeout);
|
||||||
data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime);
|
data.timeout = setTimeout(()=>delete client.repeatedMessages[message.author.id], thresholdTime);
|
||||||
}
|
}
|
||||||
}// Explanation: If spammer sends same message 5 or more times in every channel, they will be served a rotten fish and chips for dinner.
|
|
||||||
static async crosspostSpam(client:TClient, message:Discord.Message, reason:string) {
|
|
||||||
if (!client.crosspostSpam[message.author.id]) client.crosspostSpam[message.author.id] = {message: message.content, channelId: [message.channelId]};
|
|
||||||
else if (!client.crosspostSpam[message.author.id].channelId.includes(message.channelId)) client.crosspostSpam[message.author.id].channelId.push(message.channelId);
|
|
||||||
|
|
||||||
if (client.crosspostSpam[message.author.id].channelId.length >= 5) {
|
|
||||||
if (!this.lockQuery.has(message.author.id)) {
|
|
||||||
this.lockQuery.add(message.author.id);
|
|
||||||
Logger.console('log', 'AUTOMOD', `Lock acquired for ${message.author.tag} with reason: ${reason}`);
|
|
||||||
await client.punishments.punishmentAdd('ban', {}, client.user.id, `AUTOMOD:${reason}`, message.author, message.member as Discord.GuildMember);
|
|
||||||
setTimeout(()=>{
|
|
||||||
this.lockQuery.delete(message.author.id);
|
|
||||||
Logger.console('log', 'AUTOMOD', `Lock released for ${message.author.tag}`);
|
|
||||||
}, 5000); // Wait 5 seconds before releasing the lock.
|
|
||||||
}
|
|
||||||
delete client.crosspostSpam[message.author.id];
|
|
||||||
}
|
|
||||||
setTimeout(()=>delete client.crosspostSpam[message.author.id], 180000); // Delete the data after 3 minutes.
|
|
||||||
}
|
}
|
||||||
static async imageOnly(message:Discord.Message) {
|
static async imageOnly(message:Discord.Message) {
|
||||||
const io_channels = ['468896467688620032'];
|
const io_channels = ['468896467688620032'];
|
||||||
|
@ -9,7 +9,6 @@ export default class GuildBanAdd {
|
|||||||
if (target.id === member.user.id) {
|
if (target.id === member.user.id) {
|
||||||
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}))
|
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}))
|
||||||
.setTitle(`Member Banned: ${target.username}`).addFields(
|
.setTitle(`Member Banned: ${target.username}`).addFields(
|
||||||
{name: '🔹 User', value: `<@${target.id}>\n\`${target.id}\``},
|
|
||||||
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
|
{name: '🔹 Moderator', value: `<@${executor.id}>\n\`${executor.id}\``},
|
||||||
{name: '🔹 Reason', value: reason === null ? 'Reason unspecified': reason}
|
{name: '🔹 Reason', value: reason === null ? 'Reason unspecified': reason}
|
||||||
);
|
);
|
||||||
|
@ -17,12 +17,13 @@ export default class GuildMemberAdd {
|
|||||||
let isBot = 'Bot';
|
let isBot = 'Bot';
|
||||||
if (!member.user.bot) isBot = 'Member';
|
if (!member.user.bot) isBot = 'Member';
|
||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
(client.channels.resolve(client.config.dcServer.channels.welcome) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setThumbnail(member.user.displayAvatarURL({size: 2048}) || member.user.defaultAvatarURL).setTitle(`Welcome to ${member.guild.name}, ${member.user.username}!`).setFooter({text: `${index}${suffix} member`})]})
|
(client.channels.resolve(client.config.dcServer.channels.welcome) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setThumbnail(member.user.displayAvatarURL({size: 2048}) || member.user.defaultAvatarURL).setTitle(`Welcome to ${member.guild.name}, ${member.user.username}!`).setFooter({text: `${index}${suffix} member`})]});
|
||||||
|
|
||||||
const newInvites = await member.guild.invites.fetch();
|
const newInvites = await member.guild.invites.fetch();
|
||||||
const usedInvite = newInvites.find((inv:Discord.Invite)=>client.invites.get(inv.code)?.uses < inv.uses);
|
const usedInvite = newInvites.find((inv:Discord.Invite)=>client.invites.get(inv.code)?.uses < inv.uses);
|
||||||
newInvites.forEach((inv:Discord.Invite)=>client.invites.set(inv.code,{uses: inv.uses, creator: inv.inviterId, channel: inv.channel.name}));
|
newInvites.forEach((inv:Discord.Invite)=>client.invites.set(inv.code,{uses: inv.uses, creator: inv.inviterId, channel: inv.channel.name}));
|
||||||
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [
|
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [
|
||||||
new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`${isBot} Joined: ${member.user.username}`).setDescription(`<@${member.user.id}>\n\`${member.user.id}\``).setFooter({text: `Total members: ${index}${suffix}`}).addFields(
|
new client.embed().setColor(client.config.embedColorGreen).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048})).setTitle(`${isBot} Joined: ${member.user.username}`).setFooter({text: `Total members: ${index}${suffix}`}).addFields(
|
||||||
{name: '🔹 Account Creation Date', value: `<t:${Math.round(member.user.createdTimestamp/1000)}>\n<t:${Math.round(member.user.createdTimestamp/1000)}:R>`},
|
{name: '🔹 Account Creation Date', value: `<t:${Math.round(member.user.createdTimestamp/1000)}>\n<t:${Math.round(member.user.createdTimestamp/1000)}:R>`},
|
||||||
{name: '🔹 Invite Data:', value: usedInvite ? `Invite: \`${usedInvite.code}\`\nCreated by: **${usedInvite.inviter?.username}**\nChannel: **#${usedInvite.channel.name}**` : 'No invite data could be fetched.'}
|
{name: '🔹 Invite Data:', value: usedInvite ? `Invite: \`${usedInvite.code}\`\nCreated by: **${usedInvite.inviter?.username}**\nChannel: **#${usedInvite.channel.name}**` : 'No invite data could be fetched.'}
|
||||||
)]});
|
)]});
|
||||||
|
@ -11,9 +11,8 @@ export default class GuildMemberRemove {
|
|||||||
let isBot = 'Bot';
|
let isBot = 'Bot';
|
||||||
if (!member.user.bot) isBot = 'Member';
|
if (!member.user.bot) isBot = 'Member';
|
||||||
const levelData = await client.userLevels.fetchUser(member.id);
|
const levelData = await client.userLevels.fetchUser(member.id);
|
||||||
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}) as string)
|
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setThumbnail(member.user.displayAvatarURL({size: 2048}))
|
||||||
.setTitle(`${isBot} Left: ${member.user.username}`).addFields(
|
.setTitle(`${isBot} Left: ${member.user.username}`).setFooter({text: `ID: ${member.user.id}`}).addFields(
|
||||||
{name: '🔹 User', value: `<@${member.user.id}>\n\`${member.user.id}\``},
|
|
||||||
{name: '🔹 Account Creation Date', value: `<t:${Math.round(member.user.createdTimestamp/1000)}>\n<t:${Math.round(member.user.createdTimestamp/1000)}:R>`},
|
{name: '🔹 Account Creation Date', value: `<t:${Math.round(member.user.createdTimestamp/1000)}>\n<t:${Math.round(member.user.createdTimestamp/1000)}:R>`},
|
||||||
{name: '🔹 Server Join Date', value: `<t:${Math.round(member.joinedTimestamp/1000)}>\n<t:${Math.round(member.joinedTimestamp/1000)}:R>`},
|
{name: '🔹 Server Join Date', value: `<t:${Math.round(member.joinedTimestamp/1000)}>\n<t:${Math.round(member.joinedTimestamp/1000)}:R>`},
|
||||||
{name: `🔹 Roles: ${member.roles.cache.size - 1}`, value: `${member.roles.cache.size > 1 ? member.roles.cache.filter((x)=>x.id !== member.guild.roles.everyone.id).sort((a,b)=>b.position - a.position).map(x=>x).join(member.roles.cache.size > 4 ? ' ' : '\n').slice(0,1024) : 'No roles'}`, inline: true}
|
{name: `🔹 Roles: ${member.roles.cache.size - 1}`, value: `${member.roles.cache.size > 1 ? member.roles.cache.filter((x)=>x.id !== member.guild.roles.everyone.id).sort((a,b)=>b.position - a.position).map(x=>x).join(member.roles.cache.size > 4 ? ' ' : '\n').slice(0,1024) : 'No roles'}`, inline: true}
|
||||||
|
@ -9,7 +9,7 @@ import MessageTool from '../helpers/MessageTool.js';
|
|||||||
export default class MessageCreate {
|
export default class MessageCreate {
|
||||||
static async run(client:TClient, message:Discord.Message) {
|
static async run(client:TClient, message:Discord.Message) {
|
||||||
if (message.author.bot) return;
|
if (message.author.bot) return;
|
||||||
if (!message.inGuild()) return (client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({content: `<:fish_unamused:1083675172407623711> ${MessageTool.formatMention(client.config.whitelist[0], 'user')}\n**${message.author.username}** (\`${message.author.id}\`) tried to send me a DM, their message is:\`\`\`${message.content}\`\`\``, allowedMentions: {parse: ['users']}});
|
if (!message.inGuild()) return (client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({content: `${this.randomEmotes[Math.floor(Math.random()*this.randomEmotes.length)]} ${MessageTool.formatMention(client.config.whitelist[0], 'user')}\n**${message.author.username}** (\`${message.author.id}\`) sent me a DM, their message is:\`\`\`${message.content}\`\`\``, allowedMentions: {parse: ['users']}});
|
||||||
let automodded: boolean;
|
let automodded: boolean;
|
||||||
|
|
||||||
if (client.config.botSwitches.automod && !message.member.roles.cache.has(client.config.dcServer.roles.dcmod) && !message.member.roles.cache.has(client.config.dcServer.roles.admin) && message.guildId === client.config.dcServer.id) {
|
if (client.config.botSwitches.automod && !message.member.roles.cache.has(client.config.dcServer.roles.dcmod) && !message.member.roles.cache.has(client.config.dcServer.roles.admin) && message.guildId === client.config.dcServer.id) {
|
||||||
@ -39,13 +39,6 @@ export default class MessageCreate {
|
|||||||
imageOnly: {
|
imageOnly: {
|
||||||
check: ()=>!MessageTool.isStaff(message.member as Discord.GuildMember),
|
check: ()=>!MessageTool.isStaff(message.member as Discord.GuildMember),
|
||||||
action: async()=>await Automoderator.imageOnly(message)
|
action: async()=>await Automoderator.imageOnly(message)
|
||||||
},
|
|
||||||
crosspost: {
|
|
||||||
check: ()=>!MessageTool.isStaff(message.member as Discord.GuildMember) && message.content.toLowerCase(),
|
|
||||||
action: async()=>{
|
|
||||||
automodded = true;
|
|
||||||
await Automoderator.crosspostSpam(client, message, 'Crosspost spam');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -124,4 +117,13 @@ export default class MessageCreate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static randomEmotes = [
|
||||||
|
'<:_:1083675172407623711>', '<:_:1201440990473506857>',
|
||||||
|
'<:_:1083675175163277383>', '<:_:1083675149347340391>',
|
||||||
|
'<:_:1139410139653353533>', '<:_:1083675155504574487>',
|
||||||
|
'<:_:1201441007271690340>', '<:_:1060388693166264380>',
|
||||||
|
'<:_:1084392085047758930>', '<:_:1159495459082092655>',
|
||||||
|
'<a:_:1016297208292851762>', '<a:_:1016297221911740466>',
|
||||||
|
'<a:_:1094804583370457268>'
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ export default class MessageDelete {
|
|||||||
if (!client.config.botSwitches.logs) return;
|
if (!client.config.botSwitches.logs) return;
|
||||||
if (msg.guild?.id != client.config.dcServer.id || msg.partial || msg.author.bot || disabledChannels.includes(msg.channelId)) return;
|
if (msg.guild?.id != client.config.dcServer.id || msg.partial || msg.author.bot || disabledChannels.includes(msg.channelId)) return;
|
||||||
if (Discord.DiscordAPIError.name === '10008') return Logger.console('log', 'MsgDelete', 'Caught an unexpected error returned by Discord API. (Unknown Message)');
|
if (Discord.DiscordAPIError.name === '10008') return Logger.console('log', 'MsgDelete', 'Caught an unexpected error returned by Discord API. (Unknown Message)');
|
||||||
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${msg.author.username} (${msg.author.id})`, iconURL: `${msg.author.displayAvatarURL()}`}).setTitle('Message deleted').setDescription(`<@${msg.author.id}>\n\`${msg.author.id}\``);
|
const embed = new client.embed().setColor(client.config.embedColorRed).setTimestamp().setAuthor({name: `Author: ${msg.author.username} (${msg.author.id})`, iconURL: `${msg.author.displayAvatarURL()}`}).setTitle('Message deleted');
|
||||||
if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${Discord.escapeCodeBlock(msg.content.slice(0,1000))}\n\`\`\``});
|
if (msg.content.length != 0) embed.addFields({name: 'Content', value: `\`\`\`\n${Discord.escapeCodeBlock(msg.content.slice(0,1000))}\n\`\`\``});
|
||||||
embed.addFields(
|
embed.addFields(
|
||||||
{name: 'Channel', value: `<#${msg.channelId}>`},
|
{name: 'Channel', value: `<#${msg.channelId}>`},
|
||||||
|
@ -9,7 +9,7 @@ export default class MessageUpdate {
|
|||||||
if (await client.prohibitedWords.findWord(newMsg.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b/g, '').split(' ').join('')) && (!MessageTool.isStaff(newMsg.member))) newMsg.delete();
|
if (await client.prohibitedWords.findWord(newMsg.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n?0-9]|[]|ing\b/g, '').split(' ').join('')) && (!MessageTool.isStaff(newMsg.member))) newMsg.delete();
|
||||||
if (!rawSwitches.MESSAGE_UPDATE || (rawSwitches.MESSAGE_UPDATE && newMsg.content !== oldMsg.content)) {
|
if (!rawSwitches.MESSAGE_UPDATE || (rawSwitches.MESSAGE_UPDATE && newMsg.content !== oldMsg.content)) {
|
||||||
rawSwitches.MESSAGE_UPDATE = true;
|
rawSwitches.MESSAGE_UPDATE = true;
|
||||||
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.username} (${oldMsg.author.id})`, iconURL: oldMsg.author.displayAvatarURL()}).setTitle('Message edited').setDescription(`<@${oldMsg.author.id}>\n\`${oldMsg.author.id}\``).addFields({name: 'Old content', value: `\`\`\`${oldMsg.content.length < 1 ? '(Attachment)' : Discord.escapeCodeBlock(oldMsg.content.slice(0,2048))}\`\`\``}, {name: 'New content', value: `\`\`\`${Discord.escapeCodeBlock(newMsg.content.slice(0,2048))}\`\`\``}, {name: 'Channel', value: `<#${oldMsg.channelId}>`})], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(oldMsg.url).setLabel('Jump to message'))]});
|
(client.channels.resolve(client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.username} (${oldMsg.author.id})`, iconURL: oldMsg.author.displayAvatarURL()}).setTitle('Message edited').addFields({name: 'Old content', value: `\`\`\`${oldMsg.content.length < 1 ? '(Attachment)' : Discord.escapeCodeBlock(oldMsg.content.slice(0,2048))}\`\`\``}, {name: 'New content', value: `\`\`\`${Discord.escapeCodeBlock(newMsg.content.slice(0,2048))}\`\`\``}, {name: 'Channel', value: `<#${oldMsg.channelId}>`})], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(oldMsg.url).setLabel('Jump to message'))]});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,15 +19,14 @@ export default class Ready {
|
|||||||
}, 300000)
|
}, 300000)
|
||||||
})
|
})
|
||||||
if (client.config.botSwitches.registerCommands) {
|
if (client.config.botSwitches.registerCommands) {
|
||||||
console.log('Total commands: '+client.registry.length) //Debugging reasons.
|
|
||||||
client.config.whitelistedServers.forEach(guildId=>(client.guilds.cache.get(guildId) as Discord.Guild).commands.set(client.registry).catch((e:Error)=>{
|
client.config.whitelistedServers.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.dcServer.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.dcServer.channels.errors) as Discord.TextChannel).send(`Cannot register slash commands for **${client.guilds.cache.get(guildId).name}** (\`${guildId}\`):\n\`\`\`${e.message}\`\`\``)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
console.log(`${client.user.username} has logged into Discord API`);
|
console.log(`Ready as ${client.user.tag}`);
|
||||||
console.log(client.config.botSwitches, client.config.whitelistedServers);
|
console.log(client.config.botSwitches, client.config.whitelistedServers);
|
||||||
(client.channels.resolve(client.config.dcServer.channels.bot_status) as Discord.TextChannel).send({content: `**${client.user.username}** is active`, embeds:[new client.embed().setColor(client.config.embedColor).setDescription(`**\`\`\`ansi\n${botSwitches}\n\`\`\`**`)]});
|
(client.channels.resolve(client.config.dcServer.channels.bot_status) as Discord.TextChannel).send({embeds:[new client.embed().setColor(client.config.embedColor).setDescription(`**\`\`\`ansi\n${botSwitches}\n\`\`\`**`)]});
|
||||||
console.timeEnd('Startup')
|
console.timeEnd('Startup')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,9 +115,8 @@ client.on('raw', async (packet:RawGatewayPacket<RawMessageDelete>)=>{
|
|||||||
embeds: [new client.embed()
|
embeds: [new client.embed()
|
||||||
.setColor(client.config.embedColorRed)
|
.setColor(client.config.embedColorRed)
|
||||||
.setTitle('Message deleted')
|
.setTitle('Message deleted')
|
||||||
.setDescription('Unknown author')
|
|
||||||
.addFields(
|
.addFields(
|
||||||
{name: 'Received over raw API gateway', value: '\u200b'},
|
{name: 'This was received over raw API event', value: '\u200b'},
|
||||||
{name: 'Channel', value: `<#${packet.d.channel_id}>`},
|
{name: 'Channel', value: `<#${packet.d.channel_id}>`},
|
||||||
).setTimestamp()
|
).setTimestamp()
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user