mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-05 17:51:27 +03:00
refactor: update to discord.js v13 (#203)
* build: bump djs version * refactor(add): update * refactor(blacklist): update * refactor(close): update * refactor(help): update * refactor(new): update * refactor(panel): update * refactor(remove): update * refactor(stats): update * refactor(survey): update * refactor(tag): update * refactor(topic): update * refactor(guild): update, now Structures doesn't exist Also I don't know if this would work actually, let's see * refactor(guild_member) * refactor(index.js): add intents I can't understand how you do the indentation, sorry if I made a mistake * Update package.json * fix(intents): add `DIRECT_MESSAGES` intents - also fix code style and indentation * style: fix properties order and indentation * fix(guild) * Update and rename message.js to messageCreate.js * Update guild.js * refactor(manager): fix * Update manager.js * fix(help) * style: fix spacing * fix: permission overwrites * fix(new) * fix(presence): rename activity to activities * fix(presence): fix debug message * fix: update channel types * Update new.js * fix(embeds): update footer function * fix: broken code * style: add new lines around embed blocks * fix(messages): update remaining `send()` calls * fix(messages): i missed one * build: replace fastify logger with standard logger * refactor: update message and reaction collectors Co-authored-by: Isaac <git@eartharoid.me>
This commit is contained in:
@@ -1,23 +1,66 @@
|
||||
const config = require('../../user/config');
|
||||
|
||||
const {
|
||||
Guild, // eslint-disable-line no-unused-vars
|
||||
GuildMember // eslint-disable-line no-unused-vars
|
||||
} = require('discord.js');
|
||||
const config = require('../../user/config');
|
||||
let current_presence = -1;
|
||||
|
||||
module.exports = {
|
||||
module.exports = class DiscordUtils {
|
||||
constructor(client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Generate embed footer text
|
||||
* @param {string} text
|
||||
* @param {string} [additional]
|
||||
* @returns {string}
|
||||
*/
|
||||
footer: (text, additional) => {
|
||||
footer(text, additional) {
|
||||
if (text && additional) return `${text} | ${additional}`;
|
||||
else return additional || text || '';
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a guild member is staff
|
||||
* @param {GuildMember} member - the guild member
|
||||
* @returns {boolean}
|
||||
*/
|
||||
async isStaff(member) {
|
||||
const guild_categories = await this.client.db.models.Category.findAll({ where: { guild: member.guild.id } });
|
||||
return guild_categories.some(cat => cat.roles.some(r => member.roles.cache.has(r)));
|
||||
}
|
||||
|
||||
/**
|
||||
* get a guild's settings
|
||||
* @param {Guild} guild - The Guild
|
||||
* @returns {Promise<Model>}
|
||||
*/
|
||||
async getSettings(guild) {
|
||||
const data = { id: guild.id };
|
||||
const [settings] = await this.client.db.models.Guild.findOrCreate({
|
||||
defaults: data,
|
||||
where: data
|
||||
});
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a guild's settings
|
||||
* @param {Guild} guild - The Guild
|
||||
* @returns {Promise<Number>}
|
||||
*/
|
||||
async deleteSettings(guild) {
|
||||
const row = await this.getSettings(guild);
|
||||
return await row.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a presence from the config
|
||||
* @returns {PresenceData}
|
||||
*/
|
||||
selectPresence: () => {
|
||||
static selectPresence() {
|
||||
const length = config.presence.presences.length;
|
||||
if (length === 0) return {};
|
||||
|
||||
@@ -42,11 +85,13 @@ module.exports = {
|
||||
} = config.presence.presences[num];
|
||||
|
||||
return {
|
||||
activity: {
|
||||
name,
|
||||
type,
|
||||
url
|
||||
},
|
||||
activities: [
|
||||
{
|
||||
name,
|
||||
type,
|
||||
url
|
||||
}
|
||||
],
|
||||
status
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user