-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
135 lines (116 loc) · 4.51 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
128
129
130
131
132
133
134
135
const fs = require('fs');
//const { REST } = require('@discordjs/rest');
//const { Routes } = require('discord-api-types/v9');
const Discord = require('discord.js');
const { REST, Routes, PermissionsBitField, Events } = require('discord.js');
const utilities = require('./utilities');
require("dotenv").config();
const CHANNEL_SONDAGE = "522437669582667787";
const repostReactionNumber = 5;
const { Client, GatewayIntentBits } = require('discord.js');
const myIntents = [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildIntegrations,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildMessageTyping,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.DirectMessageTyping,
GatewayIntentBits.MessageContent
]
const client = new Client({intents: myIntents, allowedMentions: { parse: ['users', 'roles'], repliedUser: true} });
//commandes slash
client.commands = new Discord.Collection();
const clientId = process.env.CLIENT_ID;
const guildId = process.env.GUILD_ID;
const slashCommandFolders = fs.readdirSync('./slash');
let slashCommands = [];
for (const folder of slashCommandFolders) {
const slashCommandFiles = fs.readdirSync(`./slash/${folder}`).filter(file => file.endsWith('.js'));
for (const file of slashCommandFiles) {
const slashCommand = require(`./slash/${folder}/${file}`);
if ('data' in slashCommand && 'execute' in slashCommand) {
client.commands.set(slashCommand.data.name, slashCommand)
slashCommands.push(slashCommand.data.toJSON());
} else {
console.warn(`Slash command ${file} is missing data or execute function`);
}
}
}
const rest = new REST().setToken(process.env.BOT_TOKEN);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
if(process.env.DEV_ENV == "TRUE"){
await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: slashCommands },
);
} else {
await rest.put(
Routes.applicationCommands(clientId),
{ body: slashCommands },
);
}
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
//gestion des events
client.once('ready', () => {
console.log('Ready!');
client.user.setActivity('Me voila tout neuf');
});
//spéciale dédi au bans qui ont des potes dans la moderation <3
client.on("guildBanRemove", function(guild, user){
console.log(user.id);
if(["334321322232381440","332153457005953025"].includes(user.id)){
console.log("ça a tenté d'unban quelqu'un qui ne doit pas l'etre, olalala");
guild.members.ban(user);
}
});
// this code is executed every time they add a reaction
client.on(Events.MessageReactionAdd, async (reaction, user) => {
var member = user.client.guilds.cache.get(reaction.message.guild.id).members.cache.get(user.id);
if (reaction.emoji.name === '🚩' && reaction.count >= 1 && member.roles.cache.some(role => role.id == utilities.roleMod ) ) {
utilities.warn(reaction.message,member);
}
if (reaction.emoji.name == '♻️' && reaction.count >= repostReactionNumber && reaction.message.channel == utilities.salonMeme && !reaction.message.author.bot && reaction.message.author.id != "352459053928022017") {
reaction.message.channel.send("le repost hammer est tombé sur " + reaction.message.author.username + " *bonk*")
await utilities.warn(reaction.message,null);
await reaction.message.delete();
}
});
// listener pour sondage
client.on('messageCreate', message => {
if (message.channel.id == salonSondage) {
let command = client.commands.get("sondage");
command.newSondage(message);
}
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
if (interaction.commandName === "kill" && interaction.user.has(PermissionsBitField.Flags.Administrator)){
interaction.reply( '<@' + interaction.user.id + '> a detruit le bot !');
client.destroy();
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
return interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
});
client.login(process.env.BOT_TOKEN);