Slash command preparations
This commit is contained in:
parent
a438fe26df
commit
f996180fa9
20 changed files with 136 additions and 34 deletions
|
@ -3,7 +3,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class AncientCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
const controller = new AbortController(); // eslint-disable-line no-undef
|
||||
const timeout = setTimeout(() => {
|
||||
controller.abort();
|
||||
|
|
|
@ -3,7 +3,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class BirdCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
const imageData = await fetch("http://shibe.online/api/birds");
|
||||
const json = await imageData.json();
|
||||
return {
|
||||
|
|
|
@ -3,7 +3,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class CatCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
const controller = new AbortController(); // eslint-disable-line no-undef
|
||||
const timeout = setTimeout(() => {
|
||||
controller.abort();
|
||||
|
|
|
@ -3,7 +3,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class DogCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
const imageData = await fetch("https://dog.ceo/api/breeds/image/random");
|
||||
const json = await imageData.json();
|
||||
return {
|
||||
|
|
|
@ -4,7 +4,7 @@ import Command from "../../classes/command.js";
|
|||
class MCCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return "You need to provide some text to generate a Minecraft achievement!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
const request = await fetch(`https://www.minecraftskinstealer.com/achievement/a.php?i=13&h=Achievement+get%21&t=${encodeURIComponent(this.args.join("+"))}`);
|
||||
return {
|
||||
file: Buffer.from(await request.arrayBuffer()),
|
||||
|
|
|
@ -3,7 +3,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class WikihowCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
const request = await fetch("https://www.wikihow.com/api.php?action=query&generator=random&prop=imageinfo&format=json&iiprop=url&grnnamespace=6");
|
||||
const json = await request.json();
|
||||
const id = Object.keys(json.query.pages)[0];
|
||||
|
|
|
@ -3,6 +3,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class ChannelCommand extends Command {
|
||||
async run() {
|
||||
if (this.type !== "classic") return "This command only works with the old command style!";
|
||||
if (!this.message.channel.guild) return "This command only works in servers!";
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!this.message.member.permissions.has("administrator") && !owners.includes(this.message.member.id)) return "You need to be an administrator to enable/disable me!";
|
||||
|
@ -40,8 +41,9 @@ class ChannelCommand extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
static description = "Enables/disables me in a channel";
|
||||
static description = "Enables/disables me in a channel (does not work with slash commands)";
|
||||
static arguments = ["[enable/disable]", "{id}"];
|
||||
static slashAllowed = false;
|
||||
}
|
||||
|
||||
export default ChannelCommand;
|
||||
|
|
|
@ -3,7 +3,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class DonateCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
let prefix = "";
|
||||
const controller = new AbortController(); // eslint-disable-line no-undef
|
||||
const timeout = setTimeout(() => {
|
||||
|
|
|
@ -9,7 +9,7 @@ class ImageSearchCommand extends Command {
|
|||
async run() {
|
||||
if (this.message.channel.guild && !this.message.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!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
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());
|
||||
if (rawImages.results.length === 0) return "I couldn't find any results!";
|
||||
|
|
|
@ -2,7 +2,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class ImageStatsCommand extends Command {
|
||||
async run() {
|
||||
await this.client.sendChannelTyping(this.message.channel.id);
|
||||
await this.acknowledge();
|
||||
const servers = await this.ipc.serviceCommand("image", { type: "stats" }, true);
|
||||
const embed = {
|
||||
embeds: [{
|
||||
|
|
|
@ -4,7 +4,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class LengthenCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
if (this.args.length === 0 || !urlCheck(this.args[0])) return "You need to provide a short URL to lengthen!";
|
||||
if (urlCheck(this.args[0])) {
|
||||
const url = await fetch(encodeURI(this.args[0]), { redirect: "manual" });
|
||||
|
|
|
@ -5,7 +5,7 @@ import Command from "../../classes/command.js";
|
|||
class QrCreateCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return "You need to provide some text to generate a QR code!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
const writable = new PassThrough();
|
||||
qrcode.toFileStream(writable, this.content, { margin: 1 });
|
||||
const file = await this.streamToBuf(writable);
|
||||
|
|
|
@ -9,7 +9,7 @@ class QrReadCommand extends Command {
|
|||
async run() {
|
||||
const image = await imageDetect(this.client, this.message);
|
||||
if (image === undefined) return "You need to provide an image/GIF with a QR code to read!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
const data = await (await fetch(image.path)).buffer();
|
||||
const rawData = await sharp(data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
|
||||
|
|
|
@ -3,7 +3,7 @@ import imageDetect from "../../utils/imagedetect.js";
|
|||
|
||||
class RawCommand extends Command {
|
||||
async run() {
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
const image = await imageDetect(this.client, this.message);
|
||||
if (image === undefined) return "You need to provide an image/GIF to get a raw URL!";
|
||||
return image.path;
|
||||
|
|
|
@ -6,7 +6,7 @@ class SoundReloadCommand extends Command {
|
|||
return new Promise((resolve) => {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.message.author.id)) return "Only the bot owner can reload Lavalink!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
this.ipc.broadcast("soundreload");
|
||||
this.ipc.register("soundReloadSuccess", (msg) => {
|
||||
this.ipc.unregister("soundReloadSuccess");
|
||||
|
|
|
@ -8,7 +8,7 @@ import Command from "../../classes/command.js";
|
|||
class YouTubeCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) return "You need to provide something to search for!";
|
||||
this.client.sendChannelTyping(this.message.channel.id);
|
||||
this.acknowledge();
|
||||
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());
|
||||
if (videos.results.length === 0) return "I couldn't find any results!";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue