BOT
This commit is contained in:
commit
7bd3661eb5
57
Bot.js
Normal file
57
Bot.js
Normal file
@ -0,0 +1,57 @@
|
||||
const { Client, GatewayIntentBits, AttachmentBuilder } = require('discord.js');
|
||||
const { token } = require('./config.json');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.MessageContent // Assurez-vous d'avoir cet intent pour accéder au contenu du message
|
||||
]
|
||||
});
|
||||
|
||||
client.once('ready', () => {
|
||||
console.log('Ready!');
|
||||
});
|
||||
|
||||
client.on('messageCreate', async message => {
|
||||
// Ignore les messages envoyés par le bot
|
||||
if (message.author.bot) return;
|
||||
|
||||
// Vérifie si le message contient "UwU" ou "uwu"
|
||||
if (message.content.includes("UwU") || message.content.includes("uwu")) {
|
||||
const user = message.author;
|
||||
const avatarUrl = user.displayAvatarURL({extension: 'png', size: 1024});
|
||||
|
||||
const canvas = createCanvas(1024, 1024);
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
// Charger l'image du buste
|
||||
const bust = await loadImage('./DONTUWU.png');
|
||||
ctx.drawImage(bust, 0, 0, canvas.width, canvas.height);
|
||||
|
||||
// Coordonnées et taille pour l'avatar
|
||||
const avatarX = 312; // Remplacer par la position X réelle
|
||||
const avatarY = 305; // Remplacer par la position Y réelle
|
||||
const avatarSize = 350; // Remplacer par la taille désirée de l'avatar
|
||||
|
||||
// Charger l'avatar
|
||||
const avatar = await loadImage(avatarUrl);
|
||||
|
||||
// Dessiner un cercle où l'avatar sera affiché
|
||||
ctx.beginPath();
|
||||
ctx.arc(avatarX + avatarSize / 2, avatarY + avatarSize / 2, avatarSize / 2, 0, Math.PI * 2, true);
|
||||
ctx.closePath();
|
||||
ctx.clip();
|
||||
|
||||
// Dessiner l'avatar dans le cercle
|
||||
ctx.drawImage(avatar, avatarX, avatarY, avatarSize, avatarSize);
|
||||
|
||||
const attachment = new AttachmentBuilder(canvas.toBuffer(), {name: 'profil-buste.png'});
|
||||
|
||||
// Envoyer l'image en réponse
|
||||
await message.reply({content:'Hop prison',files: [attachment]});
|
||||
}
|
||||
});
|
||||
|
||||
client.login(token);
|
BIN
DONTUWU.png
Normal file
BIN
DONTUWU.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
5
config.json
Normal file
5
config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"token": "XXX",
|
||||
"clientId": "XXX",
|
||||
"guildId": "XXX"
|
||||
}
|
27
registerCommands.js
Normal file
27
registerCommands.js
Normal file
@ -0,0 +1,27 @@
|
||||
const { REST } = require('@discordjs/rest');
|
||||
const { Routes } = require('discord-api-types/v9');
|
||||
const { clientId, guildId, token } = require('./config.json');
|
||||
|
||||
const commands = [
|
||||
{
|
||||
name: 'bustme',
|
||||
description: 'Affiche votre avatar sur une image de buste',
|
||||
}
|
||||
];
|
||||
|
||||
const rest = new REST({ version: '9' }).setToken(token);
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Started refreshing application (/) commands.');
|
||||
|
||||
await rest.put(
|
||||
Routes.applicationGuildCommands(clientId, guildId),
|
||||
{ body: commands },
|
||||
);
|
||||
|
||||
console.log('Successfully reloaded application (/) commands.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
Loading…
Reference in New Issue
Block a user