mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2025-09-02 08:41:25 +03:00
Command handler stuff, presences, other stuff
This commit is contained in:
45
src/utils/discord.js
Normal file
45
src/utils/discord.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const { PresenceData } = require('discord.js');
|
||||
|
||||
const config = require('../../user/config');
|
||||
|
||||
let current_presence = -1;
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Select a presence from the config
|
||||
* @returns {PresenceData}
|
||||
*/
|
||||
selectPresence() {
|
||||
let length = config.presence.presences.length;
|
||||
if (length === 0) return {};
|
||||
|
||||
let num;
|
||||
if (length === 1)
|
||||
num = 0;
|
||||
else if (config.presence.randomise)
|
||||
num = Math.floor(Math.random() * length);
|
||||
else {
|
||||
current_presence = current_presence + 1; // ++ doesn't work on negative numbers
|
||||
if (current_presence === length)
|
||||
current_presence = 0;
|
||||
num = current_presence;
|
||||
}
|
||||
|
||||
let {
|
||||
activity: name,
|
||||
status,
|
||||
type,
|
||||
url
|
||||
} = config.presence.presences[num];
|
||||
|
||||
return {
|
||||
activity: {
|
||||
name,
|
||||
type,
|
||||
url
|
||||
},
|
||||
status
|
||||
};
|
||||
}
|
||||
};
|
@@ -1,5 +1,10 @@
|
||||
const { join } = require('path');
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Make a relative path absolute
|
||||
* @param {string} path - A path relative to the root of the project (like "./user/config.js")
|
||||
* @returns {string} absolute path
|
||||
*/
|
||||
path: path => join(__dirname, '../../', path),
|
||||
};
|
Reference in New Issue
Block a user