Compare commits
4 Commits
c2c53edc58
...
cf429b3e4f
Author | SHA1 | Date | |
---|---|---|---|
|
cf429b3e4f | ||
|
563369e5ca | ||
|
c48cd4d776 | ||
|
5691d599c0 |
73
index.js
73
index.js
@ -11,17 +11,14 @@ const Client = new Discord.Client({
|
|||||||
Discord.Intents.FLAGS.GUILD_MEMBERS
|
Discord.Intents.FLAGS.GUILD_MEMBERS
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
const data = new SlashCommandBuilder()
|
/*const data = new SlashCommandBuilder()
|
||||||
.setName("react")
|
.setName("role")
|
||||||
.setDescription("Créer un ajout de rôle")
|
.setDescription("Créer un ajout de rôle")
|
||||||
.addStringOption(option =>
|
.addRoleOption(option =>
|
||||||
option.setName('role')
|
option.setName('role')
|
||||||
.setDescription('Le rôle à ajouter')
|
.setDescription('Le rôle à ajouter')
|
||||||
.setRequired(true)
|
.setRequired(true)
|
||||||
.addChoice('Lol', 'League_of_Legends')
|
)*/
|
||||||
.addChoice('OW', 'OverWatch')
|
|
||||||
.addChoice('SW', 'Summoners_War')
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
let embedCommands = new Discord.MessageEmbed().setTitle("Liste des commandes").setColor("#ff0505")
|
let embedCommands = new Discord.MessageEmbed().setTitle("Liste des commandes").setColor("#ff0505")
|
||||||
@ -33,6 +30,7 @@ let embedCommands = new Discord.MessageEmbed().setTitle("Liste des commandes").s
|
|||||||
Client.on("ready", async () => {
|
Client.on("ready", async () => {
|
||||||
fromCommandsToEmbed(friendsCommands.commands)
|
fromCommandsToEmbed(friendsCommands.commands)
|
||||||
console.log(`Logged in as ${Client.user.tag}!`)
|
console.log(`Logged in as ${Client.user.tag}!`)
|
||||||
|
|
||||||
// pour tout les serveurs - lent : Client.application.commands.create(data)
|
// pour tout les serveurs - lent : Client.application.commands.create(data)
|
||||||
/*await Client.guilds.cache.get("903598468306702336").commands.create(data)
|
/*await Client.guilds.cache.get("903598468306702336").commands.create(data)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -54,12 +52,17 @@ Client.login(config.token)
|
|||||||
"token": "ODkwOTc1MDU2NDAwOTA0MjQy.YU3nLg.T5wCbJ4UuDBanMjVaE-JX-aSELo",
|
"token": "ODkwOTc1MDU2NDAwOTA0MjQy.YU3nLg.T5wCbJ4UuDBanMjVaE-JX-aSELo",
|
||||||
"authorId": "307975903999164416"
|
"authorId": "307975903999164416"
|
||||||
}
|
}
|
||||||
|
* { bot
|
||||||
|
"clientId": "905433349080875038",
|
||||||
|
"guildId": "876543210987654321",
|
||||||
|
"token": "OTA1NDMzMzQ5MDgwODc1MDM4.YYKAhA.lX9_YqbkTxlkSfnYPOKa2pl5V8s",
|
||||||
|
"authorId": "307975903999164416"
|
||||||
|
}
|
||||||
* */
|
* */
|
||||||
// dev token OTA1NDMzMzQ5MDgwODc1MDM4.YYKAhA.lX9_YqbkTxlkSfnYPOKa2pl5V8s && "clientId": "905433349080875038",
|
// dev token OTA1NDMzMzQ5MDgwODc1MDM4.YYKAhA.lX9_YqbkTxlkSfnYPOKa2pl5V8s && "clientId": "905433349080875038",
|
||||||
Client.on("interactionCreate", async interaction => {
|
Client.on("interactionCreate", async interaction => {
|
||||||
if (interaction.isCommand()) {
|
if (interaction.isCommand()) {
|
||||||
const {commandName} = interaction
|
const {commandName} = interaction
|
||||||
|
|
||||||
if (commandName === "games") {
|
if (commandName === "games") {
|
||||||
let embed = new Discord.MessageEmbed()
|
let embed = new Discord.MessageEmbed()
|
||||||
.setTitle("Mini-Jeux")
|
.setTitle("Mini-Jeux")
|
||||||
@ -70,36 +73,20 @@ Client.on("interactionCreate", async interaction => {
|
|||||||
.addField("__WORlDLE__", "https://worldle.teuteuf.fr/")
|
.addField("__WORlDLE__", "https://worldle.teuteuf.fr/")
|
||||||
.addField("__LETTERS__", "https://edjefferson.com/letterle/ ")
|
.addField("__LETTERS__", "https://edjefferson.com/letterle/ ")
|
||||||
.setTimestamp()
|
.setTimestamp()
|
||||||
await interaction.channel.send({embeds: [embed]})
|
await interaction.reply({embeds: [embed], ephemeral: true})
|
||||||
interaction.reply({content: 'Done ! :white_check_mark:', ephemeral: true,})
|
|
||||||
|
|
||||||
} else if (commandName === "help") {
|
} else if (commandName === "help") {
|
||||||
await interaction.channel.send({embeds: [embedCommands]})
|
await interaction.reply({embeds: [embedCommands], ephemeral: true})
|
||||||
interaction.reply({content: 'Done ! :white_check_mark:', ephemeral: true,})
|
|
||||||
|
|
||||||
} else if (commandName === 'react') {
|
} else if (commandName === 'role') {
|
||||||
const message = await interaction.reply({content: 'Ajout du role : ' + interaction.options._hoistedOptions[0].value, fetchReply: true});
|
console.log(interaction)
|
||||||
console.log( interaction.options)
|
let roleId = interaction.options._hoistedOptions[0].value
|
||||||
|
await interaction.member.roles.add(interaction.guild.roles.cache.find(r => r.id === roleId))
|
||||||
message.react('👍')
|
await interaction.reply({
|
||||||
.then(() => message.react('👎'))
|
content: `Ajout du role : <@&${roleId}>`,
|
||||||
.catch(error => console.error('One of the emojis failed to react:', error))
|
fetchReply: true, ephemeral: true
|
||||||
|
|
||||||
const filter = (reaction, user) => {
|
|
||||||
return ['👍', '👎'].includes(reaction.emoji.name) && user.id === interaction.user.id;
|
|
||||||
};
|
|
||||||
message.awaitReactions({filter, max: 1, time: 60000, errors: ['time']})
|
|
||||||
.then(collected => {
|
|
||||||
const reaction = collected.first();
|
|
||||||
if (reaction.emoji.name === '👍') {
|
|
||||||
message.reply('Ajout effectué !');
|
|
||||||
} else {
|
|
||||||
message.reply('Suppression effectuée !');
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(collected => {
|
|
||||||
message.reply('You reacted with neither a thumbs up, nor a thumbs down.');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -124,24 +111,6 @@ Client.on('messageCreate', message => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Client.on('messageReactionAdd', async (reaction, user) => {
|
|
||||||
// When a reaction is received, check if the structure is partial
|
|
||||||
if (reaction.partial) {
|
|
||||||
// If the message this reaction belongs to was removed, the fetching might result in an API error which should be handled
|
|
||||||
try {
|
|
||||||
await reaction.fetch();
|
|
||||||
if (reaction.emoji.name === '👍') {
|
|
||||||
|
|
||||||
reaction.reply("J'ajoute ton rôle")
|
|
||||||
}
|
|
||||||
} catch
|
|
||||||
(error) {
|
|
||||||
console.error('Something went wrong when fetching the message:', error);
|
|
||||||
// Return as `reaction.message.author` may be undefined/null
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
function fromCommandsToEmbed(commands) {
|
function fromCommandsToEmbed(commands) {
|
||||||
|
Loading…
Reference in New Issue
Block a user