More slash command work
This commit is contained in:
parent
77913618d6
commit
c821d91254
26 changed files with 188 additions and 62 deletions
|
@ -2,13 +2,21 @@ import Command from "../../classes/command.js";
|
||||||
|
|
||||||
class DiceCommand extends Command {
|
class DiceCommand extends Command {
|
||||||
async run() {
|
async run() {
|
||||||
if (this.args.length === 0 || !this.args[0].match(/^\d+$/)) {
|
const max = this.type === "classic" ? parseInt(this.args[0]) : this.options.max;
|
||||||
|
if (!max) {
|
||||||
return `🎲 The dice landed on ${Math.floor(Math.random() * 6) + 1}.`;
|
return `🎲 The dice landed on ${Math.floor(Math.random() * 6) + 1}.`;
|
||||||
} else {
|
} else {
|
||||||
return `🎲 The dice landed on ${Math.floor(Math.random() * parseInt(this.args[0])) + 1}.`;
|
return `🎲 The dice landed on ${Math.floor(Math.random() * max) + 1}.`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static flags = [{
|
||||||
|
name: "max",
|
||||||
|
type: 4,
|
||||||
|
description: "The maximum dice value",
|
||||||
|
min_value: 1
|
||||||
|
}];
|
||||||
|
|
||||||
static description = "Rolls the dice";
|
static description = "Rolls the dice";
|
||||||
static aliases = ["roll", "die", "rng", "random"];
|
static aliases = ["roll", "die", "rng", "random"];
|
||||||
static arguments = ["{number}"];
|
static arguments = ["{number}"];
|
||||||
|
|
|
@ -28,6 +28,7 @@ class AvatarCommand extends Command {
|
||||||
static description = "Gets a user's avatar";
|
static description = "Gets a user's avatar";
|
||||||
static aliases = ["pfp", "ava"];
|
static aliases = ["pfp", "ava"];
|
||||||
static arguments = ["{mention/id}"];
|
static arguments = ["{mention/id}"];
|
||||||
|
static slashAllowed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AvatarCommand;
|
export default AvatarCommand;
|
||||||
|
|
|
@ -28,6 +28,7 @@ class BannerCommand extends Command {
|
||||||
static description = "Gets a user's banner";
|
static description = "Gets a user's banner";
|
||||||
static aliases = ["userbanner"];
|
static aliases = ["userbanner"];
|
||||||
static arguments = ["{mention/id}"];
|
static arguments = ["{mention/id}"];
|
||||||
|
static slashAllowed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BannerCommand;
|
export default BannerCommand;
|
||||||
|
|
|
@ -6,8 +6,9 @@ class BroadcastCommand extends Command {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const owners = process.env.OWNER.split(",");
|
const owners = process.env.OWNER.split(",");
|
||||||
if (!owners.includes(this.author.id)) return "Only the bot owner can broadcast messages!";
|
if (!owners.includes(this.author.id)) return "Only the bot owner can broadcast messages!";
|
||||||
if (this.args.length !== 0) {
|
const message = this.type === "classic" ? this.args.join(" ") : this.options.message;
|
||||||
this.ipc.broadcast("playbroadcast", this.args.join(" "));
|
if (message && message.trim()) {
|
||||||
|
this.ipc.broadcast("playbroadcast", message);
|
||||||
this.ipc.register("broadcastSuccess", () => {
|
this.ipc.register("broadcastSuccess", () => {
|
||||||
this.ipc.unregister("broadcastSuccess");
|
this.ipc.unregister("broadcastSuccess");
|
||||||
resolve("Successfully broadcasted message.");
|
resolve("Successfully broadcasted message.");
|
||||||
|
@ -22,6 +23,12 @@ class BroadcastCommand extends Command {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static flags = [{
|
||||||
|
name: "message",
|
||||||
|
type: 3,
|
||||||
|
description: "The message to broadcast"
|
||||||
|
}];
|
||||||
|
|
||||||
static description = "Broadcasts a playing message until the command is run again or the bot restarts";
|
static description = "Broadcasts a playing message until the command is run again or the bot restarts";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class CountCommand extends Command {
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return paginator(this.client, this.message, embeds);
|
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, embeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static description = "Gets how many times every command was used";
|
static description = "Gets how many times every command was used";
|
||||||
|
|
|
@ -5,7 +5,8 @@ class EvalCommand extends Command {
|
||||||
async run() {
|
async run() {
|
||||||
const owners = process.env.OWNER.split(",");
|
const owners = process.env.OWNER.split(",");
|
||||||
if (!owners.includes(this.author.id)) return "Only the bot owner can use eval!";
|
if (!owners.includes(this.author.id)) return "Only the bot owner can use eval!";
|
||||||
const code = this.args.join(" ");
|
await this.acknowledge();
|
||||||
|
const code = this.type === "classic" ? this.args.join(" ") : this.options.code;
|
||||||
try {
|
try {
|
||||||
const evaled = eval(code);
|
const evaled = eval(code);
|
||||||
const cleaned = await clean(evaled);
|
const cleaned = await clean(evaled);
|
||||||
|
@ -24,6 +25,13 @@ class EvalCommand extends Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static flags = [{
|
||||||
|
name: "code",
|
||||||
|
type: 3,
|
||||||
|
description: "The code to execute",
|
||||||
|
required: true
|
||||||
|
}];
|
||||||
|
|
||||||
static description = "Executes JavaScript code";
|
static description = "Executes JavaScript code";
|
||||||
static aliases = ["run"];
|
static aliases = ["run"];
|
||||||
static arguments = ["[code]"];
|
static arguments = ["[code]"];
|
||||||
|
|
|
@ -25,6 +25,7 @@ class EvalRawCommand extends Command {
|
||||||
static description = "Executes JavaScript code (with raw output)";
|
static description = "Executes JavaScript code (with raw output)";
|
||||||
static aliases = ["run"];
|
static aliases = ["run"];
|
||||||
static arguments = ["[code]"];
|
static arguments = ["[code]"];
|
||||||
|
static slashAllowed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EvalRawCommand;
|
export default EvalRawCommand;
|
|
@ -8,7 +8,8 @@ class ExecCommand extends Command {
|
||||||
async run() {
|
async run() {
|
||||||
const owners = process.env.OWNER.split(",");
|
const owners = process.env.OWNER.split(",");
|
||||||
if (!owners.includes(this.author.id)) return "Only the bot owner can use exec!";
|
if (!owners.includes(this.author.id)) return "Only the bot owner can use exec!";
|
||||||
const code = this.args.join(" ");
|
await this.acknowledge();
|
||||||
|
const code = this.type === "classic" ? this.args.join(" ") : this.options.cmd;
|
||||||
try {
|
try {
|
||||||
const execed = await exec(code);
|
const execed = await exec(code);
|
||||||
if (execed.stderr) return `\`ERROR\` \`\`\`xl\n${await clean(execed.stderr)}\n\`\`\``;
|
if (execed.stderr) return `\`ERROR\` \`\`\`xl\n${await clean(execed.stderr)}\n\`\`\``;
|
||||||
|
@ -28,6 +29,13 @@ class ExecCommand extends Command {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static flags = [{
|
||||||
|
name: "cmd",
|
||||||
|
type: 3,
|
||||||
|
description: "The command to execute",
|
||||||
|
required: true
|
||||||
|
}];
|
||||||
|
|
||||||
static description = "Executes a shell command";
|
static description = "Executes a shell command";
|
||||||
static aliases = ["runcmd"];
|
static aliases = ["runcmd"];
|
||||||
static arguments = ["[command]"];
|
static arguments = ["[command]"];
|
||||||
|
|
|
@ -93,7 +93,7 @@ class HelpCommand extends Command {
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return paginator(this.client, this.message, embeds);
|
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, embeds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,11 @@ import Command from "../../classes/command.js";
|
||||||
class ImageSearchCommand extends Command {
|
class ImageSearchCommand extends Command {
|
||||||
async run() {
|
async run() {
|
||||||
if (this.channel.guild && !this.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
|
if (this.channel.guild && !this.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
|
||||||
if (this.args.length === 0) return "You need to provide something to search for!";
|
const query = this.type === "classic" ? this.args.join(" ") : this.options.query;
|
||||||
|
if (!query || !query.trim()) return "You need to provide something to search for!";
|
||||||
this.acknowledge();
|
this.acknowledge();
|
||||||
const embeds = [];
|
const embeds = [];
|
||||||
const rawImages = await fetch(`${random(searx)}/search?format=json&safesearch=2&categories=images&q=!goi%20!ddi%20${encodeURIComponent(this.args.join(" "))}`).then(res => res.json());
|
const rawImages = await fetch(`${random(searx)}/search?format=json&safesearch=2&categories=images&q=!goi%20!ddi%20${encodeURIComponent(query)}`).then(res => res.json());
|
||||||
if (rawImages.results.length === 0) return "I couldn't find any results!";
|
if (rawImages.results.length === 0) return "I couldn't find any results!";
|
||||||
const images = rawImages.results.filter((val) => !val.img_src.startsWith("data:"));
|
const images = rawImages.results.filter((val) => !val.img_src.startsWith("data:"));
|
||||||
for (const [i, value] of images.entries()) {
|
for (const [i, value] of images.entries()) {
|
||||||
|
@ -33,9 +34,16 @@ class ImageSearchCommand extends Command {
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return paginator(this.client, this.message, embeds);
|
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, embeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static flags = [{
|
||||||
|
name: "query",
|
||||||
|
type: 3,
|
||||||
|
description: "The query you want to search for",
|
||||||
|
required: true
|
||||||
|
}];
|
||||||
|
|
||||||
static description = "Searches for images across the web";
|
static description = "Searches for images across the web";
|
||||||
static aliases = ["im", "photo", "img"];
|
static aliases = ["im", "photo", "img"];
|
||||||
static arguments = ["[query]"];
|
static arguments = ["[query]"];
|
||||||
|
|
|
@ -6,12 +6,14 @@ class ReloadCommand extends Command {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const owners = process.env.OWNER.split(",");
|
const owners = process.env.OWNER.split(",");
|
||||||
if (!owners.includes(this.author.id)) return resolve("Only the bot owner can reload commands!");
|
if (!owners.includes(this.author.id)) return resolve("Only the bot owner can reload commands!");
|
||||||
if (this.args.length === 0) return resolve("You need to provide a command to reload!");
|
const commandName = this.type === "classic" ? this.args.join(" ") : this.options.cmd;
|
||||||
this.ipc.broadcast("reload", this.args[0]);
|
if (!commandName || !commandName.trim()) return resolve("You need to provide a command to reload!");
|
||||||
|
this.acknowledge();
|
||||||
|
this.ipc.broadcast("reload", commandName);
|
||||||
this.ipc.register("reloadSuccess", () => {
|
this.ipc.register("reloadSuccess", () => {
|
||||||
this.ipc.unregister("reloadSuccess");
|
this.ipc.unregister("reloadSuccess");
|
||||||
this.ipc.unregister("reloadFail");
|
this.ipc.unregister("reloadFail");
|
||||||
resolve(`The command \`${this.args[0]}\` has been reloaded.`);
|
resolve(`The command \`${commandName}\` has been reloaded.`);
|
||||||
});
|
});
|
||||||
this.ipc.register("reloadFail", (message) => {
|
this.ipc.register("reloadFail", (message) => {
|
||||||
this.ipc.unregister("reloadSuccess");
|
this.ipc.unregister("reloadSuccess");
|
||||||
|
@ -21,6 +23,13 @@ class ReloadCommand extends Command {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static flags = [{
|
||||||
|
name: "cmd",
|
||||||
|
type: 3,
|
||||||
|
description: "The command to reload",
|
||||||
|
required: true
|
||||||
|
}];
|
||||||
|
|
||||||
static description = "Reloads a command";
|
static description = "Reloads a command";
|
||||||
static arguments = ["[command]"];
|
static arguments = ["[command]"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ class UserInfoCommand extends Command {
|
||||||
static description = "Gets info about a user";
|
static description = "Gets info about a user";
|
||||||
static aliases = ["user"];
|
static aliases = ["user"];
|
||||||
static arguments = ["[mention/id]"];
|
static arguments = ["[mention/id]"];
|
||||||
|
static slashAllowed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UserInfoCommand;
|
export default UserInfoCommand;
|
||||||
|
|
|
@ -7,17 +7,25 @@ import Command from "../../classes/command.js";
|
||||||
|
|
||||||
class YouTubeCommand extends Command {
|
class YouTubeCommand extends Command {
|
||||||
async run() {
|
async run() {
|
||||||
if (this.args.length === 0) return "You need to provide something to search for!";
|
const query = this.type === "classic" ? this.args.join(" ") : this.options.query;
|
||||||
|
if (!query || !query.trim()) return "You need to provide something to search for!";
|
||||||
this.acknowledge();
|
this.acknowledge();
|
||||||
const messages = [];
|
const messages = [];
|
||||||
const videos = await fetch(`${random(searx)}/search?format=json&safesearch=1&categories=videos&q=!youtube%20${encodeURIComponent(this.args.join(" "))}`).then(res => res.json());
|
const videos = await fetch(`${random(searx)}/search?format=json&safesearch=1&categories=videos&q=!youtube%20${encodeURIComponent(query)}`).then(res => res.json());
|
||||||
if (videos.results.length === 0) return "I couldn't find any results!";
|
if (videos.results.length === 0) return "I couldn't find any results!";
|
||||||
for (const [i, value] of videos.results.entries()) {
|
for (const [i, value] of videos.results.entries()) {
|
||||||
messages.push({ content: `Page ${i + 1} of ${videos.results.length}\n<:youtube:637020823005167626> **${value.title.replaceAll("*", "\\*")}**\nUploaded by **${value.author.replaceAll("*", "\\*")}**\n${value.url}` });
|
messages.push({ content: `Page ${i + 1} of ${videos.results.length}\n<:youtube:637020823005167626> **${value.title.replaceAll("*", "\\*")}**\nUploaded by **${value.author.replaceAll("*", "\\*")}**\n${value.url}` });
|
||||||
}
|
}
|
||||||
return paginator(this.client, this.message, messages);
|
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static flags = [{
|
||||||
|
name: "query",
|
||||||
|
type: 3,
|
||||||
|
description: "The query you want to search for",
|
||||||
|
required: true
|
||||||
|
}];
|
||||||
|
|
||||||
static description = "Searches YouTube";
|
static description = "Searches YouTube";
|
||||||
static aliases = ["yt", "video", "ytsearch"];
|
static aliases = ["yt", "video", "ytsearch"];
|
||||||
static arguments = ["[query]"];
|
static arguments = ["[query]"];
|
||||||
|
|
|
@ -7,16 +7,17 @@ class FlagCommand extends ImageCommand {
|
||||||
flagPath = "";
|
flagPath = "";
|
||||||
|
|
||||||
async criteria() {
|
async criteria() {
|
||||||
if (!this.args[0].match(emojiRegex)) return false;
|
const text = this.type === "classic" ? this.args[0] : this.options.text;
|
||||||
const flag = emoji.unemojify(this.args[0]).replaceAll(":", "").replace("flag-", "");
|
if (!text.match(emojiRegex)) return false;
|
||||||
|
const flag = emoji.unemojify(text).replaceAll(":", "").replace("flag-", "");
|
||||||
let path = `./assets/images/region-flags/png/${flag.toUpperCase()}.png`;
|
let path = `./assets/images/region-flags/png/${flag.toUpperCase()}.png`;
|
||||||
if (flag === "pirate_flag") path = "./assets/images/pirateflag.png";
|
if (flag === "pirate_flag") path = "./assets/images/pirateflag.png";
|
||||||
if (flag === "rainbow-flag") path = "./assets/images/rainbowflag.png";
|
if (flag === "rainbow-flag") path = "./assets/images/rainbowflag.png";
|
||||||
if (flag === "checkered_flag") path = "./assets/images/checkeredflag.png";
|
if (flag === "checkered_flag") path = "./assets/images/checkeredflag.png";
|
||||||
if (flag === "transgender_flag") path = "./assets/images/transflag.png";
|
if (flag === "transgender_flag") path = "./assets/images/transflag.png";
|
||||||
if (this.args[0] === "🏴") path = "./assets/images/region-flags/png/GB-SCT.png";
|
if (text === "🏴") path = "./assets/images/region-flags/png/GB-SCT.png";
|
||||||
if (this.args[0] === "🏴") path = "./assets/images/region-flags/png/GB-WLS.png";
|
if (text === "🏴") path = "./assets/images/region-flags/png/GB-WLS.png";
|
||||||
if (this.args[0] === "🏴") path = "./assets/images/region-flags/png/GB-ENG.png";
|
if (text === "🏴") path = "./assets/images/region-flags/png/GB-ENG.png";
|
||||||
try {
|
try {
|
||||||
await fs.promises.access(path);
|
await fs.promises.access(path);
|
||||||
this.flagPath = path;
|
this.flagPath = path;
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
import ImageCommand from "../../classes/imageCommand.js";
|
import ImageCommand from "../../classes/imageCommand.js";
|
||||||
|
|
||||||
class FreezeCommand extends ImageCommand {
|
class FreezeCommand extends ImageCommand {
|
||||||
|
constructor(client, cluster, worker, ipc, options) {
|
||||||
|
super(client, cluster, worker, ipc, options);
|
||||||
|
this.flags.push({
|
||||||
|
name: "endframe",
|
||||||
|
type: 4,
|
||||||
|
description: "Set the end frame (default: last frame)",
|
||||||
|
min_value: 0
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
params() {
|
params() {
|
||||||
const frameCount = parseInt(this.args[0]);
|
const frameCount = parseInt(this.type === "classic" ? this.args[0] : this.options.endframe);
|
||||||
return {
|
return {
|
||||||
loop: false,
|
loop: false,
|
||||||
frame: isNaN(frameCount) ? -1 : frameCount
|
frame: isNaN(frameCount) ? -1 : frameCount
|
||||||
|
|
|
@ -1,8 +1,19 @@
|
||||||
import ImageCommand from "../../classes/imageCommand.js";
|
import ImageCommand from "../../classes/imageCommand.js";
|
||||||
|
|
||||||
class JPEGCommand extends ImageCommand {
|
class JPEGCommand extends ImageCommand {
|
||||||
|
constructor(client, cluster, worker, ipc, options) {
|
||||||
|
super(client, cluster, worker, ipc, options);
|
||||||
|
this.flags.push({
|
||||||
|
name: "quality",
|
||||||
|
type: 4,
|
||||||
|
description: "Set the JPEG quality (default: 1)",
|
||||||
|
min_value: 1,
|
||||||
|
max_value: 100
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
params() {
|
params() {
|
||||||
const quality = parseInt(this.args[0]);
|
const quality = parseInt(this.type === "classic" ? this.args[0] : this.options.quality);
|
||||||
return {
|
return {
|
||||||
quality: isNaN(quality) ? 1 : Math.max(1, Math.min(quality, 100))
|
quality: isNaN(quality) ? 1 : Math.max(1, Math.min(quality, 100))
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,8 +19,8 @@ class MotivateCommand extends ImageCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
params(url) {
|
params(url) {
|
||||||
const newArgs = this.args.filter(item => !item.includes(url));
|
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
|
||||||
const [topText, bottomText] = newArgs.join(" ").split(/(?<!\\),/).map(elem => elem.trim());
|
const [topText, bottomText] = newArgs.split(/(?<!\\),/).map(elem => elem.trim());
|
||||||
return {
|
return {
|
||||||
top: topText.replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%"),
|
top: topText.replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%"),
|
||||||
bottom: bottomText ? bottomText.replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%") : "",
|
bottom: bottomText ? bottomText.replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%") : "",
|
||||||
|
|
|
@ -3,9 +3,10 @@ import { random } from "../../utils/misc.js";
|
||||||
const names = ["esmBot", "me_irl", "dankmemes", "hmmm", "gaming", "wholesome", "chonkers", "memes", "funny", "pcmasterrace", "thomastheplankengine"];
|
const names = ["esmBot", "me_irl", "dankmemes", "hmmm", "gaming", "wholesome", "chonkers", "memes", "funny", "pcmasterrace", "thomastheplankengine"];
|
||||||
|
|
||||||
class RedditCommand extends ImageCommand {
|
class RedditCommand extends ImageCommand {
|
||||||
params() {
|
params(url) {
|
||||||
|
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
|
||||||
return {
|
return {
|
||||||
caption: this.args.length === 0 ? random(names) : this.args.join(" ").replaceAll("\n", "").replaceAll(" ", "")
|
caption: newArgs && newArgs.trim() ? newArgs.replaceAll("\n", "").replaceAll(" ", "") : random(names)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
import ImageCommand from "../../classes/imageCommand.js";
|
import ImageCommand from "../../classes/imageCommand.js";
|
||||||
|
|
||||||
class SlowCommand extends ImageCommand {
|
class SlowCommand extends ImageCommand {
|
||||||
|
constructor(client, cluster, worker, ipc, options) {
|
||||||
|
super(client, cluster, worker, ipc, options);
|
||||||
|
this.flags.push({
|
||||||
|
name: "multiplier",
|
||||||
|
type: 4,
|
||||||
|
description: "Set the speed multiplier (default: 2)",
|
||||||
|
min_value: 1
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
params() {
|
params() {
|
||||||
const speed = parseInt(this.args[0]);
|
const speed = parseInt(this.type === "classic" ? this.args[0] : this.options.multiplier);
|
||||||
return {
|
return {
|
||||||
slow: true,
|
slow: true,
|
||||||
speed: isNaN(speed) ? 2 : speed
|
speed: isNaN(speed) ? 2 : speed
|
||||||
|
|
|
@ -13,10 +13,10 @@ class SnapchatCommand extends ImageCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
params(url) {
|
params(url) {
|
||||||
const newArgs = this.args.filter(item => !item.includes(url));
|
const newArgs = this.type === "classic" ? this.args.filter(item => !item.includes(url)).join(" ") : this.options.text;
|
||||||
const position = parseFloat(this.specialArgs.position);
|
const position = parseFloat(this.specialArgs.position);
|
||||||
return {
|
return {
|
||||||
caption: newArgs.join(" ").replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%"),
|
caption: newArgs.replaceAll("&", "\\&").replaceAll(">", "\\>").replaceAll("<", "\\<").replaceAll("\"", "\\"").replaceAll("'", "\\'").replaceAll("%", "\\%"),
|
||||||
pos: isNaN(position) ? 0.5 : position
|
pos: isNaN(position) ? 0.5 : position
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class QueueCommand extends MusicCommand {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (embeds.length === 0) return "There's nothing in the queue!";
|
if (embeds.length === 0) return "There's nothing in the queue!";
|
||||||
return paginator(this.client, this.message, embeds);
|
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, embeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static description = "Shows the current queue";
|
static description = "Shows the current queue";
|
||||||
|
|
|
@ -75,7 +75,7 @@ class TagsCommand extends Command {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (embeds.length === 0) return "I couldn't find any tags!";
|
if (embeds.length === 0) return "I couldn't find any tags!";
|
||||||
return paginator(this.client, this.message, embeds);
|
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, embeds);
|
||||||
} else if (this.args[0].toLowerCase() === "random") {
|
} else if (this.args[0].toLowerCase() === "random") {
|
||||||
const tagList = await database.getTags(this.channel.guild.id);
|
const tagList = await database.getTags(this.channel.guild.id);
|
||||||
return tagList[random(Object.keys(tagList))].content;
|
return tagList[random(Object.keys(tagList))].content;
|
||||||
|
|
5
events/debug.js
Normal file
5
events/debug.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import { debug } from "../utils/logger.js";
|
||||||
|
|
||||||
|
export default async (client, cluster, worker, ipc, message) => {
|
||||||
|
debug(message);
|
||||||
|
};
|
4
shard.js
4
shard.js
|
@ -80,8 +80,8 @@ class Shard extends BaseClusterWorker {
|
||||||
this.ipc.register("reload", async (message) => {
|
this.ipc.register("reload", async (message) => {
|
||||||
const path = paths.get(message);
|
const path = paths.get(message);
|
||||||
if (!path) return this.ipc.broadcast("reloadFail", { result: "I couldn't find that command!" });
|
if (!path) return this.ipc.broadcast("reloadFail", { result: "I couldn't find that command!" });
|
||||||
const result = await load(this.bot, this.clusterID, this.workerID, this.ipc, path, await checkStatus());
|
const result = await load(this.bot, this.clusterID, this.workerID, this.ipc, path, await checkStatus(), true);
|
||||||
if (result) return this.ipc.broadcast("reloadFail", { result });
|
if (result !== message) return this.ipc.broadcast("reloadFail", { result });
|
||||||
return this.ipc.broadcast("reloadSuccess");
|
return this.ipc.broadcast("reloadSuccess");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { log } from "./logger.js";
|
||||||
let queryValue = 0;
|
let queryValue = 0;
|
||||||
|
|
||||||
// load command into memory
|
// load command into memory
|
||||||
export async function load(client, cluster, worker, ipc, command, soundStatus) {
|
export async function load(client, cluster, worker, ipc, command, soundStatus, slashReload = false) {
|
||||||
const { default: props } = await import(`${command}?v=${queryValue}`);
|
const { default: props } = await import(`${command}?v=${queryValue}`);
|
||||||
queryValue++;
|
queryValue++;
|
||||||
if (props.requires.includes("sound") && soundStatus) {
|
if (props.requires.includes("sound") && soundStatus) {
|
||||||
|
@ -28,6 +28,19 @@ export async function load(client, cluster, worker, ipc, command, soundStatus) {
|
||||||
slashAllowed: props.slashAllowed
|
slashAllowed: props.slashAllowed
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (slashReload && props.slashAllowed) {
|
||||||
|
const commandList = await client.getCommands();
|
||||||
|
const oldCommand = commandList.filter((item) => {
|
||||||
|
return item.name === commandName;
|
||||||
|
})[0];
|
||||||
|
await client.editCommand(oldCommand.id, {
|
||||||
|
name: commandName,
|
||||||
|
type: 1,
|
||||||
|
description: props.description,
|
||||||
|
options: propsInstance.flags ?? props.flags
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (props.aliases) {
|
if (props.aliases) {
|
||||||
for (const alias of props.aliases) {
|
for (const alias of props.aliases) {
|
||||||
_aliases.set(alias, commandName);
|
_aliases.set(alias, commandName);
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import InteractionCollector from "./awaitinteractions.js";
|
import InteractionCollector from "./awaitinteractions.js";
|
||||||
import { ComponentInteraction } from "eris";
|
import { ComponentInteraction } from "eris";
|
||||||
|
|
||||||
export default async (client, message, pages, timeout = 120000) => {
|
export default async (client, info, pages, timeout = 120000) => {
|
||||||
const options = {
|
const options = info.type === "classic" ? {
|
||||||
messageReference: {
|
messageReference: {
|
||||||
channelID: message.channel.id,
|
channelID: info.channel.id,
|
||||||
messageID: message.id,
|
messageID: info.message.id,
|
||||||
guildID: message.channel.guild ? message.channel.guild.id : undefined,
|
guildID: info.channel.guild ? info.channel.guild.id : undefined,
|
||||||
failIfNotExists: false
|
failIfNotExists: false
|
||||||
},
|
},
|
||||||
allowedMentions: {
|
allowedMentions: {
|
||||||
repliedUser: false
|
repliedUser: false
|
||||||
}
|
}
|
||||||
};
|
} : {};
|
||||||
let page = 0;
|
let page = 0;
|
||||||
const components = {
|
const components = {
|
||||||
components: [{
|
components: [{
|
||||||
|
@ -61,11 +61,18 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
let currentPage = await client.createMessage(message.channel.id, Object.assign(pages[page], options, pages.length > 1 ? components : {}));
|
let currentPage;
|
||||||
|
if (info.type === "classic") {
|
||||||
|
currentPage = await client.createMessage(info.message.channel.id, Object.assign(pages[page], options, pages.length > 1 ? components : {}));
|
||||||
|
} else {
|
||||||
|
await info.interaction[info.interaction.acknowledged ? "editOriginalMessage" : "createMessage"](Object.assign(pages[page], pages.length > 1 ? components : {}));
|
||||||
|
currentPage = await info.interaction.getOriginalMessage();
|
||||||
|
}
|
||||||
|
|
||||||
if (pages.length > 1) {
|
if (pages.length > 1) {
|
||||||
const interactionCollector = new InteractionCollector(client, currentPage, ComponentInteraction, timeout);
|
const interactionCollector = new InteractionCollector(client, currentPage, ComponentInteraction, timeout);
|
||||||
interactionCollector.on("interaction", async (interaction) => {
|
interactionCollector.on("interaction", async (interaction) => {
|
||||||
if ((interaction.member ?? interaction.user).id === message.author.id) {
|
if ((interaction.member ?? interaction.user).id === info.author.id) {
|
||||||
switch (interaction.data.custom_id) {
|
switch (interaction.data.custom_id) {
|
||||||
case "back":
|
case "back":
|
||||||
await interaction.deferUpdate();
|
await interaction.deferUpdate();
|
||||||
|
@ -105,7 +112,9 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
};
|
};
|
||||||
jumpComponents.components[0].components[0].options[i] = payload;
|
jumpComponents.components[0].components[0].options[i] = payload;
|
||||||
}
|
}
|
||||||
client.createMessage(message.channel.id, Object.assign({ content: "What page do you want to jump to?" }, {
|
var promise;
|
||||||
|
if (info.type === "classic") {
|
||||||
|
promise = client.createMessage(info.message.channel.id, Object.assign({ content: "What page do you want to jump to?" }, {
|
||||||
messageReference: {
|
messageReference: {
|
||||||
channelID: currentPage.channel.id,
|
channelID: currentPage.channel.id,
|
||||||
messageID: currentPage.id,
|
messageID: currentPage.id,
|
||||||
|
@ -115,7 +124,11 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
allowedMentions: {
|
allowedMentions: {
|
||||||
repliedUser: false
|
repliedUser: false
|
||||||
}
|
}
|
||||||
}, jumpComponents)).then(askMessage => {
|
}, jumpComponents));
|
||||||
|
} else {
|
||||||
|
promise = info.interaction.createFollowup(Object.assign({ content: "What page do you want to jump to?" }, jumpComponents));
|
||||||
|
}
|
||||||
|
promise.then(askMessage => {
|
||||||
const dropdownCollector = new InteractionCollector(client, askMessage, ComponentInteraction, timeout);
|
const dropdownCollector = new InteractionCollector(client, askMessage, ComponentInteraction, timeout);
|
||||||
let ended = false;
|
let ended = false;
|
||||||
dropdownCollector.on("interaction", async (response) => {
|
dropdownCollector.on("interaction", async (response) => {
|
||||||
|
@ -145,7 +158,7 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
break;
|
break;
|
||||||
case "delete":
|
case "delete":
|
||||||
await interaction.deferUpdate();
|
await interaction.deferUpdate();
|
||||||
interactionCollector.emit("end");
|
interactionCollector.emit("end", true);
|
||||||
if (currentPage.channel.messages ? currentPage.channel.messages.has(currentPage.id) : await client.getMessage(currentPage.channel.id, currentPage.id).catch(() => undefined)) await currentPage.delete();
|
if (currentPage.channel.messages ? currentPage.channel.messages.has(currentPage.id) : await client.getMessage(currentPage.channel.id, currentPage.id).catch(() => undefined)) await currentPage.delete();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
@ -153,14 +166,16 @@ export default async (client, message, pages, timeout = 120000) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
interactionCollector.once("end", async () => {
|
interactionCollector.once("end", async (deleted = false) => {
|
||||||
interactionCollector.removeAllListeners("interaction");
|
interactionCollector.removeAllListeners("interaction");
|
||||||
|
if (!deleted) {
|
||||||
for (const index of components.components[0].components.keys()) {
|
for (const index of components.components[0].components.keys()) {
|
||||||
components.components[0].components[index].disabled = true;
|
components.components[0].components[index].disabled = true;
|
||||||
}
|
}
|
||||||
if (currentPage.channel.messages ? currentPage.channel.messages.has(currentPage.id) : await client.getMessage(currentPage.channel.id, currentPage.id).catch(() => undefined)) {
|
if (currentPage.channel.messages ? currentPage.channel.messages.has(currentPage.id) : await client.getMessage(currentPage.channel.id, currentPage.id).catch(() => undefined)) {
|
||||||
await currentPage.edit(components);
|
await currentPage.edit(components);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue