This repository was archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
98 lines (77 loc) · 2.82 KB
/
Copy pathbot.js
File metadata and controls
98 lines (77 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const config = require("./config.json");
const token = require("./token.json");
const { Client, APIMessage,Intents } = require("discord.js");
const { readdirSync } = require("fs");
const Commands = [];
const Discord = require("discord.js");
const fs = require("fs");
var intent = Intents.resolve(4095);
const bot = new Client({ intents: [intent] });
bot.commands = new Discord.Collection();
const { MessageActionRow, MessageButton } = require('discord.js');
const { DiscordTogether } = require('discord-together');
const buttons = require("./buttons");
bot.discordTogether = new DiscordTogether(bot);
fs.readdir("./commands/", (err, files) => {
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js")
if(jsfile.length <= 0){
console.log("Couldn't find commands.");
return;
}
jsfile.forEach((f, i) =>{
let props = require(`./commands/${f}`);
console.log(`${f} loaded!`);
bot.commands.set(props.help.name, props);
});
});
var client = bot;
bot.on('interactionCreate', async interaction => {
if (interaction.isMessageComponent() && interaction.componentType == 'BUTTON')
{
await buttons.buttonresponce(bot,interaction);
}
else
{
return;
}
});
//Add Role And Welcome New Member
bot.on('guildMemberAdd', member => {
});
bot.on("guildCreate", guild => {
console.log("Joined a new guild: " + guild.name);
bot.user.setActivity("with b>help on " + bot.guilds.cache.size + " servers with " + bot.users.cache.size + " users in total", {type: "PLAYING"});
//Your other stuff like adding to guildArray
})
//removed from a server
bot.on("guildDelete", guild => {
console.log("Left a guild: " + guild.name);
bot.user.setActivity("with b>help on " + bot.guilds.cache.size + " servers with " + bot.users.cache.size + " users in total", {type: "PLAYING"});
//remove from guildArray
})
//Playing Message
bot.on("ready", async () => {
console.log(`${bot.user.username} is online on ${bot.guilds.cache.size} servers!`);
bot.user.setActivity("with b>help on " + bot.guilds.cache.size + " servers with " + bot.users.cache.size + " users in total", {type: "PLAYING"});
});
//Command Manager
bot.on("messageCreate", async message => {
console.log(`${message.author.username}(${message.author.id})/${message.id}: ${message.content}`);
try{
let prefix = config.prefix;
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
//Check for prefix
if(cmd.startsWith(config.prefix) && !message.author.bot && message.channel.type != "dm"){
let commandfile = bot.commands.get(cmd.slice(prefix.length));
if(commandfile) commandfile.run(bot,message,args);
}
}
catch(e){
message.channel.send(`<@${message.author.id}> Error ${e}!`)
}
});
//Token need in token.json
bot.login(token.token);