Fixed offline people
This commit is contained in:
parent
c3ee2fbc43
commit
480e66abdf
1 changed files with 8 additions and 9 deletions
17
index.js
17
index.js
|
@ -174,21 +174,20 @@ client.login(config.discord.token).catch(error => {
|
|||
|
||||
const discordAvatarRegex = /(https:\/\/cdn.discordapp.com\/avatars\/\w+\/\w+\.(\w+)\?size=)(\w+)/;
|
||||
|
||||
function findEmoji(message) {
|
||||
console.log('Mentions:', message.mentions);
|
||||
async function findEmoji(message) {
|
||||
// find a user mention
|
||||
if (message.mentions.members.size > 0) {
|
||||
const mentionedMember = message.mentions.members.first();
|
||||
const mentionedUser = mentionedMember.user;
|
||||
if (message.mentions.users.size > 0) {
|
||||
const mentionedUser = message.mentions.users.first();
|
||||
const mentionedMember = message.guild.members[mentionedUser.id];
|
||||
let avatarUrl = mentionedUser.displayAvatarURL;
|
||||
const avatarMatch = discordAvatarRegex.exec(avatarUrl);
|
||||
if (avatarMatch) {
|
||||
const ext = avatarMatch[2];
|
||||
// const ext = avatarMatch[2];
|
||||
avatarUrl = `${avatarMatch[1]}128`;
|
||||
}
|
||||
return {
|
||||
name: mentionedMember.displayName,
|
||||
id: mentionedMember.id,
|
||||
name: mentionedMember ? mentionedMember.displayName : mentionedUser.username,
|
||||
id: mentionedUser.id,
|
||||
url: avatarUrl,
|
||||
ext: avatarUrl.indexOf('.gif') >= 0 ? 'gif' : 'png'
|
||||
};
|
||||
|
@ -251,7 +250,7 @@ client.on('message', async message => {
|
|||
|
||||
if (message.cleanContent[0] === '/' || message.cleanContent[0] === '\\') {
|
||||
const messageSplit = message.cleanContent.split(' ');
|
||||
const emoji = findEmoji(message);
|
||||
const emoji = await findEmoji(message);
|
||||
let result = null;
|
||||
let count = 0;
|
||||
try {
|
||||
|
|
Reference in a new issue