Skip to content

Commit

Permalink
fixes givebadge command #69
Browse files Browse the repository at this point in the history
  • Loading branch information
BastLast committed Jul 15, 2020
1 parent e59ae1d commit fb0fc00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 2 additions & 4 deletions ressources/text/commands/giveBadgeCommand.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
"fr": {
"giveSuccess": "{pseudo}, vous avez donné un badge, j'espère que c'est mérité !",
"descGive": "Le badge {badge} a été donné à {player}",
"giveError": "{pseudo}, vous avez fait une erreur !",
"descError": "Vous devez entrer un badge sous la forme :nom_badge: puis tag le pseudo de la personne à qui est donné le badge !"
"descError": "La personne que vous avez saisi n'est pas valide. `gb :badge: @mention`."
},
"en": {
"giveSuccess": "{pseudo}, you gave a badge, i hope it is well deserved !",
"descGive": "The badge {badge} has been given to {player}",
"giveError": "{pseudo}, you made an error !",
"descError": "You must give a badge like :badge_name: and tag the nickname of the receiver !"
"descError": "Please indicate a valid user. `gb :badge: @mention`."
}
}
}
11 changes: 6 additions & 5 deletions src/commands/admin/GiveBadgeCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
* @param {module:"discord.js".Message} message - Message from the discord server
* @param {String[]} args=[] - Additional arguments sent with the command
*/
const giveBadgeCommand = async function(language, message, args) {
const giveBadgeCommand = async function (language, message, args) {
if ((await canPerformCommand(message, language, PERMISSION.ROLE.BADGEMANAGER)) !== true) {
return;
}
const embed = new discord.MessageEmbed();
// the author of the command is the author of the bot
if (message.mentions.users.last() === undefined) {
return sendErrorMessage(message.author, message.channel, language, JsonReader.commands.giveBadgeCommand.getTranslation(language).descError);
}
const playerId = message.mentions.users.last().id;
[entity] = await Entities.getOrRegister(playerId);

await entity.Player.addBadge(args[0]);
await entity.Player.save();

embed.setColor(JsonReader.bot.embed.default)
.setAuthor(format(JsonReader.commands.giveBadgeCommand.getTranslation(language).giveSuccess, {pseudo: message.author.username}), message.author.displayAvatarURL())
.setDescription(format(JsonReader.commands.giveBadgeCommand.getTranslation(language).descGive, {badge: args[0], player: message.mentions.users.last()}));
.setAuthor(format(JsonReader.commands.giveBadgeCommand.getTranslation(language).giveSuccess, { pseudo: message.author.username }), message.author.displayAvatarURL())
.setDescription(format(JsonReader.commands.giveBadgeCommand.getTranslation(language).descGive, { badge: args[0], player: message.mentions.users.last() }));
return await message.channel.send(embed);
};

Expand Down

0 comments on commit fb0fc00

Please sign in to comment.