mirror of https://github.com/kry008/Bot-2.0.git
Mod functions
parent
aedaec1961
commit
d5515ff8c1
|
@ -2,3 +2,4 @@ config.json
|
||||||
templates.file
|
templates.file
|
||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
guilds-*.txt
|
|
@ -1,3 +1,4 @@
|
||||||
|
const { EmbedBuilder } = require('discord.js');
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'supportbot',
|
name: 'supportbot',
|
||||||
description: 'How to support bot development?',
|
description: 'How to support bot development?',
|
||||||
|
|
|
@ -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`);
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,9 +1,13 @@
|
||||||
const { Events } = require('discord.js');
|
const { Events } = require('discord.js');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: Events.GuildCreate,
|
name: Events.GuildCreate,
|
||||||
once: false,
|
once: false,
|
||||||
execute(guild) {
|
execute(guild) {
|
||||||
console.log(`Joined guild ${guild.name}`);
|
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`);
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -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] });
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
6
index.js
6
index.js
|
@ -26,7 +26,11 @@ const client = new Client({
|
||||||
GatewayIntentBits.GuildMessageTyping,
|
GatewayIntentBits.GuildMessageTyping,
|
||||||
GatewayIntentBits.DirectMessages,
|
GatewayIntentBits.DirectMessages,
|
||||||
GatewayIntentBits.DirectMessageReactions,
|
GatewayIntentBits.DirectMessageReactions,
|
||||||
GatewayIntentBits.DirectMessageTyping
|
GatewayIntentBits.DirectMessageTyping,
|
||||||
|
GatewayIntentBits.GuildModeration,
|
||||||
|
GatewayIntentBits.GuildInvites,
|
||||||
|
GatewayIntentBits.GuildPresences,
|
||||||
|
GatewayIntentBits.GuildIntegrations
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"watch": ["commands", "deploy-commands.js", "index.js"],
|
"watch": ["commands", "events", "deploy-commands.js", "index.js"],
|
||||||
"execMap": {
|
"execMap": {
|
||||||
"js": "node"
|
"js": "node"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue