Compare commits
2 Commits
cf453957e9
...
148d93aaab
| Author | SHA1 | Date | |
|---|---|---|---|
| 148d93aaab | |||
| 81ea71328a |
11
dist/discord.js
vendored
11
dist/discord.js
vendored
@@ -7,13 +7,12 @@ const v9_1 = require("discord-api-types/v9");
|
|||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
name: 'queue',
|
name: 'queue',
|
||||||
description: 'create a queue',
|
description: 'get queue info or initialize a queue for this channel',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
type: 4,
|
type: 4,
|
||||||
name: 'teamsize',
|
name: 'teamsize',
|
||||||
description: 'size of each team',
|
description: 'size of each team',
|
||||||
required: true,
|
|
||||||
min_value: 1
|
min_value: 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -27,12 +26,8 @@ const commands = [
|
|||||||
description: 'leave the active queue'
|
description: 'leave the active queue'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'ready',
|
name: 'stop',
|
||||||
description: 'ready the queue and display team info'
|
description: 'stops the current queue (must have the Manage Messages permission)'
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'cancel',
|
|
||||||
description: 'cancels the current queue (must have the Manage Messages permission)'
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'player',
|
name: 'player',
|
||||||
|
|||||||
19
dist/index.js
vendored
19
dist/index.js
vendored
@@ -29,31 +29,30 @@ const CLIENT = new discord_js_1.Client({ intents: [discord_js_1.Intents.FLAGS.GU
|
|||||||
//init logs with a timestamp
|
//init logs with a timestamp
|
||||||
console.log(new Date().toISOString() + '\n\n');
|
console.log(new Date().toISOString() + '\n\n');
|
||||||
//get token
|
//get token
|
||||||
if (!fs.existsSync('./token')) {
|
if (!fs.existsSync('./token.txt')) {
|
||||||
fs.writeFileSync('./token', '');
|
fs.writeFileSync('./token.txt', '');
|
||||||
console.error('Missing Discord Token, please enter the bot token into the token file');
|
console.error('Missing Discord Token, please enter the bot token into the token file');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const TOKEN = fs.readFileSync('./token').toString();
|
const TOKEN = fs.readFileSync('./token.txt').toString();
|
||||||
//discord connections
|
//discord connections
|
||||||
CLIENT.on('ready', client => {
|
CLIENT.on('ready', client => {
|
||||||
console.log(`Logged in as ${client.user.tag}`);
|
console.log(`Logged in as ${client.user.tag}`);
|
||||||
client.guilds.fetch().then(guilds => (0, discord_1.registerCommands)(TOKEN, client.user.id, guilds.map(g => g.id)));
|
client.guilds.fetch().then(guilds => (0, discord_1.registerCommands)(TOKEN, client.user.id, guilds.map(g => g.id)));
|
||||||
|
(0, queue_1.discordInit)(client);
|
||||||
});
|
});
|
||||||
CLIENT.on('interactionCreate', async (interaction) => {
|
CLIENT.on('interactionCreate', async (interaction) => {
|
||||||
if (!interaction.isCommand())
|
if (!interaction.isCommand())
|
||||||
return;
|
return;
|
||||||
try {
|
try {
|
||||||
if (interaction.commandName === 'queue')
|
if (interaction.commandName === 'queue')
|
||||||
await (0, queue_1.createQueue)(interaction);
|
await queue_1.QueueCommands.queue(interaction);
|
||||||
else if (interaction.commandName === 'join')
|
else if (interaction.commandName === 'join')
|
||||||
await (0, queue_1.joinQueue)(interaction);
|
await queue_1.QueueCommands.join(interaction);
|
||||||
else if (interaction.commandName === 'leave')
|
else if (interaction.commandName === 'leave')
|
||||||
await (0, queue_1.leaveQueue)(interaction);
|
await queue_1.QueueCommands.leave(interaction);
|
||||||
else if (interaction.commandName === 'ready')
|
else if (interaction.commandName === 'stop')
|
||||||
await (0, queue_1.readyQueue)(interaction);
|
await queue_1.QueueCommands.stop(interaction);
|
||||||
else if (interaction.commandName === 'cancel')
|
|
||||||
await (0, queue_1.cancelQueue)(interaction);
|
|
||||||
else if (interaction.commandName === 'player')
|
else if (interaction.commandName === 'player')
|
||||||
await (0, api_1.getPlayerInteraction)(interaction);
|
await (0, api_1.getPlayerInteraction)(interaction);
|
||||||
}
|
}
|
||||||
|
|||||||
291
dist/queue.js
vendored
291
dist/queue.js
vendored
@@ -1,10 +1,111 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
/* TODO
|
||||||
|
|
||||||
|
join message should contain your current position in the queue, editing it to keep it current
|
||||||
|
*/
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.cancelQueue = exports.readyQueue = exports.leaveQueue = exports.joinQueue = exports.createQueue = exports.queueContains = exports.getAll = exports.getInfo = void 0;
|
exports.QueueCommands = exports.discordInit = void 0;
|
||||||
const discord_js_1 = require("discord.js");
|
const discord_js_1 = require("discord.js");
|
||||||
|
const fs = __importStar(require("fs"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
//maps ChannelID to QueueInfo
|
//load queues from file
|
||||||
const QUEUE = new Map();
|
if (!fs.existsSync('./queues.json'))
|
||||||
|
fs.writeFileSync('./queues.json', '{}');
|
||||||
|
const _QUEUE = fs.readFileSync('./queues.json').toString(), QUEUE = new Map();
|
||||||
|
try {
|
||||||
|
let queueJson = JSON.parse(_QUEUE);
|
||||||
|
for (let channelId of queueJson) {
|
||||||
|
let { teamsize } = queueJson[channelId];
|
||||||
|
if (teamsize)
|
||||||
|
QUEUE.set(channelId, { teamsize, players: [] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) { }
|
||||||
|
function SaveQueue() {
|
||||||
|
let queueJson = Object.fromEntries(QUEUE), queueFileJson = {};
|
||||||
|
for (let channelId in QUEUE.keys())
|
||||||
|
queueFileJson[channelId] = { teamsize: queueJson[channelId].teamsize };
|
||||||
|
fs.writeFileSync('./queues.json', JSON.stringify(queueFileJson, null, 2));
|
||||||
|
}
|
||||||
|
async function checkQueue(channel) {
|
||||||
|
let info = QUEUE.get(channel.id);
|
||||||
|
if (!info)
|
||||||
|
return;
|
||||||
|
if (info.players.length > info.teamsize) {
|
||||||
|
let team = info.players.splice(0, info.teamsize).map(m => m.toString());
|
||||||
|
let embed = new discord_js_1.MessageEmbed()
|
||||||
|
.setTitle('Team')
|
||||||
|
.setDescription(team.join('\n'));
|
||||||
|
await channel.send({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var Queue;
|
||||||
|
(function (Queue) {
|
||||||
|
function create(channelId, teamsize) {
|
||||||
|
if (!QUEUE.has(channelId)) {
|
||||||
|
QUEUE.set(channelId, { teamsize, players: [] });
|
||||||
|
SaveQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Queue.create = create;
|
||||||
|
function remove(channelId) {
|
||||||
|
if (QUEUE.has(channelId)) {
|
||||||
|
QUEUE.delete(channelId);
|
||||||
|
SaveQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Queue.remove = remove;
|
||||||
|
function addPlayer(channelId, member) {
|
||||||
|
if (QUEUE.has(channelId)) {
|
||||||
|
QUEUE.delete(channelId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Queue.addPlayer = addPlayer;
|
||||||
|
function removePlayer(channelId, member) {
|
||||||
|
if (QUEUE.has(channelId)) {
|
||||||
|
QUEUE.delete(channelId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Queue.removePlayer = removePlayer;
|
||||||
|
})(Queue || (Queue = {}));
|
||||||
|
SaveQueue();
|
||||||
|
async function discordInit(client) {
|
||||||
|
for (let channelId in QUEUE.keys()) {
|
||||||
|
let info = QUEUE.get(channelId), channel = await client.channels.fetch(channelId);
|
||||||
|
if (!info) { //no idea what could cause this but TS complains
|
||||||
|
Queue.remove(channelId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!channel || !(channel instanceof discord_js_1.TextChannel)) {
|
||||||
|
console.error(`Unable to find channel ${channelId} for teams of ${info?.teamsize}`);
|
||||||
|
Queue.remove(channelId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
channel.send('The bot has just restarted and anybody in the queues have been reset');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.discordInit = discordInit;
|
||||||
|
var QueueCommands;
|
||||||
|
(function (QueueCommands) {
|
||||||
/**
|
/**
|
||||||
* get the queueInfo of an interaction
|
* get the queueInfo of an interaction
|
||||||
* @param interaction
|
* @param interaction
|
||||||
@@ -17,7 +118,6 @@ function getInfo(interaction) {
|
|||||||
throw (0, util_1.emsg)('There is not an active queue in this channel, type `/queue` to create one');
|
throw (0, util_1.emsg)('There is not an active queue in this channel, type `/queue` to create one');
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
exports.getInfo = getInfo;
|
|
||||||
/**
|
/**
|
||||||
* compiles all the get functions above
|
* compiles all the get functions above
|
||||||
* @param interaction
|
* @param interaction
|
||||||
@@ -29,161 +129,90 @@ const getAll = (interaction) => ({
|
|||||||
channel: (0, util_1.getChannel)(interaction),
|
channel: (0, util_1.getChannel)(interaction),
|
||||||
info: getInfo(interaction)
|
info: getInfo(interaction)
|
||||||
});
|
});
|
||||||
exports.getAll = getAll;
|
|
||||||
/**
|
/**
|
||||||
* checks if the interaction data is already in the queue
|
* checks if the interaction data is already in the queue
|
||||||
* @param interaction
|
* @param interaction
|
||||||
* @returns boolean
|
* @returns boolean
|
||||||
*/
|
*/
|
||||||
function queueContains(interaction) {
|
function queueContains(interaction) {
|
||||||
let { member, info } = (0, exports.getAll)(interaction);
|
let { member, info } = getAll(interaction);
|
||||||
if (info.players.map(m => m.id).includes(member.id))
|
if (info.players.map(m => m.id).includes(member.id))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
exports.queueContains = queueContains;
|
QueueCommands.queueContains = queueContains;
|
||||||
/**
|
|
||||||
* creates the timeout for the queue
|
|
||||||
* @param interaction
|
|
||||||
* @returns time timeout identifier
|
|
||||||
*/
|
|
||||||
function setQueueTimeout(interaction) {
|
|
||||||
let channel = (0, util_1.getChannel)(interaction);
|
|
||||||
return setTimeout(() => {
|
|
||||||
clearQueue(interaction);
|
|
||||||
channel.send('Queue has been reset due to inactivity');
|
|
||||||
}, 5 * 60 * 1000); //5 minutes
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* updates the rich embed for the current queue
|
|
||||||
* @param interaction
|
|
||||||
*/
|
|
||||||
async function sendQueueEmbed(interaction, closed = false) {
|
|
||||||
let info = getInfo(interaction), origInteraction = info.initiator.interaction;
|
|
||||||
let embed = new discord_js_1.MessageEmbed()
|
|
||||||
.setTitle('Queue')
|
|
||||||
.setAuthor({
|
|
||||||
name: info.initiator.member.displayName,
|
|
||||||
iconURL: info.initiator.member.displayAvatarURL({ dynamic: true })
|
|
||||||
})
|
|
||||||
.addField('Team Size', info.teamsize.toString(), true)
|
|
||||||
.addField('Players Joined', info.players.length.toString(), true)
|
|
||||||
.setFooter({ text: closed ? 'queue is finished' : 'type /join' });
|
|
||||||
if (origInteraction.deferred || origInteraction.replied)
|
|
||||||
await origInteraction.editReply({ embeds: [embed] });
|
|
||||||
else
|
|
||||||
await origInteraction.reply({ embeds: [embed] });
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* sends the list of teams
|
|
||||||
* @param interaction
|
|
||||||
*/
|
|
||||||
async function sendTeamsEmbed(interaction, teams) {
|
|
||||||
let embed = new discord_js_1.MessageEmbed()
|
|
||||||
.setTitle('Teams');
|
|
||||||
teams.forEach((team, i) => {
|
|
||||||
team.map(m => m.user.tag);
|
|
||||||
embed.addField(`Title ${i + 1}`, team.join('\n'));
|
|
||||||
});
|
|
||||||
interaction.reply({ embeds: [embed] });
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* sends the list of teams
|
|
||||||
* @param interaction
|
|
||||||
*/
|
|
||||||
async function clearQueue(interaction) {
|
|
||||||
let info = getInfo(interaction);
|
|
||||||
sendQueueEmbed(interaction, true);
|
|
||||||
clearTimeout(info.timeout);
|
|
||||||
QUEUE.delete(interaction.channelId);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* creates a queue from an interaction
|
* creates a queue from an interaction
|
||||||
* @param interaction
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be created
|
* @throws errorMessage class if it cannot be left
|
||||||
*/
|
*/
|
||||||
async function createQueue(interaction) {
|
function queueCreate(interaction) {
|
||||||
let member = (0, util_1.getMember)(interaction), { channelId } = interaction, teamsize = interaction.options.getInteger('teamsize', true);
|
(0, util_1.memberIsModThrow)(interaction);
|
||||||
|
let { channelId } = interaction, teamsize = interaction.options.getInteger('teamsize', true);
|
||||||
if (QUEUE.has(channelId))
|
if (QUEUE.has(channelId))
|
||||||
throw (0, util_1.emsg)('There is already an active queue in this channel, ' + (queueContains(interaction) ? 'and you are already in it' : 'type `/join` to join'));
|
throw (0, util_1.emsg)(`There is already an active queue in this channel for teams of ${QUEUE.get(channelId)?.teamsize}`);
|
||||||
QUEUE.set(channelId, {
|
Queue.create(channelId, teamsize);
|
||||||
players: [
|
interaction.reply(`A queue for teams of ${teamsize} has been started`);
|
||||||
member
|
|
||||||
],
|
|
||||||
initiator: {
|
|
||||||
interaction,
|
|
||||||
member
|
|
||||||
},
|
|
||||||
teamsize: teamsize,
|
|
||||||
timeout: setQueueTimeout(interaction)
|
|
||||||
});
|
|
||||||
sendQueueEmbed(interaction);
|
|
||||||
}
|
}
|
||||||
exports.createQueue = createQueue;
|
QueueCommands.queueCreate = queueCreate;
|
||||||
/**
|
/**
|
||||||
* joins a queue from an interaction
|
* creates a queue from an interaction
|
||||||
* @param interaction
|
|
||||||
* @throws errorMessage class if it cannot be joined
|
|
||||||
*/
|
|
||||||
async function joinQueue(interaction) {
|
|
||||||
let { member, info } = (0, exports.getAll)(interaction);
|
|
||||||
if (queueContains(interaction))
|
|
||||||
throw (0, util_1.emsg)('You are already in the active queue');
|
|
||||||
info.players.push(member);
|
|
||||||
clearTimeout(info.timeout);
|
|
||||||
info.timeout = setQueueTimeout(interaction);
|
|
||||||
QUEUE.set(interaction.channelId, info);
|
|
||||||
sendQueueEmbed(interaction);
|
|
||||||
await interaction.reply('Joined the queue');
|
|
||||||
}
|
|
||||||
exports.joinQueue = joinQueue;
|
|
||||||
/**
|
|
||||||
* leaves a queue from an interaction
|
|
||||||
* @param interaction
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be left
|
* @throws errorMessage class if it cannot be left
|
||||||
*/
|
*/
|
||||||
async function leaveQueue(interaction) {
|
async function queue(interaction) {
|
||||||
let { member, info } = (0, exports.getAll)(interaction);
|
let teamsize = interaction.options.getInteger('teamsize');
|
||||||
if (!queueContains(interaction))
|
if (teamsize) {
|
||||||
throw (0, util_1.emsg)('You aren\'t in the active queue');
|
queueCreate(interaction);
|
||||||
info.players.splice(info.players.indexOf(member), 1);
|
return;
|
||||||
clearTimeout(info.timeout);
|
|
||||||
info.timeout = setQueueTimeout(interaction);
|
|
||||||
QUEUE.set(interaction.channelId, info);
|
|
||||||
sendQueueEmbed(interaction);
|
|
||||||
await interaction.reply('Left the queue');
|
|
||||||
}
|
}
|
||||||
exports.leaveQueue = leaveQueue;
|
let info = getInfo(interaction);
|
||||||
|
let embed = new discord_js_1.MessageEmbed()
|
||||||
|
.setTitle('Active Queue')
|
||||||
|
.addField('Team Size', info.teamsize.toString(), true)
|
||||||
|
.addField('Players Joined', info.players.length.toString(), true)
|
||||||
|
.setFooter({ text: 'type /join' });
|
||||||
|
await interaction.reply({ embeds: [embed], ephemeral: true });
|
||||||
|
}
|
||||||
|
QueueCommands.queue = queue;
|
||||||
/**
|
/**
|
||||||
* readys a queue from an interaction
|
* stops a queue from an interaction
|
||||||
|
* @param interaction
|
||||||
|
* @throws errorMessage class if it cannot be joined
|
||||||
|
*/
|
||||||
|
async function stop(interaction) {
|
||||||
|
(0, util_1.memberIsModThrow)(interaction);
|
||||||
|
QUEUE.delete(interaction.channelId);
|
||||||
|
await interaction.reply('Queue has been reset');
|
||||||
|
}
|
||||||
|
QueueCommands.stop = stop;
|
||||||
|
/**
|
||||||
|
* joins a queue from an interaction
|
||||||
* @param interaction
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be readied
|
* @throws errorMessage class if it cannot be readied
|
||||||
*/
|
*/
|
||||||
async function readyQueue(interaction) {
|
async function join(interaction) {
|
||||||
let { member, info } = (0, exports.getAll)(interaction), { initiator } = info;
|
let { member, info, channel } = getAll(interaction);
|
||||||
if (member.id !== initiator.member.id)
|
if (queueContains(interaction))
|
||||||
throw (0, util_1.emsg)('Only the queue initiator can ready the queue');
|
throw (0, util_1.emsg)('You are already in the queue');
|
||||||
clearQueue(interaction);
|
info.players.push(member);
|
||||||
if (info.players.filter(m => m.id !== initiator.member.id).length === 0)
|
QUEUE.set(interaction.channelId, info);
|
||||||
throw (0, util_1.emsg)('Nobody signed up for the queue, the queue has been reset');
|
await interaction.reply('Joined the queue');
|
||||||
//team data
|
checkQueue(channel);
|
||||||
let playerlist = (0, util_1.shuffle)(info.players), teams = [];
|
|
||||||
//fill team data
|
|
||||||
for (let i = 0; i < playerlist.length; i += info.teamsize)
|
|
||||||
teams.push(playerlist.slice(i, i + info.teamsize));
|
|
||||||
sendTeamsEmbed(interaction, teams);
|
|
||||||
}
|
}
|
||||||
exports.readyQueue = readyQueue;
|
QueueCommands.join = join;
|
||||||
/**
|
/**
|
||||||
* readys a queue from an interaction
|
* leaves a queue from an interaction
|
||||||
* @param interaction
|
* @param interaction
|
||||||
* @throws errorMessage class if it cannot be reset
|
* @throws errorMessage class if it cannot be reset
|
||||||
*/
|
*/
|
||||||
async function cancelQueue(interaction) {
|
async function leave(interaction) {
|
||||||
let { info, member, channel } = (0, exports.getAll)(interaction);
|
let { member, info } = getAll(interaction);
|
||||||
if (!member.permissionsIn(channel).has('MANAGE_MESSAGES'))
|
if (!queueContains(interaction))
|
||||||
throw (0, util_1.emsg)('You do not have permission to run this command');
|
throw (0, util_1.emsg)('You aren\'t in the queue');
|
||||||
clearQueue(interaction);
|
info.players.splice(info.players.indexOf(member), 1);
|
||||||
await interaction.reply('Queue has been reset');
|
QUEUE.set(interaction.channelId, info);
|
||||||
|
await interaction.reply('Left the queue');
|
||||||
}
|
}
|
||||||
exports.cancelQueue = cancelQueue;
|
QueueCommands.leave = leave;
|
||||||
|
})(QueueCommands = exports.QueueCommands || (exports.QueueCommands = {}));
|
||||||
|
|||||||
12
dist/util.js
vendored
12
dist/util.js
vendored
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getChannel = exports.getMember = exports.emsg = exports.errorMessage = exports.shuffle = void 0;
|
exports.memberIsModThrow = exports.memberIsMod = exports.getChannel = exports.getMember = exports.emsg = exports.errorMessage = exports.shuffle = void 0;
|
||||||
const discord_js_1 = require("discord.js");
|
const discord_js_1 = require("discord.js");
|
||||||
/**
|
/**
|
||||||
* shuffles an array
|
* shuffles an array
|
||||||
@@ -64,3 +64,13 @@ function getChannel(interaction) {
|
|||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
exports.getChannel = getChannel;
|
exports.getChannel = getChannel;
|
||||||
|
function memberIsMod(interaction) {
|
||||||
|
let member = getMember(interaction);
|
||||||
|
return member.permissionsIn(interaction.channelId).has('MANAGE_MESSAGES');
|
||||||
|
}
|
||||||
|
exports.memberIsMod = memberIsMod;
|
||||||
|
function memberIsModThrow(interaction) {
|
||||||
|
if (!memberIsMod(interaction))
|
||||||
|
throw (0, exports.emsg)('Member is not a moderator');
|
||||||
|
}
|
||||||
|
exports.memberIsModThrow = memberIsModThrow;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ if (!fs.existsSync('./token.txt')) {
|
|||||||
console.error('Missing Discord Token, please enter the bot token into the token file');
|
console.error('Missing Discord Token, please enter the bot token into the token file');
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
const TOKEN = fs.readFileSync('./token').toString();
|
const TOKEN = fs.readFileSync('./token.txt').toString();
|
||||||
|
|
||||||
//discord connections
|
//discord connections
|
||||||
CLIENT.on('ready', client => {
|
CLIENT.on('ready', client => {
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import * as fs from 'fs';
|
|||||||
import { emsg, getChannel, getMember, memberIsModThrow, queueInfo, queueInfoBase } from "./util";
|
import { emsg, getChannel, getMember, memberIsModThrow, queueInfo, queueInfoBase } from "./util";
|
||||||
|
|
||||||
//load queues from file
|
//load queues from file
|
||||||
if (!fs.existsSync('./queues'))
|
if (!fs.existsSync('./queues.json'))
|
||||||
fs.writeFileSync('./queues', '{}');
|
fs.writeFileSync('./queues.json', '{}');
|
||||||
|
|
||||||
const _QUEUE = fs.readFileSync('./queues').toString(),
|
const _QUEUE = fs.readFileSync('./queues.json').toString(),
|
||||||
QUEUE = new Map<string, queueInfo>();
|
QUEUE = new Map<string, queueInfo>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user