-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update messageCreate, guildCreate and guildDelete to new handling method
- Loading branch information
Showing
7 changed files
with
144 additions
and
120 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { EmbedBuilder, Events } = require("discord.js"); | ||
const schema = require("../Schemas/base-system.js"); | ||
|
||
module.exports = { | ||
name: Events.GuildCreate, | ||
async execute(guild, client) { | ||
const data = await schema.findOne({ | ||
Guild: guild.id, | ||
ID: "audit-logs", | ||
}); | ||
|
||
if (data) { | ||
const channel = await client.channels.cache.get(data.Channel); | ||
if (!data.Channel || !channel) return; | ||
const owner = await client.users.cache.get(guild.ownerId); | ||
|
||
const embed = new EmbedBuilder() | ||
.setColor("Green") | ||
.setTitle("FKZ Bot has joined a new server.") | ||
.addFields([ | ||
{ | ||
name: "Server", | ||
value: `> ${guild.name}`, | ||
}, | ||
{ | ||
name: "Server Membercount", | ||
value: `> ${guild.memberCount}`, | ||
}, | ||
{ | ||
name: "Server Owner", | ||
value: `> ${owner.username} / ${guild.ownerId}`, | ||
}, | ||
{ | ||
name: "Server Age", | ||
value: `> <t:${parseInt(guild.createdTimestamp / 1000)}:R>`, | ||
}, | ||
]) | ||
.setTimestamp() | ||
.setFooter({ text: `Guild Joined - ${guild.id}` }); | ||
|
||
try { | ||
await channel.send({ embeds: [embed] }); | ||
} catch (error) { | ||
console.error("Error in GuildCreate event:", error); | ||
} | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const { EmbedBuilder, Events } = require("discord.js"); | ||
const schema = require("../Schemas/base-system.js"); | ||
|
||
module.exports = { | ||
name: Events.GuildDelete, | ||
async execute(guild, client) { | ||
const data = await schema.findOne({ | ||
Guild: guild.id, | ||
ID: "audit-logs", | ||
}); | ||
|
||
if (data) { | ||
const channel = await client.channels.cache.get(data.Channel); | ||
if (!data.Channel || !channel) return; | ||
const owner = await client.users.cache.get(guild.ownerId); | ||
|
||
const embed = new EmbedBuilder() | ||
.setColor("Red") | ||
.setTitle("FKZ Bot has left a server.") | ||
.addFields([ | ||
{ | ||
name: "Server", | ||
value: `> ${guild.name}`, | ||
}, | ||
{ | ||
name: "Server Membercount", | ||
value: `> ${guild.memberCount}`, | ||
}, | ||
{ | ||
name: "Server Owner", | ||
value: `> ${owner.username} / ${guild.ownerId}`, | ||
}, | ||
{ | ||
name: "Server Age", | ||
value: `> <t:${parseInt(guild.createdTimestamp / 1000)}:R>`, | ||
}, | ||
]) | ||
.setTimestamp() | ||
.setFooter({ text: `Guild Left - ${guild.id}` }); | ||
try { | ||
await channel.send({ embeds: [embed] }); | ||
} catch (error) { | ||
console.error("Error in GuildDelete event:", error); | ||
} | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const { Events } = require("discord.js"); | ||
//const schema = require("../Schemas/base-system.js"); | ||
//const settings = require("../Schemas/logger/settings.js"); | ||
const antiLink = require("../Schemas/moderation/anti-link.js"); | ||
//const schema = require("../Schemas/moderation/anti-spam.js"); | ||
|
||
module.exports = { | ||
name: Events.MessageCreate, | ||
async execute(message, client) { | ||
if ( | ||
!message || | ||
!message.guild || | ||
!message.author || | ||
message.system || | ||
message.webhookId || | ||
!client | ||
) { | ||
return; | ||
} | ||
|
||
const antiLinkData = await antiLink.findOne({ | ||
Guild: message.guild.id, | ||
}); | ||
if (antiLinkData) { | ||
if ( | ||
message.content.includes("http") || | ||
message.content.includes("https") || | ||
message.content.includes("gg/") | ||
) { | ||
try { | ||
const member = await message.guild.members.cache.get( | ||
message.author.id | ||
); | ||
if (member && member.permissions.has(data.Perms)) { | ||
return; | ||
} else if (member) { | ||
const msg = await message.channel.send( | ||
`${message.author}, you can't send links here!` | ||
); | ||
setTimeout(() => msg.delete(), 3000); | ||
await message.delete(); | ||
} | ||
} catch (error) { | ||
console.error(`Error in messageCreate event:\n${error}`); | ||
} | ||
} | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters