mirror of
https://github.com/arthur-pbty/gestion-perso.git
synced 2026-06-03 15:07:27 +02:00
137 lines
4.2 KiB
TypeScript
137 lines
4.2 KiB
TypeScript
import { Message, Client, EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder, ActivityType, Activity } from "discord.js";
|
|
|
|
module.exports = {
|
|
aliases: ['setact'],
|
|
description: 'Changer la présence du bot',
|
|
emote: '🎮',
|
|
utilisation: '',
|
|
permission: '8',
|
|
|
|
async execute(message: Message, args:string[], client: Client) {
|
|
if (!client.user) return
|
|
|
|
const author = message.author;
|
|
|
|
let currentActivitie: any = client.user.presence.activities[0]?.type;
|
|
if (currentActivitie === 0) {
|
|
currentActivitie = 'Joue';
|
|
} else if (currentActivitie === 1) {
|
|
currentActivitie = 'Stream';
|
|
} else if (currentActivitie === 2) {
|
|
currentActivitie = 'Écoute';
|
|
} else if (currentActivitie === 3) {
|
|
currentActivitie = 'Regarde';
|
|
} else {
|
|
currentActivitie = 'Aucun';
|
|
}
|
|
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 === 0) {
|
|
embed.setColor('#FF0000');
|
|
} else if (currentActivitie === 1) {
|
|
embed.setColor('#FFA500');
|
|
} else if (currentActivitie === 2) {
|
|
embed.setColor('#00FF00');
|
|
} else if (currentActivitie === 3) {
|
|
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: '👀'
|
|
}
|
|
]);
|
|
|
|
const row: any = new ActionRowBuilder()
|
|
.addComponents(selectMenu)
|
|
|
|
const sendMessage = await message.reply({ embeds: [embed], components: [row] });
|
|
|
|
let filter = (interaction: any) => interaction.user.id === message.author.id;
|
|
const collector = sendMessage.createMessageComponentCollector({ filter, time: 60000 });
|
|
collector.on('collect', async (interaction: any) => {
|
|
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) => message.author.id === author.id;
|
|
const messageCollector = message.channel.createMessageCollector({ filter, time: 60000, max: 1 });
|
|
messageCollector.on('collect', async (messageCollect: Message): Promise<void> => {
|
|
const text = messageCollect.content;
|
|
const url = 'https://www.twitch.tv/tuturp33';
|
|
|
|
if (!client.user) return;
|
|
if (value === 'playing') {
|
|
client.user.setPresence({
|
|
activities: [{
|
|
name: text,
|
|
type: ActivityType.Playing,
|
|
url: url
|
|
}]
|
|
});
|
|
} else if (value === 'streaming') {
|
|
client.user.setPresence({
|
|
activities: [{
|
|
name: text,
|
|
type: ActivityType.Streaming,
|
|
url: url
|
|
}]
|
|
});
|
|
} else if (value === 'listening') {
|
|
client.user.setPresence({
|
|
activities: [{
|
|
name: text,
|
|
type: ActivityType.Listening,
|
|
url: url
|
|
}]
|
|
});
|
|
} else if (value === 'watching') {
|
|
client.user.setPresence({
|
|
activities: [{
|
|
name: text,
|
|
type: ActivityType.Watching,
|
|
url: url
|
|
}]
|
|
});
|
|
} else {
|
|
return;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
collector.on('end', async () => {
|
|
sendMessage.edit({ components: [] });
|
|
});
|
|
},
|
|
}; |