Skip to content

Commit

Permalink
small refactoring send command #69
Browse files Browse the repository at this point in the history
  • Loading branch information
BastLast committed Jul 15, 2020
1 parent bb58dfb commit 4135a99
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 0 additions & 2 deletions ressources/text/commands/sendPrivateMessage.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"translations": {
"fr": {
"error": "{pseudo}, hmmm... Cela n'a pas fonctionné !",
"descError": "Entrez l'id du joueur ainsi qu'un message après la commande svp",
"title": ":white_check_mark: | DM envoyé à **{username}** :",
"ok":">>> ",
Expand All @@ -10,7 +9,6 @@
"personNotExists": "Personne n'a été trouvé avec cet id !"
},
"en": {
"error": "{pseudo}, hmmm... It didn't work!",
"descError": "Indiacte the user id and a message after the command please",
"title": ":white_check_mark: | DM sent to **{username}**:",
"ok":">>> ",
Expand Down
14 changes: 1 addition & 13 deletions src/commands/admin/SendPrivateMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const SendPrivateMessage = async function(language, message, args) {
});

if (userId === undefined || args[1] === undefined) {
return await sendErrorMessageDM(message, language);
return sendErrorMessage(user, message.channel, language, JsonReader.commands.sendPrivateMessage.getTranslation(language).descError);
}

const user = client.users.cache.get(userId);
Expand All @@ -43,18 +43,6 @@ const SendPrivateMessage = async function(language, message, args) {
}
};

/**
* Send the error message for this command
* @param {module:"discord.js".Message} message - Message from the discord server
*/
async function sendErrorMessageDM(message, language) {
return await message.channel.send(new discord.MessageEmbed().setColor(JsonReader.bot.embed.error)
.setAuthor(format(JsonReader.commands.sendPrivateMessage.getTranslation(language).error, {
pseudo: message.author.username,
}), message.author.displayAvatarURL())
.setDescription(JsonReader.commands.sendPrivateMessage.getTranslation(language).descError));
}

module.exports = {
'dm': SendPrivateMessage,
};

0 comments on commit 4135a99

Please sign in to comment.