Skip to content
Snippets Groups Projects
Commit b6594eb8 authored by Sofiane Lasri's avatar Sofiane Lasri
Browse files

heu?

parent bf7bf841
Branches
No related tags found
No related merge requests found
......@@ -281,7 +281,7 @@ const { verify } = require('crypto');
// create a new Discord client
const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES", "DIRECT_MESSAGES", "GUILD_MEMBERS"] });
var mcChatWebhook, devMcChatWebhook;
var mcChatWebhook;
client.on("ready", async function () {
console.log('\n' + "SL-Projects Bot".brightCyan);
......@@ -625,41 +625,15 @@ async function createMcChatWebhook() {
console.log("[" + 'INFO'.yellow + "] Le Webhook du serveur MC a été configuré avec succès.");
})
.catch(console.error);
// Dev
client.channels.cache.get(config.get("CANAL_CHAT_MC_DEV")).createWebhook('Chat Serveur Minecraft Dev', {
avatar: 'https://sl-craft.fr/data/images/logo/short-color.png',
})
.then(webhook => {
botSettings.create({
name: "devMcChatWebhookId",
value: webhook.id
});
botSettings.create({
name: "devMcChatWebhookToken",
value: webhook.token
});
devMcChatWebhook = new WebhookClient({ id: devMcChatWebhookId.value, token: devMcChatWebhookToken.value });
console.log("[" + 'INFO'.yellow + "] Le Webhook du serveur MC Dev a été configuré avec succès.");
})
.catch(console.error);
}
function sendMessageFromMcChat(username, message, serverType) {
function sendMessageFromMcChat(username, message) {
if(username == "SL-Craft"){
if(serverType == "dev"){
devMcChatWebhook.send({
content: message,
username: username,
avatarURL: 'https://sl-craft.fr/data/images/logo/favicon-color.png',
});
}else{
mcChatWebhook.send({
content: message,
username: username,
avatarURL: 'https://sl-craft.fr/data/images/logo/favicon-color.png',
});
}
}else{
// On va vérifier que le joueur ne fait pas de @everyone ou de @here
message = message.replace("<@everyone>", "**everyone**");
......@@ -681,21 +655,12 @@ function sendMessageFromMcChat(username, message, serverType) {
}
}
if(serverType == "dev"){
devMcChatWebhook.send({
content: message,
username: username,
avatarURL: 'https://live.mc.sl-projects.com/tiles/faces/32x32/' + username + '.png',
});
}else{
mcChatWebhook.send({
content: message,
username: username,
avatarURL: 'https://live.mc.sl-projects.com/tiles/faces/32x32/' + username + '.png',
});
}
}
}
......@@ -723,7 +688,7 @@ app.get('/channels/:id', (req, res) => {
})
app.get('/mc/chat/:detail', (req, res) => {
var detail = JSON.parse(decodeURI(req.params.detail));
sendMessageFromMcChat(detail.username, detail.message, req.headers.serverType);
sendMessageFromMcChat(detail.username, detail.message);
res.send("Envoyé!")
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment