mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
9bd39c69ca
sinon il y a pleins de truc comme les anti raid , des coorectif ect
161 lines
5.0 KiB
JavaScript
161 lines
5.0 KiB
JavaScript
const { EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder, ActivityType } = require("discord.js");
|
|
const sqlite3 = require('sqlite3').verbose();
|
|
const db = new sqlite3.Database('myDatabase.db');
|
|
module.exports = {
|
|
name: 'setactivity',
|
|
description: 'Changer la présence du bot',
|
|
emote: '🎮',
|
|
utilisation: '',
|
|
permission: '8',
|
|
utilisation: 'setactivity',
|
|
category: 'botcontrol',
|
|
async execute(message, args, client) {
|
|
const author = message.author;
|
|
|
|
let currentActivitie = client.user.presence.activities[0] || "aucun status";
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setTitle('Changement d\'activité')
|
|
.setDescription(`Le bot est en mode :\`${currentActivitie}\``)
|
|
.setTimestamp()
|
|
.setFooter({text: `${client.user.tag} © 2024`, iconURL: client.user.displayAvatarURL()});
|
|
|
|
if (!currentActivitie) {
|
|
embed.setColor('#000000');
|
|
} else if (currentActivitie.name === 'playing') {
|
|
embed.setColor('#FF0000');
|
|
} else if (currentActivitie.name === 'streaming') {
|
|
embed.setColor('#FFA500');
|
|
} else if (currentActivitie.name === 'listening') {
|
|
embed.setColor('#00FF00');
|
|
} else if (currentActivitie.name === 'watching') {
|
|
embed.setColor('#000000');
|
|
}
|
|
|
|
const selectMenu = new StringSelectMenuBuilder()
|
|
.setCustomId('activity')
|
|
.setPlaceholder('Changer l\'activité')
|
|
.addOptions([
|
|
{
|
|
label: 'Joue',
|
|
value: 'playing',
|
|
description: 'Le bot joue',
|
|
emoji: '🎮'
|
|
},
|
|
{
|
|
label: 'Stream',
|
|
value: 'streaming',
|
|
description: 'Le bot stream',
|
|
emoji: '📺'
|
|
},
|
|
{
|
|
label: 'Écoute',
|
|
value: 'listening',
|
|
description: 'Le bot écoute',
|
|
emoji: '🎵'
|
|
},
|
|
{
|
|
label: 'Regarde',
|
|
value: 'watching',
|
|
description: 'Le bot regarde',
|
|
emoji: '👀'
|
|
},
|
|
{
|
|
label: 'Competition',
|
|
value: 'competing',
|
|
description: 'Le bot participe à',
|
|
emoji: '🕹️'
|
|
}
|
|
]);
|
|
|
|
const row = new ActionRowBuilder()
|
|
.addComponents(selectMenu)
|
|
|
|
const sendMessage = await message.reply({ embeds: [embed], components: [row] });
|
|
|
|
let filter = (interaction) => interaction.user.id === message.author.id;
|
|
const collector = sendMessage.createMessageComponentCollector({ filter, time: 60000 });
|
|
collector.on('collect', async (interaction) => {
|
|
if (interaction.isStringSelectMenu()) {
|
|
const value = interaction.values[0];
|
|
|
|
interaction.reply(`Veuillez entrer le message que vous voulez afficher pour l'activité ${value}`);
|
|
filter = (message) => message.author.id === author.id;
|
|
const messageCollector = message.channel.createMessageCollector({ filter , max: 1 , time: 60000 });
|
|
messageCollector.on('collect', async (messageCollect) => {
|
|
const text = messageCollect.content;
|
|
const url = 'https://www.twitch.tv/valou336_ytb';
|
|
|
|
if (!client.user) return;
|
|
let type, status;
|
|
if (value === 'playing') {
|
|
client.user.setPresence({
|
|
activities: [{
|
|
name: text,
|
|
type: ActivityType.Playing,
|
|
url: url
|
|
}]
|
|
});
|
|
type = 'playing';
|
|
status = text;
|
|
} else if (value === 'streaming') {
|
|
client.user.setPresence({
|
|
activities: [{
|
|
name: text,
|
|
type: ActivityType.Streaming,
|
|
url: url
|
|
}]
|
|
});
|
|
type = 'streaming';
|
|
status = text;
|
|
} else if (value === 'listening') {
|
|
client.user.setPresence({
|
|
activities: [{
|
|
name: text,
|
|
type: ActivityType.Listening,
|
|
url: url
|
|
}]
|
|
});
|
|
type = 'listening';
|
|
status = text;
|
|
} else if (value === 'watching') {
|
|
client.user.setPresence({
|
|
activities: [{
|
|
name: text,
|
|
type: ActivityType.Watching,
|
|
url: url
|
|
}]
|
|
});
|
|
type = 'watching';
|
|
status = text;
|
|
} else if (value === 'competing') {
|
|
client.user.setPresence({
|
|
activities: [{
|
|
name: text,
|
|
type: ActivityType.Competing,
|
|
url: url
|
|
}]
|
|
});
|
|
type = 'competing';
|
|
status = text;
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
db.run('INSERT OR REPLACE INTO status (botId, type, status) VALUES (?, ?, ?)', [client.user.id, type, status], (err) => {
|
|
if (err) {
|
|
console.error(err.message);
|
|
} else {
|
|
}
|
|
});
|
|
|
|
|
|
});
|
|
}
|
|
});
|
|
|
|
collector.on('end', async () => {
|
|
sendMessage.edit({ components: [] });
|
|
});
|
|
},
|
|
}; |