Mod functions

main
kry008 2024-06-15 18:52:42 +02:00
parent aedaec1961
commit d5515ff8c1
7 changed files with 55 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
config.json
templates.file
node_modules
package-lock.json
package-lock.json
guilds-*.txt

View File

@ -1,3 +1,4 @@
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: 'supportbot',
description: 'How to support bot development?',

View File

@ -0,0 +1,14 @@
const { Events } = require('discord.js');
const fs = require('fs');
module.exports = {
name: Events.GuildDelete,
once: false,
execute(args) {
console.log(`Left guild ${args.name}`);
//guilds-YYYY-MM.txt
const guildPath = `./guilds-${new Date().toISOString().split('T')[0]}.txt`;
//save name - id - time of leaving
fs.appendFileSync(guildPath, `LEAVE: \`${args.name}\` - ${args.id} - ${new Date().toLocaleString()}\n`);
}
};

View File

@ -1,9 +1,13 @@
const { Events } = require('discord.js');
const fs = require('fs');
module.exports = {
name: Events.GuildCreate,
once: false,
execute(guild) {
console.log(`Joined guild ${guild.name}`);
const guildPath = `./guilds-${new Date().toISOString().split('T')[0]}.txt`;
//save name - id - time of joining
fs.appendFileSync(guildPath, `JOIN: \`${guild.name}\` - ${guild.id} - ${new Date().toLocaleString()}\n`);
}
};

View File

@ -0,0 +1,28 @@
const { Events, EmbedBuilder } = require('discord.js');
function randomColor() {
const r = Math.floor(Math.random() * 200) + 50;
const g = Math.floor(Math.random() * 200) + 50;
const b = Math.floor(Math.random() * 200) + 50;
return `#${r.toString(16)}${g.toString(16)}${b.toString(16)}`;
}
module.exports = {
name: Events.GuildMemberAdd,
once: false,
execute(args) {
const { guild, user } = args;
const channel = guild.channels.cache.find(channel => ['new-member', 'new-users', 'hello', 'welcome'].includes(channel.name));
//find rules channel
const rulesChannel = guild.channels.cache.find(channel => ['rules', 'regulations', 'regulamin'].includes(channel.name));
if (!channel) return;
if(!rulesChannel) var text = 'Please read the rules in rules channel.';
else var text = `Please read the rules in ${rulesChannel} channel.`;
const embed = new EmbedBuilder()
.setTitle(`Welcome ${user.username}!`)
.setDescription(`Welcome to ${guild.name}! \n${text}`)
.setColor(randomColor())
.setThumbnail(user.avatarURL())
.setTimestamp();
channel.send({ embeds: [embed] });
}
};

View File

@ -26,7 +26,11 @@ const client = new Client({
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessageTyping
GatewayIntentBits.DirectMessageTyping,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildIntegrations
]
});

View File

@ -1,5 +1,5 @@
{
"watch": ["commands", "deploy-commands.js", "index.js"],
"watch": ["commands", "events", "deploy-commands.js", "index.js"],
"execMap": {
"js": "node"
},