HEX colours

This commit is contained in:
Isaac 2021-04-01 22:00:01 +01:00
parent 1a4a3c1a33
commit c01f8c3b02
3 changed files with 10 additions and 4 deletions

View File

@ -270,7 +270,7 @@ module.exports = async (log) => {
},
},
name: DataTypes.STRING,
colour: DataTypes.INTEGER,
colour: DataTypes.CHAR(6),
}, {
tableName: DB_TABLE_PREFIX + 'role_entities'
});

View File

@ -1,3 +1,5 @@
const { int2hex } = require('../../utils');
/** Manages ticket archiving */
module.exports = class TicketArchives {
/**
@ -103,7 +105,7 @@ module.exports = class TicketArchives {
username: message.author.username,
discriminator: message.author.discriminator,
display_name: message.member.displayName,
colour: message.member.displayColor === 0 ? null : message.member.displayColor,
colour: message.member.displayColor === 0 ? null : int2hex(message.member.displayColor),
bot: message.author.bot
});
@ -117,12 +119,13 @@ module.exports = class TicketArchives {
where: m_model_data,
defaults: m_model_data
});
await m_row.update({
avatar: member.user.displayAvatarURL(),
username: member.user.username,
discriminator: member.user.discriminator,
display_name: member.displayName,
colour: member.displayColor === 0 ? null : member.displayColor,
colour: member.displayColor === 0 ? null : int2hex(member.displayColor),
bot: member.user.bot
});
});
@ -154,7 +157,7 @@ module.exports = class TicketArchives {
});
await r_row.update({
name: role.name,
colour: role.color === 0 ? 7506394 : role.color
colour: role.color === 0 ? '7289DA' : int2hex(role.color) // 7289DA = 7506394
});
});
}

3
src/utils/index.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
int2hex: (int) => int.toString(16).toUpperCase(),
};