Browse Source

refactor: clean up changes for config

development
Abheek Dhawan 2 years ago
parent
commit
ca50751652
Signed by: abheekd GPG Key ID: 7BE81B8C14475B67
  1. 1
      nbproject/private/private.properties
  2. 4
      nbproject/private/private.xml
  3. 4
      src/deploy-commands.js
  4. 4
      src/events/interactionCreate.ts
  5. 82
      src/helpers/util/pagination.js

1
nbproject/private/private.properties

@ -1 +0,0 @@
browser=Chrome.INTEGRATED

4
nbproject/private/private.xml

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
</project-private>

4
src/deploy-commands.js

@ -6,10 +6,10 @@ const { Routes } = require('discord-api-types/v9');
const { clientId, token } = require('./helpers/env');
const commands = [];
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const commandFiles = fs.readdirSync(__dirname + '/commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
const command = require(`${__dirname}/commands/${file}`);
commands.push(command.data.toJSON());
}

4
src/events/interactionCreate.ts

@ -11,7 +11,7 @@ export async function execute(interaction) {
const command = client.commands.get(interaction.commandName);
if (!command) return; //h
if (!command) return;
try {
await command.execute(interaction);
@ -20,4 +20,4 @@ export async function execute(interaction) {
log({ logger: 'interaction', content: `Interaction ${interaction.name} failed!`, level: 'error' });
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
}

82
src/helpers/util/pagination.js

@ -1,82 +0,0 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.paginateInteraction = exports.paginateMessage = void 0;
const discord_js_1 = require("discord.js");
function paginateMessage(message, embeds) {
return __awaiter(this, void 0, void 0, function* () {
let index = 0;
const row = new discord_js_1.MessageActionRow;
row.addComponents(new discord_js_1.MessageButton()
.setCustomId('paginator-left')
.setEmoji('868552005977788466')
.setStyle('SECONDARY'), new discord_js_1.MessageButton()
.setCustomId('paginator-right')
.setEmoji('868551772887711754')
.setStyle('SECONDARY'));
yield message.reply({ content: `Page 1 of ${embeds.length}:`, embeds: [embeds[index]], components: [row] })
.then((paginatorMessage) => __awaiter(this, void 0, void 0, function* () {
const filter = m => m.author.id === message.author.id;
const paginatorCollector = paginatorMessage.createMessageComponentCollector({ componentType: 'BUTTON', filter: filter });
paginatorCollector.on('collect', (i) => __awaiter(this, void 0, void 0, function* () {
switch (i.customId) {
case 'paginator-left':
index--;
if (index < 0)
index = embeds.length - 1;
break;
case 'paginator-right':
index++;
if (index > embeds.length - 1)
index = 0;
break;
}
paginatorMessage.edit({ content: `Page ${index + 1} of ${embeds.length}:`, embeds: [embeds[index]] });
}));
}));
});
}
exports.paginateMessage = paginateMessage;
function paginateInteraction(interaction, embeds) {
return __awaiter(this, void 0, void 0, function* () {
let index = 0;
const row = new discord_js_1.MessageActionRow;
row.addComponents(new discord_js_1.MessageButton()
.setCustomId('paginator-left')
.setEmoji('868552005977788466')
.setStyle('SECONDARY'), new discord_js_1.MessageButton()
.setCustomId('paginator-right')
.setEmoji('868551772887711754')
.setStyle('SECONDARY'));
yield interaction.followUp({ content: `Page 1 of ${embeds.length}:`, embeds: [embeds[index]], components: [row], fetchReply: true })
.then((p) => __awaiter(this, void 0, void 0, function* () {
const paginatorMessage = p;
const filter = i => i.user.id === interaction.user.id;
const paginatorCollector = paginatorMessage.createMessageComponentCollector({ componentType: 'BUTTON', filter: filter });
paginatorCollector.on('collect', (i) => __awaiter(this, void 0, void 0, function* () {
switch (i.customId) {
case 'paginator-left':
index--;
if (index < 0)
index = embeds.length - 1;
break;
case 'paginator-right':
index++;
if (index > embeds.length - 1)
index = 0;
break;
}
yield i.update({ content: `Page ${index + 1} of ${embeds.length}:`, embeds: [embeds[index]] });
}));
}));
});
}
exports.paginateInteraction = paginateInteraction;
Loading…
Cancel
Save