Compare commits
4 Commits
707155d5c4
...
ec95f1a24a
Author | SHA1 | Date |
---|---|---|
Nemo | ec95f1a24a | |
Nemo | 0ab0bcac22 | |
Nemo | c07ce75832 | |
Nemo | 6f998afb61 |
|
@ -0,0 +1,49 @@
|
|||
const { SlashCommandBuilder } = require('@discordjs/builders');
|
||||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('roll')
|
||||
.setDescription('Roll the dice, seal your fate.')
|
||||
.addStringOption(option =>
|
||||
option.setName('dice')
|
||||
.setDescription('*ex: /roll 1d6 - max 100 faces - max 15 dés')
|
||||
.setRequired(true)
|
||||
),
|
||||
async execute(interaction) {
|
||||
const option = interaction.options.get('dice');
|
||||
const regex = /^([0-9]){1,}([dD])([0-9]{1,})$/;
|
||||
if(!option.value.match(regex)){
|
||||
await interaction.reply({content: 'Veuillez entrer le bon format - *ex: 1d6*', ephemeral: true});
|
||||
return;
|
||||
}
|
||||
|
||||
const args = option.value.split(/[dD]/);
|
||||
const num = parseInt(args[0]);
|
||||
const dice = parseInt(args[1]);
|
||||
|
||||
if(num < 1 || num > 15){
|
||||
await interaction.reply({content: 'Veuillez entrer un nombre de dé compris entre 1 et 15 - *ex: 1d6*', ephemeral: true});
|
||||
return;
|
||||
}
|
||||
|
||||
if(dice < 1 || dice > 100){
|
||||
await interaction.reply({content: 'Veuillez entrer un nombre de dé compris entre 1 et 15 - *ex: 1d6*', ephemeral: true});
|
||||
return;
|
||||
}
|
||||
|
||||
var reply = num + " dés de " + dice + " faces lancés :\t";
|
||||
var total = 0;
|
||||
var dices = ""
|
||||
|
||||
for(var i = 0; i < num; i++){
|
||||
var roll = 1 + Math.floor(Math.random() * (dice));
|
||||
total += roll;
|
||||
dices += " 🎲 **" + roll + "** ";
|
||||
}
|
||||
|
||||
reply += "*total de* **" + total + "**\n" + dices;
|
||||
|
||||
await interaction.reply(reply);
|
||||
},
|
||||
};
|
||||
|
|
@ -5,7 +5,7 @@ const commandUser = new Collection();
|
|||
|
||||
module.exports = {
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('role')
|
||||
.setName('setrole')
|
||||
.setDescription('Gère les rôles de votre profil'),
|
||||
async execute(interaction) {
|
||||
|
||||
|
@ -57,7 +57,7 @@ module.exports = {
|
|||
|
||||
const collector = interaction.channel.createMessageComponentCollector({
|
||||
filter: filter,
|
||||
time: 3 * 60000,
|
||||
time: 5 * 1000,
|
||||
});
|
||||
|
||||
commandUser.set(interaction.user.id, interaction);
|
||||
|
@ -76,11 +76,11 @@ module.exports = {
|
|||
//i.member.roles.add(roles.get(selectRole));
|
||||
if (selectRole != null) {
|
||||
if (interaction.member.roles.cache.has(selectRole.id)) {
|
||||
interaction.editReply(messageContent + ' - *Le rôle ' + selectRole.name + ' vous est déjà attribué*');
|
||||
interaction.editReply(messageContent + ' - *Le rôle "' + selectRole.name + '" vous est déjà attribué*');
|
||||
|
||||
} else {
|
||||
interaction.member.roles.add(selectRole);
|
||||
interaction.editReply(messageContent + ' - *Le rôle ' + selectRole.name + ' a été ajouté*');
|
||||
interaction.editReply(messageContent + ' - *Le rôle "' + selectRole.name + '" a été ajouté*');
|
||||
selectRole = null;
|
||||
}
|
||||
} else {
|
||||
|
@ -92,10 +92,10 @@ module.exports = {
|
|||
if (i.customId === 'btnDel') {
|
||||
if (selectRole != null) {
|
||||
if (!interaction.member.roles.cache.has(selectRole.id)) {
|
||||
interaction.editReply(messageContent + ' - *Le rôle ' + selectRole.name + ' ne vous est pas attribué*');
|
||||
interaction.editReply(messageContent + ' - *Le rôle "' + selectRole.name + '" ne vous est pas attribué*');
|
||||
} else {
|
||||
interaction.member.roles.remove(selectRole);
|
||||
interaction.editReply(messageContent + ' - *Le rôle ' + selectRole.name + ' a été enlevé*');
|
||||
interaction.editReply(messageContent + ' - *Le rôle "' + selectRole.name + '" a été enlevé*');
|
||||
selectRole = null;
|
||||
}
|
||||
} else {
|
|
@ -103,6 +103,9 @@ module.exports = {
|
|||
|
||||
interaction.reply({ content: commandReply, components: [row] })
|
||||
.then(() => {
|
||||
|
||||
var publicReplies = undefined;
|
||||
|
||||
const filterParticipate = (btnInt) => btnInt.customId === 'primary';
|
||||
|
||||
const collectorParticipate = interaction.channel.createMessageComponentCollector({
|
||||
|
@ -128,7 +131,6 @@ module.exports = {
|
|||
});
|
||||
|
||||
collectorCancel.on('collect', async i => {
|
||||
console.log("pouet on passe combien de fois ici ?");
|
||||
if (!i.member.roles.cache.has(wwRole.id)) {
|
||||
OnlyReply('Vous n\'êtes pas enregistré pour cette wordwar', i, wwRole);
|
||||
} else {
|
||||
|
@ -145,43 +147,39 @@ module.exports = {
|
|||
wwRole.delete();
|
||||
collectorCancel.stop();
|
||||
collectorParticipate.stop();
|
||||
if (publicReplies != undefined) {
|
||||
publicReplies.delete();
|
||||
}
|
||||
console.log(wwRole.name + ' canceled');
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (wwRole.deleted != true) {
|
||||
setTimeout(async () => {
|
||||
console.log('Wordwar launched');
|
||||
setTimeout(async () => {
|
||||
if (wwRole.deleted != true) {
|
||||
console.log(wwRole.name + ' launched');
|
||||
var participantStart = '\nLa wordwar ' + wwRole.name + ' commence. Vous pouvez toujours la rejoindre si vous le désirez. Bonne chance à tou.te.s !! ' + roleMention(wwRole.id) + '\n';
|
||||
var sentMsg = await interaction.channel.send({ content: participantStart, fetchReply: true });
|
||||
if (wwRole.deleted != true) {
|
||||
setTimeout(async () => {
|
||||
if (wwRole.deleted != true) {
|
||||
console.log('Wordwar ended');
|
||||
var participantEnd = 'La wordwar ' + wwRole.name + ' est maintenant terminée, merci d\'y avoir participé \! ' + roleMention(wwRole.id) + '\n';
|
||||
interaction.channel.send(participantEnd);
|
||||
ongoingww.forEach(element => {
|
||||
if (element.value == wwRole.name) {
|
||||
element.delete();
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
wwRole.delete();
|
||||
collectorCancel.stop();
|
||||
collectorParticipate.stop();
|
||||
}, 30 * 1000); // Wait 30 seconds to delete the role
|
||||
} else {
|
||||
sentMsg.delete();
|
||||
console.log('Wordwar canceled');
|
||||
}
|
||||
}, wwtimer * 1000);
|
||||
} else {
|
||||
sentMsg.delete();
|
||||
console.log('Wordwar canceled');
|
||||
}
|
||||
}, wwdelay * 1000);
|
||||
}
|
||||
publicReplies = await interaction.channel.send({ content: participantStart, fetchReply: true });
|
||||
setTimeout(async () => {
|
||||
if (wwRole.deleted != true) {
|
||||
console.log(wwRole.name + ' ended');
|
||||
var participantEnd = 'La wordwar ' + wwRole.name + ' est maintenant terminée, merci d\'y avoir participé \! ' + roleMention(wwRole.id) + '\n';
|
||||
await interaction.channel.send({ content: participantEnd, fetchReply: true });
|
||||
ongoingww.forEach((value,key,ongoingww) => {
|
||||
if (value == wwRole.name) {
|
||||
ongoingww.delete(key);
|
||||
}
|
||||
collectorCancel.stop();
|
||||
collectorParticipate.stop();
|
||||
});
|
||||
setTimeout(() => {
|
||||
wwRole.delete();
|
||||
}, 30 * 1000); // Wait 30 seconds to delete the role
|
||||
}
|
||||
}, wwtimer * 1000);
|
||||
}
|
||||
}, wwdelay * 1000);
|
||||
});
|
||||
/* }
|
||||
*/ }
|
||||
|
@ -197,7 +195,7 @@ function OnlyReply(str, int, ww) {
|
|||
intTable.set(ww.name + int.user.id, int);
|
||||
int.reply({ content: str, ephemeral: true });
|
||||
} else {
|
||||
intTable.get(ww.name + int.user.id).editReply({ content: str, ephemeral: true });
|
||||
intTable.get(ww.name + int.user.id).editReply({ content: str, ephemeral: true, fetchReply: true });
|
||||
int.deferUpdate();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue