-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
127 lines (104 loc) · 3.04 KB
/
index.js
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
const fs = require("fs");
// Bot File
module.exports =
fs.writeFileSync("bot.js",
`
// Perms
const Discord = require("discord.js");
const http = require("http");
const { EmbedBuilder, PermissionBitFlags } = require("@discordjs/builders");
const env = require("dotenv").config();
// Server
const server = http.createServer((req, res) => {
res.write("Your Bot Hoster");
});
server.listen();
// Client-Setup
const client = new Discord.Client(
{
partials: [
Discord.Partials.Channel,
Discord.Partials.GuildMember,
Discord.Partials.Message,
Discord.Partials.Reaction,
Discord.Partials.ThreadMember,
Discord.Partials.GuildScheduledEvent
],
intents: [
Discord.GatewayIntentBits.Guilds,
Discord.GatewayIntentBits.DirectMessages,
Discord.GatewayIntentBits.GuildEmojisAndStickers,
Discord.GatewayIntentBits.GuildIntegrations,
Discord.GatewayIntentBits.GuildInvites,
Discord.GatewayIntentBits.GuildMembers,
Discord.GatewayIntentBits.GuildMessages,
Discord.GatewayIntentBits.GuildMessageReactions,
Discord.GatewayIntentBits.MessageContent,
Discord.IntentsBitField.Flags.Guilds,
Discord.IntentsBitField.Flags.DirectMessages,
Discord.IntentsBitField.Flags.GuildEmojisAndStickers,
Discord.IntentsBitField.Flags.GuildInvites,
Discord.IntentsBitField.Flags.GuildMembers,
Discord.IntentsBitField.Flags.GuildMessages,
Discord.IntentsBitField.Flags.MessageContent
]
}
);
// Client-Start
client.on("ready", function(){
console.log("Bot starting!");
console.log("Logged in!");
console.log("Bot started");
});
// Client-Reconnect
client.on("shardReconnecting", function(){
console.log("Trying to reconnect to the websocket");
});
// Client-Reconnected
client.on("shardResume", function(){
console.log("Der Bot hat sich wieder verbunden!")
});
// Client-Warning
client.on("warn", function(info){
console.log(info);
});
// Client-Disconnect
client.on("shardDisconnect", function(event){
console.log("The bot disconnected and won't reconnect itself");
});
// Client-Error
client.on("error", function(error){
console.error(error);
});
// Client-Login
client.login(process.env["TOKEN"]);
`);
// Commands File
module.exports =
fs.writeFileSync("commands.js",
`
// Perms
const dotenv = require("dotenv").config();
const token = process.env["TOKEN"];
const clientId= process.env["CLIENT_ID"];
const { REST, SlashCommandBuilder, Routes, PermissionFlagsBits } = require('discord.js');
// Commands
const commands = [
].map(command => command.toJSON());
const rest = new REST(
{
version: '10'
}
).setToken(token);
rest.put(
Routes.applicationCommands(clientId), {
body: commands
})
.then((data) => console.log("Commands saved: " + data.length))
.catch(console.error);
`);
// ENV File
module.exports =
fs.writeFileSync(".env",
`TOKEN=
CLIENT_ID=`)