-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
93 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"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":">>> ", | ||
"signature": "\n\n- {username}" | ||
}, | ||
"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":">>> ", | ||
"signature": "\n\n- {username}" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* Allow an admin to change the prefix the bot use in a specific server | ||
* @param {("fr"|"en")} language - Language to use in the response | ||
* @param {module:"discord.js".Message} message - Message from the discord server | ||
* @param {String[]} args=[] - Additional arguments sent with the command | ||
*/ | ||
|
||
const SendPrivateMessage = async function (language, message, args) { | ||
|
||
if ((await canPerformCommand(message, language, | ||
PERMISSION.ROLE.SUPPORT)) !== true) { | ||
return; | ||
} | ||
|
||
var userId = args[0]; | ||
var messageToSend = args.join(' ').replace(userId, '') + | ||
format(JsonReader.commands.sendPrivateMessage.getTranslation(language).signature, { | ||
username: message.author.username | ||
}); | ||
|
||
if (userId == undefined || args[1] == undefined) | ||
return await sendErrorMessage(message, language); | ||
|
||
const user = client.users.cache.get(userId); | ||
let embed = new discord.MessageEmbed(); | ||
embed.setColor(JsonReader.bot.embed.default) | ||
.setTitle(format(JsonReader.commands.sendPrivateMessage.getTranslation(language).title, { | ||
username: user.username | ||
})) | ||
.setDescription(JsonReader.commands.sendPrivateMessage.getTranslation(language).ok + messageToSend) | ||
.setImage(message.attachments.size > 0 ? [...message.attachments.values()][0].url : ''); | ||
|
||
user.send(messageToSend); | ||
sendMessageAttachments(message, user); | ||
return await message.channel.send(embed); | ||
}; | ||
|
||
/** | ||
* Send the error message for this command | ||
* @param {module:"discord.js".Message} message - Message from the discord server | ||
*/ | ||
async function sendErrorMessage(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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters