From 7743c4e5c330e18030a6a2fc4a37f7d90ef99a04 Mon Sep 17 00:00:00 2001 From: Tutur33 Date: Thu, 29 Feb 2024 19:03:58 +0100 Subject: [PATCH] upgrade 2 commands --- commands/botcontrol/dnd.js | 12 --- commands/botcontrol/idle.js | 12 --- commands/botcontrol/invisible.js | 12 --- commands/botcontrol/listen.js | 24 ------ commands/botcontrol/online.js | 12 --- commands/botcontrol/play.js | 25 ------ commands/botcontrol/setactivity.js | 126 +++++++++++++++++++++++++++++ commands/botcontrol/setstatus.js | 101 +++++++++++++++++++++++ commands/botcontrol/stream.js | 24 ------ commands/botcontrol/watch.js | 25 ------ 10 files changed, 227 insertions(+), 146 deletions(-) delete mode 100644 commands/botcontrol/dnd.js delete mode 100644 commands/botcontrol/idle.js delete mode 100644 commands/botcontrol/invisible.js delete mode 100644 commands/botcontrol/listen.js delete mode 100644 commands/botcontrol/online.js delete mode 100644 commands/botcontrol/play.js create mode 100644 commands/botcontrol/setactivity.js create mode 100644 commands/botcontrol/setstatus.js delete mode 100644 commands/botcontrol/stream.js delete mode 100644 commands/botcontrol/watch.js diff --git a/commands/botcontrol/dnd.js b/commands/botcontrol/dnd.js deleted file mode 100644 index da63401..0000000 --- a/commands/botcontrol/dnd.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - name: 'dnd', - description: 'Changer le status du bot en dnd', - emote: '🔕', - utilisation: 'dnd', - category: 'botcontrol', - async execute(message, args, client) { - - client.user.setStatus('dnd'); - message.channel.send(`Le bot est maintenant en de pas deranger`); - }, -}; \ No newline at end of file diff --git a/commands/botcontrol/idle.js b/commands/botcontrol/idle.js deleted file mode 100644 index caa117d..0000000 --- a/commands/botcontrol/idle.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - name: 'idle', - description: 'Changer le status du bot en idle', - emote: '🔄', - utilisation: 'idle', - category: 'botcontrol', - - async execute(message, args, client) { - client.user.setStatus('idle'); - message.channel.send(`Le bot est maintenant en mode idle`); - }, -}; \ No newline at end of file diff --git a/commands/botcontrol/invisible.js b/commands/botcontrol/invisible.js deleted file mode 100644 index be44165..0000000 --- a/commands/botcontrol/invisible.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - name: 'invisible', - description: 'Changer le status du bot en invisible', - emote: '🕶️', - utilisation: 'invisible', - category: 'botcontrol', - - async execute(message, args, client) { - client.user.setStatus('invisible'); - message.channel.send(`Le bot est maintenant invisible`); - }, - }; \ No newline at end of file diff --git a/commands/botcontrol/listen.js b/commands/botcontrol/listen.js deleted file mode 100644 index 8de3986..0000000 --- a/commands/botcontrol/listen.js +++ /dev/null @@ -1,24 +0,0 @@ -const { ActivityType } = require("discord.js"); - -module.exports = { - name: 'listen', - aliases: ['écoute'], - description: 'Changer le status du bot en listen', - emote: '🎧', - utilisation: 'listen ', - category: 'botcontrol', - async execute(message, args, client) { - const streamText = args.join(' ') || 'Streaming'; - const streamURL = 'https://www.twitch.tv/valou336_yt'; - - client.user.setPresence({ - activities: [{ - name: streamText, - type: ActivityType.Listening, - url: streamURL - }] - }); - - message.channel.send(`Le bot est maintenant en streaming : ${streamText}`); - }, -}; \ No newline at end of file diff --git a/commands/botcontrol/online.js b/commands/botcontrol/online.js deleted file mode 100644 index da68404..0000000 --- a/commands/botcontrol/online.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = { - name: 'online', - description: 'Changer le status du bot en online', - emote: '🟢', - utilisation: 'online', - category: 'botcontrol', - - async execute(message, args, client) { - client.user.setStatus('online'); - message.channel.send(`Le bot est maintenant en ligne`); - }, - }; \ No newline at end of file diff --git a/commands/botcontrol/play.js b/commands/botcontrol/play.js deleted file mode 100644 index 1befb47..0000000 --- a/commands/botcontrol/play.js +++ /dev/null @@ -1,25 +0,0 @@ -const { ActivityType } = require("discord.js"); - -module.exports = { - name: 'play', - aliases: ['joue'], - description: 'Changer le status du bot en play', - emote: '🎵', - utilisation: 'play ', - category: 'botcontrol', - - async execute(message, args, client) { - const streamText = args.join(' ') || 'Streaming'; - const streamURL = 'https://www.twitch.tv/valou336_yt'; - - client.user.setPresence({ - activities: [{ - name: streamText, - type: ActivityType.Playing, - url: streamURL - }] - }); - - message.channel.send(`Le bot est maintenant en streaming : ${streamText}`); - }, -}; \ No newline at end of file diff --git a/commands/botcontrol/setactivity.js b/commands/botcontrol/setactivity.js new file mode 100644 index 0000000..5c3bf65 --- /dev/null +++ b/commands/botcontrol/setactivity.js @@ -0,0 +1,126 @@ +const { EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder, ActivityType } = require("discord.js"); + +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]; + + 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: '👀' + } + ]); + + 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, time: 60000 }); + messageCollector.on('collect', async (messageCollect) => { + 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: [] }); + }); + }, +}; \ No newline at end of file diff --git a/commands/botcontrol/setstatus.js b/commands/botcontrol/setstatus.js new file mode 100644 index 0000000..2a93879 --- /dev/null +++ b/commands/botcontrol/setstatus.js @@ -0,0 +1,101 @@ +const { EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder } = require("discord.js"); + +module.exports = { + name: 'setstatus', + description: 'Changer le status du bot', + emote: '🟢', + utilisation: '', + permission: '8', + utilisation: 'setstatus', + category: 'botcontrol', + async execute(message, args, client) { + let currentStatus = client.user.presence.status; + + const embed = new EmbedBuilder() + .setTitle('Changement de status') + .setDescription(`Le bot est en mode :\`${currentStatus}\``) + .setTimestamp() + .setFooter({text: `${client.user.tag} © 2024`, iconURL: client.user.displayAvatarURL()}); + + if (currentStatus === 'dnd') { + embed.setColor('#FF0000'); + } else if (currentStatus === 'idle') { + embed.setColor('#FFA500'); + } else if (currentStatus === 'online') { + embed.setColor('#00FF00'); + } else if (currentStatus === 'offline') { + embed.setColor('#000000'); + } else { + embed.setColor('#000000'); + } + + const selectMenu = new StringSelectMenuBuilder() + .setCustomId('status') + .setPlaceholder('Changer le status') + .addOptions([ + { + label: 'En ligne', + value: 'online', + description: 'Le bot sera en ligne', + emoji: '🟢' + }, + { + label: 'Absent', + value: 'idle', + description: 'Le bot sera absent', + emoji: '🟠' + }, + { + label: 'Ne pas déranger', + value: 'dnd', + description: 'Le bot ne sera pas déranger', + emoji: '🔴' + }, + { + label: 'Invisible', + value: 'offline', + description: 'Le bot sera invisible', + emoji: '⚫' + } + ]); + + const row = new ActionRowBuilder() + .addComponents(selectMenu) + + const sendMessage = await message.reply({ embeds: [embed], components: [row] }); + + const filter = (interaction) => interaction.user.id === message.author.id; + const collector = sendMessage.createMessageComponentCollector({ filter, time: 60000 }); + collector.on('collect', async (interaction) => { + if (interaction.isStringSelectMenu()) { + if (!client.user) return + const value = interaction.values[0]; + if (value === 'online') { + client.user.setStatus('online'); + embed.setDescription('Le bot est maintenant en ligne'); + embed.setColor('#00FF00'); + await interaction.update({ embeds: [embed], components: [row] }); + } else if (value === 'idle') { + client.user.setStatus('idle'); + embed.setDescription('Le bot est maintenant absent'); + embed.setColor('#FFA500'); + await interaction.update({ embeds: [embed], components: [row] }); + } else if (value === 'dnd') { + client.user.setStatus('dnd'); + embed.setDescription('Le bot est maintenant en mode ne pas déranger'); + embed.setColor('#FF0000'); + await interaction.update({ embeds: [embed], components: [row] }); + } else if (value === 'offline') { + client.user.setStatus('invisible'); + embed.setDescription('Le bot est maintenant invisible'); + embed.setColor('#000000'); + await interaction.update({ embeds: [embed], components: [row] }); + } + } + }); + + collector.on('end', async () => { + sendMessage.edit({ components: [] }); + }); + }, +}; \ No newline at end of file diff --git a/commands/botcontrol/stream.js b/commands/botcontrol/stream.js deleted file mode 100644 index 12b3196..0000000 --- a/commands/botcontrol/stream.js +++ /dev/null @@ -1,24 +0,0 @@ -const { ActivityType } = require("discord.js"); - -module.exports = { - name: 'stream', - aliases: ['streaming'], - description: 'Mettre le bot en stream', - emote: '🎥', - utilisation: 'stream ', - category: 'botcontrol', - async execute(message, args, client) { - const streamText = args.join(' ') || 'Streaming'; - const streamURL = 'https://www.twitch.tv/valou336_yt'; - - client.user.setPresence({ - activities: [{ - name: streamText, - type: ActivityType.Streaming, - url: streamURL - }] - }); - - message.channel.send(`Le bot est maintenant en streaming : ${streamText}`); - }, -}; \ No newline at end of file diff --git a/commands/botcontrol/watch.js b/commands/botcontrol/watch.js deleted file mode 100644 index 03de7ea..0000000 --- a/commands/botcontrol/watch.js +++ /dev/null @@ -1,25 +0,0 @@ -const { ActivityType } = require("discord.js"); - -module.exports = { - name: 'watch', - aliases: ['regarde'], - description: 'Changer le status du bot en watch', - emote: '👁️', - utilisation: 'watch ', - category: 'botcontrol', - - async execute(message, args, client) { - const streamText = args.join(' ') || 'Streaming'; - const streamURL = 'https://www.twitch.tv/valou336_yt'; - - client.user.setPresence({ - activities: [{ - name: streamText, - type: ActivityType.Watching, - url: streamURL - }] - }); - - message.channel.send(`Le bot est maintenant en streaming : ${streamText}`); - }, -}; \ No newline at end of file