initial update
This commit is contained in:
parent
3272429cf6
commit
db9b70bf66
280 changed files with 11772 additions and 11966 deletions
|
@ -1,53 +1,53 @@
|
|||
import Command from "../../classes/command.js";
|
||||
const mentionRegex = /^<?[@#]?[&!]?(\d+)>?$/;
|
||||
|
||||
class AvatarCommand extends Command {
|
||||
async run() {
|
||||
const member = this.options.member ?? this.args[0];
|
||||
const self = this.client.users.get(this.author.id) ?? await this.client.rest.users.get(this.author.id);
|
||||
if (this.type === "classic" && this.message.mentions.users[0]) {
|
||||
return this.message.mentions.users[0].avatarURL(null, 512);
|
||||
} else if (member && member > 21154535154122752n) {
|
||||
const user = this.client.users.get(member) ?? await this.client.rest.users.get(member);
|
||||
if (user) {
|
||||
return user.avatarURL(null, 512);
|
||||
} else if (mentionRegex.test(member)) {
|
||||
const id = member.match(mentionRegex)[1];
|
||||
if (id < 21154535154122752n) {
|
||||
this.success = false;
|
||||
return "That's not a valid mention!";
|
||||
}
|
||||
try {
|
||||
const user = this.client.users.get(id) ?? await this.client.rest.users.get(id);
|
||||
return user.avatarURL(null, 512);
|
||||
} catch {
|
||||
return self.avatarURL(null, 512);
|
||||
}
|
||||
} else {
|
||||
return self.avatarURL(null, 512);
|
||||
}
|
||||
} else if (this.args.join(" ") !== "" && this.guild) {
|
||||
const searched = await this.guild.searchMembers({
|
||||
query: this.args.join(" "),
|
||||
limit: 1
|
||||
});
|
||||
if (searched.length === 0) return self.avatarURL(null, 512);
|
||||
const user = this.client.users.get(searched[0].user.id) ?? await this.client.rest.users.get(searched[0].user.id);
|
||||
return user ? user.avatarURL(null, 512) : self.avatarURL(null, 512);
|
||||
} else {
|
||||
return self.avatarURL(null, 512);
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Gets a user's avatar";
|
||||
static aliases = ["pfp", "ava"];
|
||||
static arguments = ["{mention/id}"];
|
||||
static flags = [{
|
||||
name: "member",
|
||||
type: 6,
|
||||
description: "The member to get the avatar from",
|
||||
required: false
|
||||
}];
|
||||
}
|
||||
|
||||
export default AvatarCommand;
|
||||
import Command from "../../classes/command.js";
|
||||
const mentionRegex = /^<?[@#]?[&!]?(\d+)>?$/;
|
||||
|
||||
class AvatarCommand extends Command {
|
||||
async run() {
|
||||
const member = this.options.member ?? this.args[0];
|
||||
const self = this.client.users.get(this.author.id) ?? await this.client.rest.users.get(this.author.id);
|
||||
if (this.type === "classic" && this.message.mentions.users[0]) {
|
||||
return this.message.mentions.users[0].avatarURL(null, 512);
|
||||
} else if (member && member > 21154535154122752n) {
|
||||
const user = this.client.users.get(member) ?? await this.client.rest.users.get(member);
|
||||
if (user) {
|
||||
return user.avatarURL(null, 512);
|
||||
} else if (mentionRegex.test(member)) {
|
||||
const id = member.match(mentionRegex)[1];
|
||||
if (id < 21154535154122752n) {
|
||||
this.success = false;
|
||||
return "That's not a valid mention!";
|
||||
}
|
||||
try {
|
||||
const user = this.client.users.get(id) ?? await this.client.rest.users.get(id);
|
||||
return user.avatarURL(null, 512);
|
||||
} catch {
|
||||
return self.avatarURL(null, 512);
|
||||
}
|
||||
} else {
|
||||
return self.avatarURL(null, 512);
|
||||
}
|
||||
} else if (this.args.join(" ") !== "" && this.guild) {
|
||||
const searched = await this.guild.searchMembers({
|
||||
query: this.args.join(" "),
|
||||
limit: 1
|
||||
});
|
||||
if (searched.length === 0) return self.avatarURL(null, 512);
|
||||
const user = this.client.users.get(searched[0].user.id) ?? await this.client.rest.users.get(searched[0].user.id);
|
||||
return user ? user.avatarURL(null, 512) : self.avatarURL(null, 512);
|
||||
} else {
|
||||
return self.avatarURL(null, 512);
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Gets a user's avatar";
|
||||
static aliases = ["pfp", "ava"];
|
||||
static arguments = ["{mention/id}"];
|
||||
static flags = [{
|
||||
name: "member",
|
||||
type: 6,
|
||||
description: "The member to get the avatar from",
|
||||
required: false
|
||||
}];
|
||||
}
|
||||
|
||||
export default AvatarCommand;
|
||||
|
|
|
@ -1,55 +1,55 @@
|
|||
import Command from "../../classes/command.js";
|
||||
import { Routes } from "oceanic.js";
|
||||
const mentionRegex = /^<?[@#]?[&!]?(\d+)>?$/;
|
||||
|
||||
class BannerCommand extends Command {
|
||||
// this command sucks
|
||||
async run() {
|
||||
const member = this.options.member ?? this.args[0];
|
||||
const self = await this.client.rest.users.get(this.author.id); // banners are only available over REST
|
||||
if (this.type === "classic" && this.message.mentions.users[0] && this.message.mentions.users[0].banner) {
|
||||
return this.client.util.formatImage(Routes.BANNER(this.message.mentions.users[0].id, this.message.mentions.users[0].banner), null, 512);
|
||||
} else if (member && member > 21154535154122752n) {
|
||||
const user = await this.client.rest.users.get(member);
|
||||
if (user && user.banner) {
|
||||
return this.client.util.formatImage(Routes.BANNER(user.id, user.banner), null, 512);
|
||||
} else if (mentionRegex.test(member)) {
|
||||
const id = member.match(mentionRegex)[1];
|
||||
if (id < 21154535154122752n) {
|
||||
this.success = false;
|
||||
return "That's not a valid mention!";
|
||||
}
|
||||
try {
|
||||
const user = await this.client.rest.users.get(id);
|
||||
return user.banner ? this.client.util.formatImage(Routes.BANNER(user.id, user.banner), null, 512) : "This user doesn't have a banner!";
|
||||
} catch {
|
||||
return self.banner ? this.client.util.formatImage(Routes.BANNER(self.id, self.banner), null, 512) : "You don't have a banner!";
|
||||
}
|
||||
} else {
|
||||
return "This user doesn't have a banner!";
|
||||
}
|
||||
} else if (this.args.join(" ") !== "" && this.guild) {
|
||||
const searched = await this.guild.searchMembers({
|
||||
query: this.args.join(" "),
|
||||
limit: 1
|
||||
});
|
||||
if (searched.length === 0) return self.banner ? this.client.util.formatImage(Routes.BANNER(self.id, self.banner), null, 512) : "This user doesn't have a banner!";
|
||||
const user = await this.client.rest.users.get(searched[0].user.id);
|
||||
return user.banner ? this.client.util.formatImage(Routes.BANNER(user.id, user.banner), null, 512) : (self.banner ? this.client.util.formatImage(Routes.BANNER(self.id, self.banner), null, 512) : "This user doesn't have a banner!");
|
||||
} else {
|
||||
return self.banner ? this.client.util.formatImage(Routes.BANNER(self.id, self.banner), null, 512) : "You don't have a banner!";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Gets a user's banner";
|
||||
static aliases = ["userbanner"];
|
||||
static arguments = ["{mention/id}"];
|
||||
static flags = [{
|
||||
name: "member",
|
||||
type: 6,
|
||||
description: "The member to get the banner from",
|
||||
required: false
|
||||
}];
|
||||
}
|
||||
|
||||
export default BannerCommand;
|
||||
import Command from "../../classes/command.js";
|
||||
import { Routes } from "oceanic.js";
|
||||
const mentionRegex = /^<?[@#]?[&!]?(\d+)>?$/;
|
||||
|
||||
class BannerCommand extends Command {
|
||||
// this command sucks
|
||||
async run() {
|
||||
const member = this.options.member ?? this.args[0];
|
||||
const self = await this.client.rest.users.get(this.author.id); // banners are only available over REST
|
||||
if (this.type === "classic" && this.message.mentions.users[0] && this.message.mentions.users[0].banner) {
|
||||
return this.client.util.formatImage(Routes.BANNER(this.message.mentions.users[0].id, this.message.mentions.users[0].banner), null, 512);
|
||||
} else if (member && member > 21154535154122752n) {
|
||||
const user = await this.client.rest.users.get(member);
|
||||
if (user && user.banner) {
|
||||
return this.client.util.formatImage(Routes.BANNER(user.id, user.banner), null, 512);
|
||||
} else if (mentionRegex.test(member)) {
|
||||
const id = member.match(mentionRegex)[1];
|
||||
if (id < 21154535154122752n) {
|
||||
this.success = false;
|
||||
return "That's not a valid mention!";
|
||||
}
|
||||
try {
|
||||
const user = await this.client.rest.users.get(id);
|
||||
return user.banner ? this.client.util.formatImage(Routes.BANNER(user.id, user.banner), null, 512) : "This user doesn't have a banner!";
|
||||
} catch {
|
||||
return self.banner ? this.client.util.formatImage(Routes.BANNER(self.id, self.banner), null, 512) : "You don't have a banner!";
|
||||
}
|
||||
} else {
|
||||
return "This user doesn't have a banner!";
|
||||
}
|
||||
} else if (this.args.join(" ") !== "" && this.guild) {
|
||||
const searched = await this.guild.searchMembers({
|
||||
query: this.args.join(" "),
|
||||
limit: 1
|
||||
});
|
||||
if (searched.length === 0) return self.banner ? this.client.util.formatImage(Routes.BANNER(self.id, self.banner), null, 512) : "This user doesn't have a banner!";
|
||||
const user = await this.client.rest.users.get(searched[0].user.id);
|
||||
return user.banner ? this.client.util.formatImage(Routes.BANNER(user.id, user.banner), null, 512) : (self.banner ? this.client.util.formatImage(Routes.BANNER(self.id, self.banner), null, 512) : "This user doesn't have a banner!");
|
||||
} else {
|
||||
return self.banner ? this.client.util.formatImage(Routes.BANNER(self.id, self.banner), null, 512) : "You don't have a banner!";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Gets a user's banner";
|
||||
static aliases = ["userbanner"];
|
||||
static arguments = ["{mention/id}"];
|
||||
static flags = [{
|
||||
name: "member",
|
||||
type: 6,
|
||||
description: "The member to get the banner from",
|
||||
required: false
|
||||
}];
|
||||
}
|
||||
|
||||
export default BannerCommand;
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
import Command from "../../classes/command.js";
|
||||
import { clean } from "../../utils/misc.js";
|
||||
|
||||
class Base64Command extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (this.type === "classic" && this.args.length === 0) return "You need to provide whether you want to encode or decode the text!";
|
||||
const command = this.type === "classic" ? this.args[0].toLowerCase() : this.optionsArray[0].name.toLowerCase();
|
||||
if (command !== "decode" && command !== "encode") return "You need to provide whether you want to encode or decode the text!";
|
||||
const string = this.options.text ?? this.args.slice(1).join(" ");
|
||||
if (!string || !string.trim()) return `You need to provide a string to ${command}!`;
|
||||
this.success = true;
|
||||
if (command === "decode") {
|
||||
const b64Decoded = Buffer.from(string, "base64").toString("utf8");
|
||||
return `\`\`\`\n${await clean(b64Decoded)}\`\`\``;
|
||||
} else if (command === "encode") {
|
||||
const b64Encoded = Buffer.from(string, "utf8").toString("base64");
|
||||
return `\`\`\`\n${b64Encoded}\`\`\``;
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "decode",
|
||||
type: 1,
|
||||
description: "Decodes a Base64 string",
|
||||
options: [{
|
||||
name: "text",
|
||||
type: 3,
|
||||
description: "The text to decode",
|
||||
required: true
|
||||
}]
|
||||
}, {
|
||||
name: "encode",
|
||||
type: 1,
|
||||
description: "Encodes a Base64 string",
|
||||
options: [{
|
||||
name: "text",
|
||||
type: 3,
|
||||
description: "The text to encode",
|
||||
required: true
|
||||
}]
|
||||
}];
|
||||
|
||||
static description = "Encodes/decodes a Base64 string";
|
||||
static arguments = ["[encode/decode]", "[text]"];
|
||||
}
|
||||
|
||||
import Command from "../../classes/command.js";
|
||||
import { clean } from "../../utils/misc.js";
|
||||
|
||||
class Base64Command extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (this.type === "classic" && this.args.length === 0) return "You need to provide whether you want to encode or decode the text!";
|
||||
const command = this.type === "classic" ? this.args[0].toLowerCase() : this.optionsArray[0].name.toLowerCase();
|
||||
if (command !== "decode" && command !== "encode") return "You need to provide whether you want to encode or decode the text!";
|
||||
const string = this.options.text ?? this.args.slice(1).join(" ");
|
||||
if (!string || !string.trim()) return `You need to provide a string to ${command}!`;
|
||||
this.success = true;
|
||||
if (command === "decode") {
|
||||
const b64Decoded = Buffer.from(string, "base64").toString("utf8");
|
||||
return `\`\`\`\n${await clean(b64Decoded)}\`\`\``;
|
||||
} else if (command === "encode") {
|
||||
const b64Encoded = Buffer.from(string, "utf8").toString("base64");
|
||||
return `\`\`\`\n${b64Encoded}\`\`\``;
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "decode",
|
||||
type: 1,
|
||||
description: "Decodes a Base64 string",
|
||||
options: [{
|
||||
name: "text",
|
||||
type: 3,
|
||||
description: "The text to decode",
|
||||
required: true
|
||||
}]
|
||||
}, {
|
||||
name: "encode",
|
||||
type: 1,
|
||||
description: "Encodes a Base64 string",
|
||||
options: [{
|
||||
name: "text",
|
||||
type: 3,
|
||||
description: "The text to encode",
|
||||
required: true
|
||||
}]
|
||||
}];
|
||||
|
||||
static description = "Encodes/decodes a Base64 string";
|
||||
static arguments = ["[encode/decode]", "[text]"];
|
||||
}
|
||||
|
||||
export default Base64Command;
|
|
@ -1,52 +1,52 @@
|
|||
import Command from "../../classes/command.js";
|
||||
import database from "../../utils/database.js";
|
||||
import { endBroadcast, startBroadcast } from "../../utils/misc.js";
|
||||
|
||||
class BroadcastCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can broadcast messages!";
|
||||
}
|
||||
const message = this.options.message ?? this.args.join(" ");
|
||||
if (message?.trim()) {
|
||||
await database.setBroadcast(message);
|
||||
startBroadcast(this.client, message);
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "broadcastStart",
|
||||
message
|
||||
}
|
||||
});
|
||||
}
|
||||
return "Started broadcast.";
|
||||
} else {
|
||||
await database.setBroadcast(null);
|
||||
endBroadcast(this.client);
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "broadcastEnd"
|
||||
}
|
||||
});
|
||||
}
|
||||
return "Ended broadcast.";
|
||||
}
|
||||
}
|
||||
|
||||
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 adminOnly = true;
|
||||
static dbRequired = true;
|
||||
}
|
||||
|
||||
import Command from "../../classes/command.js";
|
||||
import database from "../../utils/database.js";
|
||||
import { endBroadcast, startBroadcast } from "../../utils/misc.js";
|
||||
|
||||
class BroadcastCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can broadcast messages!";
|
||||
}
|
||||
const message = this.options.message ?? this.args.join(" ");
|
||||
if (message?.trim()) {
|
||||
await database.setBroadcast(message);
|
||||
startBroadcast(this.client, message);
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "broadcastStart",
|
||||
message
|
||||
}
|
||||
});
|
||||
}
|
||||
return "Started broadcast.";
|
||||
} else {
|
||||
await database.setBroadcast(null);
|
||||
endBroadcast(this.client);
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "broadcastEnd"
|
||||
}
|
||||
});
|
||||
}
|
||||
return "Ended broadcast.";
|
||||
}
|
||||
}
|
||||
|
||||
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 adminOnly = true;
|
||||
static dbRequired = true;
|
||||
}
|
||||
|
||||
export default BroadcastCommand;
|
|
@ -1,53 +1,53 @@
|
|||
import db from "../../utils/database.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class ChannelCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (!this.guild) return "This command only works in servers!";
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!this.member.permissions.has("ADMINISTRATOR") && !owners.includes(this.member.id)) return "You need to be an administrator to enable/disable me!";
|
||||
if (this.args.length === 0) return "You need to provide whether I should be enabled or disabled in this channel!";
|
||||
if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!";
|
||||
|
||||
const guildDB = await db.getGuild(this.guild.id);
|
||||
|
||||
if (this.args[0].toLowerCase() === "disable") {
|
||||
let channel;
|
||||
if (this.args[1]?.match(/^<?[@#]?[&!]?\d+>?$/) && this.args[1] >= 21154535154122752n) {
|
||||
const id = this.args[1].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "");
|
||||
if (guildDB.disabled.includes(id)) return "I'm already disabled in this channel!";
|
||||
channel = this.guild.channels.get(id) ?? await this.client.rest.channels.get(id);
|
||||
} else {
|
||||
if (guildDB.disabled.includes(this.channel.id)) return "I'm already disabled in this channel!";
|
||||
channel = this.channel;
|
||||
}
|
||||
|
||||
await db.disableChannel(channel);
|
||||
this.success = true;
|
||||
return `I have been disabled in this channel. To re-enable me, just run \`${guildDB.prefix}channel enable\`.`;
|
||||
} else if (this.args[0].toLowerCase() === "enable") {
|
||||
let channel;
|
||||
if (this.args[1]?.match(/^<?[@#]?[&!]?\d+>?$/) && this.args[1] >= 21154535154122752n) {
|
||||
const id = this.args[1].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "");
|
||||
if (!guildDB.disabled.includes(id)) return "I'm not disabled in that channel!";
|
||||
channel = this.guild.channels.get(id) ?? await this.client.rest.channels.get(id);
|
||||
} else {
|
||||
if (!guildDB.disabled.includes(this.channel.id)) return "I'm not disabled in this channel!";
|
||||
channel = this.channel;
|
||||
}
|
||||
|
||||
await db.enableChannel(channel);
|
||||
this.success = true;
|
||||
return "I have been re-enabled in this channel.";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Enables/disables classic commands in a channel (use server settings for slash commands)";
|
||||
static arguments = ["[enable/disable]", "{id}"];
|
||||
static slashAllowed = false;
|
||||
static directAllowed = false;
|
||||
static dbRequired = true;
|
||||
}
|
||||
|
||||
export default ChannelCommand;
|
||||
import db from "../../utils/database.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class ChannelCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (!this.guild) return "This command only works in servers!";
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!this.member.permissions.has("ADMINISTRATOR") && !owners.includes(this.member.id)) return "You need to be an administrator to enable/disable me!";
|
||||
if (this.args.length === 0) return "You need to provide whether I should be enabled or disabled in this channel!";
|
||||
if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!";
|
||||
|
||||
const guildDB = await db.getGuild(this.guild.id);
|
||||
|
||||
if (this.args[0].toLowerCase() === "disable") {
|
||||
let channel;
|
||||
if (this.args[1]?.match(/^<?[@#]?[&!]?\d+>?$/) && this.args[1] >= 21154535154122752n) {
|
||||
const id = this.args[1].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "");
|
||||
if (guildDB.disabled.includes(id)) return "I'm already disabled in this channel!";
|
||||
channel = this.guild.channels.get(id) ?? await this.client.rest.channels.get(id);
|
||||
} else {
|
||||
if (guildDB.disabled.includes(this.channel.id)) return "I'm already disabled in this channel!";
|
||||
channel = this.channel;
|
||||
}
|
||||
|
||||
await db.disableChannel(channel);
|
||||
this.success = true;
|
||||
return `I have been disabled in this channel. To re-enable me, just run \`${guildDB.prefix}channel enable\`.`;
|
||||
} else if (this.args[0].toLowerCase() === "enable") {
|
||||
let channel;
|
||||
if (this.args[1]?.match(/^<?[@#]?[&!]?\d+>?$/) && this.args[1] >= 21154535154122752n) {
|
||||
const id = this.args[1].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "");
|
||||
if (!guildDB.disabled.includes(id)) return "I'm not disabled in that channel!";
|
||||
channel = this.guild.channels.get(id) ?? await this.client.rest.channels.get(id);
|
||||
} else {
|
||||
if (!guildDB.disabled.includes(this.channel.id)) return "I'm not disabled in this channel!";
|
||||
channel = this.channel;
|
||||
}
|
||||
|
||||
await db.enableChannel(channel);
|
||||
this.success = true;
|
||||
return "I have been re-enabled in this channel.";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Enables/disables classic commands in a channel (use server settings for slash commands)";
|
||||
static arguments = ["[enable/disable]", "{id}"];
|
||||
static slashAllowed = false;
|
||||
static directAllowed = false;
|
||||
static dbRequired = true;
|
||||
}
|
||||
|
||||
export default ChannelCommand;
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
import db from "../../utils/database.js";
|
||||
import Command from "../../classes/command.js";
|
||||
import * as collections from "../../utils/collections.js";
|
||||
|
||||
class CommandCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (!this.guild) return "This command only works in servers!";
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!this.member.permissions.has("ADMINISTRATOR") && !owners.includes(this.member.id)) return "You need to be an administrator to enable/disable me!";
|
||||
if (this.args.length === 0) return "You need to provide whether you want to enable/disable a command!";
|
||||
if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!";
|
||||
if (!this.args[1]) return "You need to provide what command to enable/disable!";
|
||||
if (!collections.commands.has(this.args[1].toLowerCase()) && !collections.aliases.has(this.args[1].toLowerCase())) return "That isn't a command!";
|
||||
|
||||
const guildDB = await db.getGuild(this.guild.id);
|
||||
const disabled = guildDB.disabled_commands ?? guildDB.disabledCommands;
|
||||
const command = collections.aliases.get(this.args[1].toLowerCase()) ?? this.args[1].toLowerCase();
|
||||
|
||||
if (this.args[0].toLowerCase() === "disable") {
|
||||
if (command === "command") return "You can't disable that command!";
|
||||
if (disabled?.includes(command)) return "That command is already disabled!";
|
||||
|
||||
await db.disableCommand(this.guild.id, command);
|
||||
this.success = true;
|
||||
return `The command has been disabled. To re-enable it, just run \`${guildDB.prefix}command enable ${command}\`.`;
|
||||
} else if (this.args[0].toLowerCase() === "enable") {
|
||||
if (!disabled?.includes(command)) return "That command isn't disabled!";
|
||||
|
||||
await db.enableCommand(this.guild.id, command);
|
||||
this.success = true;
|
||||
return `The command \`${command}\` has been re-enabled.`;
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Enables/disables a classic command for a server (use server settings for slash commands)";
|
||||
static aliases = ["cmd"];
|
||||
static arguments = ["[enable/disable]", "[command]"];
|
||||
static slashAllowed = false;
|
||||
static directAllowed = false;
|
||||
static dbRequired = true;
|
||||
}
|
||||
|
||||
export default CommandCommand;
|
||||
import db from "../../utils/database.js";
|
||||
import Command from "../../classes/command.js";
|
||||
import * as collections from "../../utils/collections.js";
|
||||
|
||||
class CommandCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (!this.guild) return "This command only works in servers!";
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!this.member.permissions.has("ADMINISTRATOR") && !owners.includes(this.member.id)) return "You need to be an administrator to enable/disable me!";
|
||||
if (this.args.length === 0) return "You need to provide whether you want to enable/disable a command!";
|
||||
if (this.args[0] !== "disable" && this.args[0] !== "enable") return "That's not a valid option!";
|
||||
if (!this.args[1]) return "You need to provide what command to enable/disable!";
|
||||
if (!collections.commands.has(this.args[1].toLowerCase()) && !collections.aliases.has(this.args[1].toLowerCase())) return "That isn't a command!";
|
||||
|
||||
const guildDB = await db.getGuild(this.guild.id);
|
||||
const disabled = guildDB.disabled_commands ?? guildDB.disabledCommands;
|
||||
const command = collections.aliases.get(this.args[1].toLowerCase()) ?? this.args[1].toLowerCase();
|
||||
|
||||
if (this.args[0].toLowerCase() === "disable") {
|
||||
if (command === "command") return "You can't disable that command!";
|
||||
if (disabled?.includes(command)) return "That command is already disabled!";
|
||||
|
||||
await db.disableCommand(this.guild.id, command);
|
||||
this.success = true;
|
||||
return `The command has been disabled. To re-enable it, just run \`${guildDB.prefix}command enable ${command}\`.`;
|
||||
} else if (this.args[0].toLowerCase() === "enable") {
|
||||
if (!disabled?.includes(command)) return "That command isn't disabled!";
|
||||
|
||||
await db.enableCommand(this.guild.id, command);
|
||||
this.success = true;
|
||||
return `The command \`${command}\` has been re-enabled.`;
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Enables/disables a classic command for a server (use server settings for slash commands)";
|
||||
static aliases = ["cmd"];
|
||||
static arguments = ["[enable/disable]", "[command]"];
|
||||
static slashAllowed = false;
|
||||
static directAllowed = false;
|
||||
static dbRequired = true;
|
||||
}
|
||||
|
||||
export default CommandCommand;
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
import paginator from "../../utils/pagination/pagination.js";
|
||||
import database from "../../utils/database.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class CountCommand extends Command {
|
||||
async run() {
|
||||
if (this.guild && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) {
|
||||
this.success = false;
|
||||
return "I don't have the `Embed Links` permission!";
|
||||
}
|
||||
const counts = await database.getCounts();
|
||||
const countArray = [];
|
||||
for (const entry of Object.entries(counts)) {
|
||||
countArray.push(entry);
|
||||
}
|
||||
const sortedValues = countArray.sort((a, b) => {
|
||||
return b[1] - a[1];
|
||||
});
|
||||
const countArray2 = [];
|
||||
for (const [key, value] of sortedValues) {
|
||||
countArray2.push(`**${key}**: ${value}`);
|
||||
}
|
||||
const embeds = [];
|
||||
const groups = countArray2.map((item, index) => {
|
||||
return index % 15 === 0 ? countArray2.slice(index, index + 15) : null;
|
||||
}).filter((item) => {
|
||||
return item;
|
||||
});
|
||||
for (const [i, value] of groups.entries()) {
|
||||
embeds.push({
|
||||
embeds: [{
|
||||
title: "Command Usage Counts",
|
||||
color: 16711680,
|
||||
footer: {
|
||||
text: `Page ${i + 1} of ${groups.length}`
|
||||
},
|
||||
description: value.join("\n"),
|
||||
author: {
|
||||
name: this.author.username,
|
||||
iconURL: this.author.avatarURL()
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
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 arguments = ["{mention/id}"];
|
||||
static aliases = ["counts"];
|
||||
static dbRequired = true;
|
||||
}
|
||||
|
||||
import paginator from "../../utils/pagination/pagination.js";
|
||||
import database from "../../utils/database.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class CountCommand extends Command {
|
||||
async run() {
|
||||
if (this.guild && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) {
|
||||
this.success = false;
|
||||
return "I don't have the `Embed Links` permission!";
|
||||
}
|
||||
const counts = await database.getCounts();
|
||||
const countArray = [];
|
||||
for (const entry of Object.entries(counts)) {
|
||||
countArray.push(entry);
|
||||
}
|
||||
const sortedValues = countArray.sort((a, b) => {
|
||||
return b[1] - a[1];
|
||||
});
|
||||
const countArray2 = [];
|
||||
for (const [key, value] of sortedValues) {
|
||||
countArray2.push(`**${key}**: ${value}`);
|
||||
}
|
||||
const embeds = [];
|
||||
const groups = countArray2.map((item, index) => {
|
||||
return index % 15 === 0 ? countArray2.slice(index, index + 15) : null;
|
||||
}).filter((item) => {
|
||||
return item;
|
||||
});
|
||||
for (const [i, value] of groups.entries()) {
|
||||
embeds.push({
|
||||
embeds: [{
|
||||
title: "Command Usage Counts",
|
||||
color: 16711680,
|
||||
footer: {
|
||||
text: `Page ${i + 1} of ${groups.length}`
|
||||
},
|
||||
description: value.join("\n"),
|
||||
author: {
|
||||
name: this.author.username,
|
||||
iconURL: this.author.avatarURL()
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
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 arguments = ["{mention/id}"];
|
||||
static aliases = ["counts"];
|
||||
static dbRequired = true;
|
||||
}
|
||||
|
||||
export default CountCommand;
|
|
@ -1,30 +1,30 @@
|
|||
import { request } from "undici";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class DonateCommand extends Command {
|
||||
async run() {
|
||||
await this.acknowledge();
|
||||
let prefix = "";
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => {
|
||||
controller.abort();
|
||||
}, 5000);
|
||||
try {
|
||||
const patrons = await request("https://projectlounge.pw/patrons", { signal: controller.signal }).then(data => data.body.json());
|
||||
clearTimeout(timeout);
|
||||
prefix = "Thanks to the following patrons for their support:\n";
|
||||
for (const patron of patrons) {
|
||||
prefix += `**- ${patron}**\n`;
|
||||
}
|
||||
prefix += "\n";
|
||||
} catch (e) {
|
||||
// no-op
|
||||
}
|
||||
return `${prefix}Like esmBot? Consider supporting the developer on Patreon to help keep it running! https://patreon.com/TheEssem`;
|
||||
}
|
||||
|
||||
static description = "Learn more about how you can support esmBot's development";
|
||||
static aliases = ["support", "patreon", "patrons"];
|
||||
}
|
||||
|
||||
import { request } from "undici";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class DonateCommand extends Command {
|
||||
async run() {
|
||||
await this.acknowledge();
|
||||
let prefix = "";
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => {
|
||||
controller.abort();
|
||||
}, 5000);
|
||||
try {
|
||||
const patrons = await request("https://projectlounge.pw/patrons", { signal: controller.signal }).then(data => data.body.json());
|
||||
clearTimeout(timeout);
|
||||
prefix = "Thanks to the following patrons for their support:\n";
|
||||
for (const patron of patrons) {
|
||||
prefix += `**- ${patron}**\n`;
|
||||
}
|
||||
prefix += "\n";
|
||||
} catch (e) {
|
||||
// no-op
|
||||
}
|
||||
return `${prefix}Like esmBot? Consider supporting the developer on Patreon to help keep it running! https://patreon.com/TheEssem`;
|
||||
}
|
||||
|
||||
static description = "Learn more about how you can support esmBot's development";
|
||||
static aliases = ["support", "patreon", "patrons"];
|
||||
}
|
||||
|
||||
export default DonateCommand;
|
|
@ -1,33 +1,33 @@
|
|||
import emojiRegex from "emoji-regex";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class EmoteCommand extends Command {
|
||||
async run() {
|
||||
const emoji = this.options.emoji ?? this.content;
|
||||
if (emoji && emoji.trim() && emoji.split(" ")[0].match(/^<a?:.+:\d+>$/)) {
|
||||
return `https://cdn.discordapp.com/emojis/${emoji.split(" ")[0].replace(/^<(a)?:.+:(\d+)>$/, "$2")}.${emoji.split(" ")[0].replace(/^<(a)?:.+:(\d+)>$/, "$1") === "a" ? "gif" : "png"}`;
|
||||
} else if (emoji.match(emojiRegex())) {
|
||||
const codePoints = [];
|
||||
for (const codePoint of emoji) {
|
||||
codePoints.push(codePoint.codePointAt(0).toString(16));
|
||||
}
|
||||
return `https://twemoji.maxcdn.com/v/latest/72x72/${codePoints.join("-").replace("-fe0f", "")}.png`;
|
||||
} else {
|
||||
this.success = false;
|
||||
return "You need to provide a valid emoji to get an image!";
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "emoji",
|
||||
type: 3,
|
||||
description: "The emoji you want to get",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Gets a raw emote image";
|
||||
static aliases = ["e", "em", "hugemoji", "hugeemoji", "emoji"];
|
||||
static arguments = ["[emote]"];
|
||||
}
|
||||
|
||||
export default EmoteCommand;
|
||||
import emojiRegex from "emoji-regex";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class EmoteCommand extends Command {
|
||||
async run() {
|
||||
const emoji = this.options.emoji ?? this.content;
|
||||
if (emoji && emoji.trim() && emoji.split(" ")[0].match(/^<a?:.+:\d+>$/)) {
|
||||
return `https://cdn.discordapp.com/emojis/${emoji.split(" ")[0].replace(/^<(a)?:.+:(\d+)>$/, "$2")}.${emoji.split(" ")[0].replace(/^<(a)?:.+:(\d+)>$/, "$1") === "a" ? "gif" : "png"}`;
|
||||
} else if (emoji.match(emojiRegex())) {
|
||||
const codePoints = [];
|
||||
for (const codePoint of emoji) {
|
||||
codePoints.push(codePoint.codePointAt(0).toString(16));
|
||||
}
|
||||
return `https://twemoji.maxcdn.com/v/latest/72x72/${codePoints.join("-").replace("-fe0f", "")}.png`;
|
||||
} else {
|
||||
this.success = false;
|
||||
return "You need to provide a valid emoji to get an image!";
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "emoji",
|
||||
type: 3,
|
||||
description: "The emoji you want to get",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Gets a raw emote image";
|
||||
static aliases = ["e", "em", "hugemoji", "hugeemoji", "emoji"];
|
||||
static arguments = ["[emote]"];
|
||||
}
|
||||
|
||||
export default EmoteCommand;
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
import { clean } from "../../utils/misc.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class EvalCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can use eval!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const code = this.options.code ?? this.args.join(" ");
|
||||
try {
|
||||
let evaled = eval(code);
|
||||
if (evaled?.constructor?.name == "Promise") evaled = await evaled;
|
||||
const cleaned = clean(evaled);
|
||||
const sendString = `\`\`\`js\n${cleaned}\n\`\`\``;
|
||||
if (sendString.length >= 2000) {
|
||||
return {
|
||||
content: "The result was too large, so here it is as a file:",
|
||||
files: [{
|
||||
contents: cleaned,
|
||||
name: "result.txt"
|
||||
}]
|
||||
};
|
||||
} else {
|
||||
return sendString;
|
||||
}
|
||||
} catch (err) {
|
||||
let error = err;
|
||||
if (err?.constructor?.name == "Promise") error = await err;
|
||||
return `\`ERROR\` \`\`\`xl\n${clean(error)}\n\`\`\``;
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "code",
|
||||
type: 3,
|
||||
description: "The code to execute",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Executes JavaScript code";
|
||||
static aliases = ["run"];
|
||||
static arguments = ["[code]"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
import { clean } from "../../utils/misc.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class EvalCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can use eval!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const code = this.options.code ?? this.args.join(" ");
|
||||
try {
|
||||
let evaled = eval(code);
|
||||
if (evaled?.constructor?.name == "Promise") evaled = await evaled;
|
||||
const cleaned = clean(evaled);
|
||||
const sendString = `\`\`\`js\n${cleaned}\n\`\`\``;
|
||||
if (sendString.length >= 2000) {
|
||||
return {
|
||||
content: "The result was too large, so here it is as a file:",
|
||||
files: [{
|
||||
contents: cleaned,
|
||||
name: "result.txt"
|
||||
}]
|
||||
};
|
||||
} else {
|
||||
return sendString;
|
||||
}
|
||||
} catch (err) {
|
||||
let error = err;
|
||||
if (err?.constructor?.name == "Promise") error = await err;
|
||||
return `\`ERROR\` \`\`\`xl\n${clean(error)}\n\`\`\``;
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "code",
|
||||
type: 3,
|
||||
description: "The code to execute",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Executes JavaScript code";
|
||||
static aliases = ["run"];
|
||||
static arguments = ["[code]"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
export default EvalCommand;
|
|
@ -1,48 +1,48 @@
|
|||
import { clean } from "../../utils/misc.js";
|
||||
import * as util from "util";
|
||||
import { exec as baseExec } from "child_process";
|
||||
const exec = util.promisify(baseExec);
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class ExecCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can use exec!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const code = this.options.cmd ?? this.args.join(" ");
|
||||
try {
|
||||
const execed = await exec(code);
|
||||
if (execed.stderr) return `\`ERROR\` \`\`\`xl\n${await clean(execed.stderr)}\n\`\`\``;
|
||||
const cleaned = await clean(execed.stdout);
|
||||
const sendString = `\`\`\`bash\n${cleaned}\n\`\`\``;
|
||||
if (sendString.length >= 2000) {
|
||||
return {
|
||||
text: "The result was too large, so here it is as a file:",
|
||||
file: cleaned,
|
||||
name: "result.txt"
|
||||
};
|
||||
} else {
|
||||
return sendString;
|
||||
}
|
||||
} catch (err) {
|
||||
return `\`ERROR\` \`\`\`xl\n${await clean(err)}\n\`\`\``;
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "cmd",
|
||||
type: 3,
|
||||
description: "The command to execute",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Executes a shell command";
|
||||
static aliases = ["runcmd"];
|
||||
static arguments = ["[command]"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
import { clean } from "../../utils/misc.js";
|
||||
import * as util from "util";
|
||||
import { exec as baseExec } from "child_process";
|
||||
const exec = util.promisify(baseExec);
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class ExecCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can use exec!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const code = this.options.cmd ?? this.args.join(" ");
|
||||
try {
|
||||
const execed = await exec(code);
|
||||
if (execed.stderr) return `\`ERROR\` \`\`\`xl\n${await clean(execed.stderr)}\n\`\`\``;
|
||||
const cleaned = await clean(execed.stdout);
|
||||
const sendString = `\`\`\`bash\n${cleaned}\n\`\`\``;
|
||||
if (sendString.length >= 2000) {
|
||||
return {
|
||||
text: "The result was too large, so here it is as a file:",
|
||||
file: cleaned,
|
||||
name: "result.txt"
|
||||
};
|
||||
} else {
|
||||
return sendString;
|
||||
}
|
||||
} catch (err) {
|
||||
return `\`ERROR\` \`\`\`xl\n${await clean(err)}\n\`\`\``;
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "cmd",
|
||||
type: 3,
|
||||
description: "The command to execute",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Executes a shell command";
|
||||
static aliases = ["runcmd"];
|
||||
static arguments = ["[command]"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
export default ExecCommand;
|
|
@ -1,120 +1,120 @@
|
|||
import { Constants } from "oceanic.js";
|
||||
import database from "../../utils/database.js";
|
||||
import * as collections from "../../utils/collections.js";
|
||||
import { random } from "../../utils/misc.js";
|
||||
import paginator from "../../utils/pagination/pagination.js";
|
||||
import * as help from "../../utils/help.js";
|
||||
import Command from "../../classes/command.js";
|
||||
const tips = ["You can change the bot's prefix using the prefix command.", "Image commands also work with images previously posted in that channel.", "You can use the tags commands to save things for later use.", "You can visit https://esmbot.net/help.html for a web version of this command list.", "You can view a command's aliases by putting the command name after the help command (e.g. help image).", "Parameters wrapped in [] are required, while parameters wrapped in {} are optional.", "esmBot is hosted and paid for completely out-of-pocket by the main developer. If you want to support development, please consider donating! https://patreon.com/TheEssem"];
|
||||
|
||||
class HelpCommand extends Command {
|
||||
async run() {
|
||||
let prefix;
|
||||
if (this.guild && database) {
|
||||
prefix = (await database.getGuild(this.guild.id)).prefix;
|
||||
} else {
|
||||
prefix = process.env.PREFIX;
|
||||
}
|
||||
if (this.args.length !== 0 && (collections.commands.has(this.args[0].toLowerCase()) || collections.aliases.has(this.args[0].toLowerCase()))) {
|
||||
const command = collections.aliases.get(this.args[0].toLowerCase()) ?? this.args[0].toLowerCase();
|
||||
const info = collections.info.get(command);
|
||||
const embed = {
|
||||
embeds: [{
|
||||
author: {
|
||||
name: "esmBot Help",
|
||||
iconURL: this.client.user.avatarURL()
|
||||
},
|
||||
title: `${this.guild ? prefix : ""}${command}`,
|
||||
url: "https://esmbot.net/help.html",
|
||||
description: command === "tags" ? "The main tags command. Check the help page for more info: https://esmbot.net/help.html" : info.description,
|
||||
color: 16711680,
|
||||
fields: [{
|
||||
name: "Aliases",
|
||||
value: info.aliases.length !== 0 ? info.aliases.join(", ") : "None"
|
||||
}, {
|
||||
name: "Parameters",
|
||||
value: command === "tags" ? "[name]" : (info.params ? (info.params.length !== 0 ? info.params.join(" ") : "None") : "None"),
|
||||
inline: true
|
||||
}]
|
||||
}]
|
||||
};
|
||||
if (database) {
|
||||
embed.embeds[0].fields.push({
|
||||
name: "Times used",
|
||||
value: (await database.getCounts())[command],
|
||||
inline: true
|
||||
});
|
||||
}
|
||||
if (info.flags.length !== 0) {
|
||||
const flagInfo = [];
|
||||
for (const flag of info.flags) {
|
||||
if (flag.type === 1) continue;
|
||||
flagInfo.push(`\`--${flag.name}${flag.type ? `=[${Constants.ApplicationCommandOptionTypes[flag.type]}]` : ""}\` - ${flag.description}`);
|
||||
}
|
||||
if (flagInfo.length !== 0) {
|
||||
embed.embeds[0].fields.push({
|
||||
"name": "Flags",
|
||||
"value": flagInfo.join("\n")
|
||||
});
|
||||
}
|
||||
}
|
||||
return embed;
|
||||
} else {
|
||||
if (this.guild && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) {
|
||||
this.success = false;
|
||||
return "I don't have the `Embed Links` permission!";
|
||||
}
|
||||
const pages = [];
|
||||
if (help.categories === help.categoryTemplate && !help.generated) help.generateList();
|
||||
for (const category of Object.keys(help.categories)) {
|
||||
const splitPages = help.categories[category].map((item, index) => {
|
||||
return index % 15 === 0 ? help.categories[category].slice(index, index + 15) : null;
|
||||
}).filter((item) => {
|
||||
return item;
|
||||
});
|
||||
const categoryStringArray = category.split("-");
|
||||
for (const index of categoryStringArray.keys()) {
|
||||
categoryStringArray[index] = categoryStringArray[index].charAt(0).toUpperCase() + categoryStringArray[index].slice(1);
|
||||
}
|
||||
for (const page of splitPages) {
|
||||
pages.push({
|
||||
title: categoryStringArray.join(" "),
|
||||
page: page
|
||||
});
|
||||
}
|
||||
}
|
||||
const embeds = [];
|
||||
for (const [i, value] of pages.entries()) {
|
||||
embeds.push({
|
||||
embeds: [{
|
||||
author: {
|
||||
name: "esmBot Help",
|
||||
iconURL: this.client.user.avatarURL()
|
||||
},
|
||||
title: value.title,
|
||||
description: value.page.join("\n"),
|
||||
color: 16711680,
|
||||
footer: {
|
||||
text: `Page ${i + 1} of ${pages.length}`
|
||||
},
|
||||
fields: [{
|
||||
name: "Prefix",
|
||||
value: prefix
|
||||
}, {
|
||||
name: "Tip",
|
||||
value: random(tips)
|
||||
}]
|
||||
}]
|
||||
});
|
||||
}
|
||||
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, author: this.author }, embeds);
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Gets a list of commands";
|
||||
static aliases = ["commands"];
|
||||
static arguments = ["{command}"];
|
||||
static slashAllowed = false;
|
||||
}
|
||||
|
||||
export default HelpCommand;
|
||||
import { Constants } from "oceanic.js";
|
||||
import database from "../../utils/database.js";
|
||||
import * as collections from "../../utils/collections.js";
|
||||
import { random } from "../../utils/misc.js";
|
||||
import paginator from "../../utils/pagination/pagination.js";
|
||||
import * as help from "../../utils/help.js";
|
||||
import Command from "../../classes/command.js";
|
||||
const tips = ["You can change the bot's prefix using the prefix command.", "Image commands also work with images previously posted in that channel.", "You can use the tags commands to save things for later use.", "You can visit https://esmbot.net/help.html for a web version of this command list.", "You can view a command's aliases by putting the command name after the help command (e.g. help image).", "Parameters wrapped in [] are required, while parameters wrapped in {} are optional.", "esmBot is hosted and paid for completely out-of-pocket by the main developer. If you want to support development, please consider donating! https://patreon.com/TheEssem"];
|
||||
|
||||
class HelpCommand extends Command {
|
||||
async run() {
|
||||
let prefix;
|
||||
if (this.guild && database) {
|
||||
prefix = (await database.getGuild(this.guild.id)).prefix;
|
||||
} else {
|
||||
prefix = process.env.PREFIX;
|
||||
}
|
||||
if (this.args.length !== 0 && (collections.commands.has(this.args[0].toLowerCase()) || collections.aliases.has(this.args[0].toLowerCase()))) {
|
||||
const command = collections.aliases.get(this.args[0].toLowerCase()) ?? this.args[0].toLowerCase();
|
||||
const info = collections.info.get(command);
|
||||
const embed = {
|
||||
embeds: [{
|
||||
author: {
|
||||
name: "esmBot Help",
|
||||
iconURL: this.client.user.avatarURL()
|
||||
},
|
||||
title: `${this.guild ? prefix : ""}${command}`,
|
||||
url: "https://esmbot.net/help.html",
|
||||
description: command === "tags" ? "The main tags command. Check the help page for more info: https://esmbot.net/help.html" : info.description,
|
||||
color: 16711680,
|
||||
fields: [{
|
||||
name: "Aliases",
|
||||
value: info.aliases.length !== 0 ? info.aliases.join(", ") : "None"
|
||||
}, {
|
||||
name: "Parameters",
|
||||
value: command === "tags" ? "[name]" : (info.params ? (info.params.length !== 0 ? info.params.join(" ") : "None") : "None"),
|
||||
inline: true
|
||||
}]
|
||||
}]
|
||||
};
|
||||
if (database) {
|
||||
embed.embeds[0].fields.push({
|
||||
name: "Times used",
|
||||
value: (await database.getCounts())[command],
|
||||
inline: true
|
||||
});
|
||||
}
|
||||
if (info.flags.length !== 0) {
|
||||
const flagInfo = [];
|
||||
for (const flag of info.flags) {
|
||||
if (flag.type === 1) continue;
|
||||
flagInfo.push(`\`--${flag.name}${flag.type ? `=[${Constants.ApplicationCommandOptionTypes[flag.type]}]` : ""}\` - ${flag.description}`);
|
||||
}
|
||||
if (flagInfo.length !== 0) {
|
||||
embed.embeds[0].fields.push({
|
||||
"name": "Flags",
|
||||
"value": flagInfo.join("\n")
|
||||
});
|
||||
}
|
||||
}
|
||||
return embed;
|
||||
} else {
|
||||
if (this.guild && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) {
|
||||
this.success = false;
|
||||
return "I don't have the `Embed Links` permission!";
|
||||
}
|
||||
const pages = [];
|
||||
if (help.categories === help.categoryTemplate && !help.generated) help.generateList();
|
||||
for (const category of Object.keys(help.categories)) {
|
||||
const splitPages = help.categories[category].map((item, index) => {
|
||||
return index % 15 === 0 ? help.categories[category].slice(index, index + 15) : null;
|
||||
}).filter((item) => {
|
||||
return item;
|
||||
});
|
||||
const categoryStringArray = category.split("-");
|
||||
for (const index of categoryStringArray.keys()) {
|
||||
categoryStringArray[index] = categoryStringArray[index].charAt(0).toUpperCase() + categoryStringArray[index].slice(1);
|
||||
}
|
||||
for (const page of splitPages) {
|
||||
pages.push({
|
||||
title: categoryStringArray.join(" "),
|
||||
page: page
|
||||
});
|
||||
}
|
||||
}
|
||||
const embeds = [];
|
||||
for (const [i, value] of pages.entries()) {
|
||||
embeds.push({
|
||||
embeds: [{
|
||||
author: {
|
||||
name: "esmBot Help",
|
||||
iconURL: this.client.user.avatarURL()
|
||||
},
|
||||
title: value.title,
|
||||
description: value.page.join("\n"),
|
||||
color: 16711680,
|
||||
footer: {
|
||||
text: `Page ${i + 1} of ${pages.length}`
|
||||
},
|
||||
fields: [{
|
||||
name: "Prefix",
|
||||
value: prefix
|
||||
}, {
|
||||
name: "Tip",
|
||||
value: random(tips)
|
||||
}]
|
||||
}]
|
||||
});
|
||||
}
|
||||
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, author: this.author }, embeds);
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Gets a list of commands";
|
||||
static aliases = ["commands"];
|
||||
static arguments = ["{command}"];
|
||||
static slashAllowed = false;
|
||||
}
|
||||
|
||||
export default HelpCommand;
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
import paginator from "../../utils/pagination/pagination.js";
|
||||
import { readFileSync } from "fs";
|
||||
const { searx } = JSON.parse(readFileSync(new URL("../../config/servers.json", import.meta.url)));
|
||||
import { random } from "../../utils/misc.js";
|
||||
import { request } from "undici";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class ImageSearchCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (this.channel && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) return "I don't have the `Embed Links` permission!";
|
||||
const query = this.options.query ?? this.args.join(" ");
|
||||
if (!query || !query.trim()) return "You need to provide something to search for!";
|
||||
await this.acknowledge();
|
||||
const embeds = [];
|
||||
const rawImages = await request(`${random(searx)}/search?format=json&safesearch=2&categories=images&q=!goi%20!ddi%20${encodeURIComponent(query)}`).then(res => res.body.json());
|
||||
if (rawImages.results.length === 0) return "I couldn't find any results!";
|
||||
const images = rawImages.results.filter((val) => !val.img_src.startsWith("data:"));
|
||||
for (const [i, value] of images.entries()) {
|
||||
embeds.push({
|
||||
embeds: [{
|
||||
title: "Search Results",
|
||||
color: 16711680,
|
||||
footer: {
|
||||
text: `Page ${i + 1} of ${images.length}`
|
||||
},
|
||||
description: value.title,
|
||||
image: {
|
||||
url: encodeURI(value.img_src)
|
||||
},
|
||||
author: {
|
||||
name: this.author.username,
|
||||
iconURL: this.author.avatarURL()
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
this.success = true;
|
||||
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 aliases = ["im", "photo", "img"];
|
||||
static arguments = ["[query]"];
|
||||
}
|
||||
|
||||
import paginator from "../../utils/pagination/pagination.js";
|
||||
import { readFileSync } from "fs";
|
||||
const { searx } = JSON.parse(readFileSync(new URL("../../config/servers.json", import.meta.url)));
|
||||
import { random } from "../../utils/misc.js";
|
||||
import { request } from "undici";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class ImageSearchCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (this.channel && !this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) return "I don't have the `Embed Links` permission!";
|
||||
const query = this.options.query ?? this.args.join(" ");
|
||||
if (!query || !query.trim()) return "You need to provide something to search for!";
|
||||
await this.acknowledge();
|
||||
const embeds = [];
|
||||
const rawImages = await request(`${random(searx)}/search?format=json&safesearch=2&categories=images&q=!goi%20!ddi%20${encodeURIComponent(query)}`).then(res => res.body.json());
|
||||
if (rawImages.results.length === 0) return "I couldn't find any results!";
|
||||
const images = rawImages.results.filter((val) => !val.img_src.startsWith("data:"));
|
||||
for (const [i, value] of images.entries()) {
|
||||
embeds.push({
|
||||
embeds: [{
|
||||
title: "Search Results",
|
||||
color: 16711680,
|
||||
footer: {
|
||||
text: `Page ${i + 1} of ${images.length}`
|
||||
},
|
||||
description: value.title,
|
||||
image: {
|
||||
url: encodeURI(value.img_src)
|
||||
},
|
||||
author: {
|
||||
name: this.author.username,
|
||||
iconURL: this.author.avatarURL()
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
this.success = true;
|
||||
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 aliases = ["im", "photo", "img"];
|
||||
static arguments = ["[query]"];
|
||||
}
|
||||
|
||||
export default ImageSearchCommand;
|
|
@ -1,32 +1,32 @@
|
|||
import Command from "../../classes/command.js";
|
||||
import { reloadImageConnections } from "../../utils/image.js";
|
||||
|
||||
class ImageReloadCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can reload the image servers!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const length = await reloadImageConnections();
|
||||
if (!length) {
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "imagereload"
|
||||
}
|
||||
});
|
||||
}
|
||||
return `Successfully connected to ${length} image server(s).`;
|
||||
} else {
|
||||
return "I couldn't connect to any image servers!";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Attempts to reconnect to all available image processing servers";
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
export default ImageReloadCommand;
|
||||
import Command from "../../classes/command.js";
|
||||
import { reloadImageConnections } from "../../utils/image.js";
|
||||
|
||||
class ImageReloadCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can reload the image servers!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const length = await reloadImageConnections();
|
||||
if (!length) {
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "imagereload"
|
||||
}
|
||||
});
|
||||
}
|
||||
return `Successfully connected to ${length} image server(s).`;
|
||||
} else {
|
||||
return "I couldn't connect to any image servers!";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Attempts to reconnect to all available image processing servers";
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
export default ImageReloadCommand;
|
||||
|
|
|
@ -1,34 +1,34 @@
|
|||
import Command from "../../classes/command.js";
|
||||
import { connections } from "../../utils/image.js";
|
||||
|
||||
class ImageStatsCommand extends Command {
|
||||
async run() {
|
||||
await this.acknowledge();
|
||||
const embed = {
|
||||
embeds: [{
|
||||
"author": {
|
||||
"name": "esmBot Image Statistics",
|
||||
"iconURL": this.client.user.avatarURL()
|
||||
},
|
||||
"color": 16711680,
|
||||
"description": `The bot is currently connected to ${connections.size} image server(s).`,
|
||||
"fields": []
|
||||
}]
|
||||
};
|
||||
let i = 0;
|
||||
for (const connection of connections.values()) {
|
||||
const count = await connection.getCount();
|
||||
if (!count) continue;
|
||||
embed.embeds[0].fields.push({
|
||||
name: `Server ${i++}`,
|
||||
value: `Running Jobs: ${count}`
|
||||
});
|
||||
}
|
||||
return embed;
|
||||
}
|
||||
|
||||
static description = "Gets some statistics about the image servers";
|
||||
static aliases = ["imgstat", "imstats", "imgstats", "imstat"];
|
||||
}
|
||||
|
||||
export default ImageStatsCommand;
|
||||
import Command from "../../classes/command.js";
|
||||
import { connections } from "../../utils/image.js";
|
||||
|
||||
class ImageStatsCommand extends Command {
|
||||
async run() {
|
||||
await this.acknowledge();
|
||||
const embed = {
|
||||
embeds: [{
|
||||
"author": {
|
||||
"name": "esmBot Image Statistics",
|
||||
"iconURL": this.client.user.avatarURL()
|
||||
},
|
||||
"color": 16711680,
|
||||
"description": `The bot is currently connected to ${connections.size} image server(s).`,
|
||||
"fields": []
|
||||
}]
|
||||
};
|
||||
let i = 0;
|
||||
for (const connection of connections.values()) {
|
||||
const count = await connection.getCount();
|
||||
if (!count) continue;
|
||||
embed.embeds[0].fields.push({
|
||||
name: `Server ${i++}`,
|
||||
value: `Running Jobs: ${count}`
|
||||
});
|
||||
}
|
||||
return embed;
|
||||
}
|
||||
|
||||
static description = "Gets some statistics about the image servers";
|
||||
static aliases = ["imgstat", "imstats", "imgstats", "imstat"];
|
||||
}
|
||||
|
||||
export default ImageStatsCommand;
|
||||
|
|
|
@ -1,57 +1,57 @@
|
|||
import { readFileSync } from "fs";
|
||||
const { version } = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url)));
|
||||
import Command from "../../classes/command.js";
|
||||
import { getServers } from "../../utils/misc.js";
|
||||
|
||||
class InfoCommand extends Command {
|
||||
async run() {
|
||||
let owner = this.client.users.get(process.env.OWNER.split(",")[0]);
|
||||
if (!owner) owner = await this.client.rest.users.get(process.env.OWNER.split(",")[0]);
|
||||
const servers = await getServers(this.client);
|
||||
await this.acknowledge();
|
||||
return {
|
||||
embeds: [{
|
||||
color: 16711680,
|
||||
author: {
|
||||
name: "esmBot Info/Credits",
|
||||
iconURL: this.client.user.avatarURL()
|
||||
},
|
||||
description: `This instance is managed by **${owner.username}#${owner.discriminator}**.`,
|
||||
fields: [{
|
||||
name: "ℹ️ Version:",
|
||||
value: `v${version}${process.env.NODE_ENV === "development" ? `-dev (${process.env.GIT_REV})` : ""}`
|
||||
},
|
||||
{
|
||||
name: "📝 Credits:",
|
||||
value: "Bot by **[Essem](https://essem.space)** and **[various contributors](https://github.com/esmBot/esmBot/graphs/contributors)**\nLogo by **[MintBurrow](https://twitter.com/MintBurrow)**"
|
||||
},
|
||||
{
|
||||
name: "💬 Total Servers:",
|
||||
value: servers ? servers : `${this.client.guilds.size} (for this process only)`
|
||||
},
|
||||
{
|
||||
name: "✅ Official Server:",
|
||||
value: "[Click here!](https://esmbot.net/support)"
|
||||
},
|
||||
{
|
||||
name: "💻 Source Code:",
|
||||
value: "[Click here!](https://github.com/esmBot/esmBot)"
|
||||
},
|
||||
{
|
||||
name: "🛡️ Privacy Policy:",
|
||||
value: "[Click here!](https://esmbot.net/privacy.html)"
|
||||
},
|
||||
{
|
||||
name: "🐘 Mastodon:",
|
||||
value: "[Click here!](https://wetdry.world/@esmBot)"
|
||||
}
|
||||
]
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
static description = "Gets some info and credits about me";
|
||||
static aliases = ["botinfo", "credits"];
|
||||
}
|
||||
|
||||
import { readFileSync } from "fs";
|
||||
const { version } = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url)));
|
||||
import Command from "../../classes/command.js";
|
||||
import { getServers } from "../../utils/misc.js";
|
||||
|
||||
class InfoCommand extends Command {
|
||||
async run() {
|
||||
let owner = this.client.users.get(process.env.OWNER.split(",")[0]);
|
||||
if (!owner) owner = await this.client.rest.users.get(process.env.OWNER.split(",")[0]);
|
||||
const servers = await getServers(this.client);
|
||||
await this.acknowledge();
|
||||
return {
|
||||
embeds: [{
|
||||
color: 16711680,
|
||||
author: {
|
||||
name: "esmBot Info/Credits",
|
||||
iconURL: this.client.user.avatarURL()
|
||||
},
|
||||
description: `This instance is managed by **${owner.username}#${owner.discriminator}**.`,
|
||||
fields: [{
|
||||
name: "ℹ️ Version:",
|
||||
value: `v${version}${process.env.NODE_ENV === "development" ? `-dev (${process.env.GIT_REV})` : ""}`
|
||||
},
|
||||
{
|
||||
name: "📝 Credits:",
|
||||
value: "Bot by **[Essem](https://essem.space)** and **[various contributors](https://github.com/esmBot/esmBot/graphs/contributors)**\nLogo by **[MintBurrow](https://twitter.com/MintBurrow)**"
|
||||
},
|
||||
{
|
||||
name: "💬 Total Servers:",
|
||||
value: servers ? servers : `${this.client.guilds.size} (for this process only)`
|
||||
},
|
||||
{
|
||||
name: "✅ Official Server:",
|
||||
value: "[Click here!](https://esmbot.net/support)"
|
||||
},
|
||||
{
|
||||
name: "💻 Source Code:",
|
||||
value: "[Click here!](https://github.com/esmBot/esmBot)"
|
||||
},
|
||||
{
|
||||
name: "🛡️ Privacy Policy:",
|
||||
value: "[Click here!](https://esmbot.net/privacy.html)"
|
||||
},
|
||||
{
|
||||
name: "🐘 Mastodon:",
|
||||
value: "[Click here!](https://wetdry.world/@esmBot)"
|
||||
}
|
||||
]
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
static description = "Gets some info and credits about me";
|
||||
static aliases = ["botinfo", "credits"];
|
||||
}
|
||||
|
||||
export default InfoCommand;
|
|
@ -1,32 +1,32 @@
|
|||
import urlCheck from "../../utils/urlcheck.js";
|
||||
import { request } from "undici";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class LengthenCommand extends Command {
|
||||
async run() {
|
||||
await this.acknowledge();
|
||||
const input = this.options.url ?? this.args.join(" ");
|
||||
this.success = false;
|
||||
if (!input || !input.trim() || !urlCheck(input)) return "You need to provide a short URL to lengthen!";
|
||||
if (urlCheck(input)) {
|
||||
const url = await request(encodeURI(input), { method: "HEAD" });
|
||||
this.success = true;
|
||||
return url.headers.location || input;
|
||||
} else {
|
||||
return "That isn't a URL!";
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "url",
|
||||
type: 3,
|
||||
description: "The URL you want to lengthen",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Lengthens a short URL";
|
||||
static aliases = ["longurl", "lengthenurl", "longuri", "lengthenuri", "unshorten"];
|
||||
static arguments = ["[url]"];
|
||||
}
|
||||
|
||||
import urlCheck from "../../utils/urlcheck.js";
|
||||
import { request } from "undici";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class LengthenCommand extends Command {
|
||||
async run() {
|
||||
await this.acknowledge();
|
||||
const input = this.options.url ?? this.args.join(" ");
|
||||
this.success = false;
|
||||
if (!input || !input.trim() || !urlCheck(input)) return "You need to provide a short URL to lengthen!";
|
||||
if (urlCheck(input)) {
|
||||
const url = await request(encodeURI(input), { method: "HEAD" });
|
||||
this.success = true;
|
||||
return url.headers.location || input;
|
||||
} else {
|
||||
return "That isn't a URL!";
|
||||
}
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "url",
|
||||
type: 3,
|
||||
description: "The URL you want to lengthen",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Lengthens a short URL";
|
||||
static aliases = ["longurl", "lengthenurl", "longuri", "lengthenuri", "unshorten"];
|
||||
static arguments = ["[url]"];
|
||||
}
|
||||
|
||||
export default LengthenCommand;
|
|
@ -1,27 +1,27 @@
|
|||
import Command from "../../classes/command.js";
|
||||
|
||||
class PingCommand extends Command {
|
||||
async run() {
|
||||
if (this.type === "classic") {
|
||||
const pingMessage = await this.client.rest.channels.createMessage(this.message.channelID, Object.assign({
|
||||
content: "🏓 Ping?"
|
||||
}, this.reference));
|
||||
await pingMessage.edit({
|
||||
content: `🏓 Pong!\n\`\`\`\nLatency: ${pingMessage.timestamp - this.message.timestamp}ms${this.message.guildID ? `\nShard Latency: ${Math.round(this.client.shards.get(this.client.guildShardMap[this.message.guildID]).latency)}ms` : ""}\n\`\`\``
|
||||
});
|
||||
} else {
|
||||
await this.interaction.createMessage({
|
||||
content: "🏓 Ping?"
|
||||
});
|
||||
const pingMessage = await this.interaction.getOriginal();
|
||||
await this.interaction.editOriginal({
|
||||
content: `🏓 Pong!\n\`\`\`\nLatency: ${pingMessage.timestamp - Math.floor((this.interaction.id / 4194304) + 1420070400000)}ms${this.interaction.guildID ? `\nShard Latency: ${Math.round(this.client.shards.get(this.client.guildShardMap[this.interaction.guildID]).latency)}ms` : ""}\n\`\`\``
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Pings Discord's servers";
|
||||
static aliases = ["pong"];
|
||||
}
|
||||
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class PingCommand extends Command {
|
||||
async run() {
|
||||
if (this.type === "classic") {
|
||||
const pingMessage = await this.client.rest.channels.createMessage(this.message.channelID, Object.assign({
|
||||
content: "🏓 Ping?"
|
||||
}, this.reference));
|
||||
await pingMessage.edit({
|
||||
content: `🏓 Pong!\n\`\`\`\nLatency: ${pingMessage.timestamp - this.message.timestamp}ms${this.message.guildID ? `\nShard Latency: ${Math.round(this.client.shards.get(this.client.guildShardMap[this.message.guildID]).latency)}ms` : ""}\n\`\`\``
|
||||
});
|
||||
} else {
|
||||
await this.interaction.createMessage({
|
||||
content: "🏓 Ping?"
|
||||
});
|
||||
const pingMessage = await this.interaction.getOriginal();
|
||||
await this.interaction.editOriginal({
|
||||
content: `🏓 Pong!\n\`\`\`\nLatency: ${pingMessage.timestamp - Math.floor((this.interaction.id / 4194304) + 1420070400000)}ms${this.interaction.guildID ? `\nShard Latency: ${Math.round(this.client.shards.get(this.client.guildShardMap[this.interaction.guildID]).latency)}ms` : ""}\n\`\`\``
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Pings Discord's servers";
|
||||
static aliases = ["pong"];
|
||||
}
|
||||
|
||||
export default PingCommand;
|
|
@ -1,30 +1,30 @@
|
|||
import database from "../../utils/database.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class PrefixCommand extends Command {
|
||||
async run() {
|
||||
if (!this.guild) return `The current prefix is \`${process.env.PREFIX}\`.`;
|
||||
const guild = await database.getGuild(this.guild.id);
|
||||
if (this.args.length !== 0) {
|
||||
if (!database) {
|
||||
return "Setting a per-guild prefix is not possible on a stateless instance of esmBot!";
|
||||
}
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!this.member.permissions.has("ADMINISTRATOR") && !owners.includes(this.member.id)) {
|
||||
this.success = false;
|
||||
return "You need to be an administrator to change the bot prefix!";
|
||||
}
|
||||
await database.setPrefix(this.args[0], this.guild);
|
||||
return `The prefix has been changed to ${this.args[0]}.`;
|
||||
} else {
|
||||
return `The current prefix is \`${guild.prefix}\`.`;
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Checks/changes the server prefix";
|
||||
static aliases = ["setprefix", "changeprefix", "checkprefix"];
|
||||
static arguments = ["{prefix}"];
|
||||
static slashAllowed = false;
|
||||
}
|
||||
|
||||
import database from "../../utils/database.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class PrefixCommand extends Command {
|
||||
async run() {
|
||||
if (!this.guild) return `The current prefix is \`${process.env.PREFIX}\`.`;
|
||||
const guild = await database.getGuild(this.guild.id);
|
||||
if (this.args.length !== 0) {
|
||||
if (!database) {
|
||||
return "Setting a per-guild prefix is not possible on a stateless instance of esmBot!";
|
||||
}
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!this.member.permissions.has("ADMINISTRATOR") && !owners.includes(this.member.id)) {
|
||||
this.success = false;
|
||||
return "You need to be an administrator to change the bot prefix!";
|
||||
}
|
||||
await database.setPrefix(this.args[0], this.guild);
|
||||
return `The prefix has been changed to ${this.args[0]}.`;
|
||||
} else {
|
||||
return `The current prefix is \`${guild.prefix}\`.`;
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Checks/changes the server prefix";
|
||||
static aliases = ["setprefix", "changeprefix", "checkprefix"];
|
||||
static arguments = ["{prefix}"];
|
||||
static slashAllowed = false;
|
||||
}
|
||||
|
||||
export default PrefixCommand;
|
|
@ -1,40 +1,40 @@
|
|||
import qrcode from "qrcode";
|
||||
import { PassThrough } from "stream";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class QrCreateCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) {
|
||||
this.success = false;
|
||||
return "You need to provide some text to generate a QR code!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const writable = new PassThrough();
|
||||
qrcode.toFileStream(writable, this.content, { margin: 1 });
|
||||
const file = await this.streamToBuf(writable);
|
||||
return {
|
||||
contents: file,
|
||||
name: "qr.png"
|
||||
};
|
||||
}
|
||||
|
||||
streamToBuf(stream) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks = [];
|
||||
stream.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
stream.once("error", (error) => {
|
||||
reject(error);
|
||||
});
|
||||
stream.once("end", () => {
|
||||
resolve(Buffer.concat(chunks));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static description = "Generates a QR code";
|
||||
static arguments = ["[text]"];
|
||||
}
|
||||
|
||||
import qrcode from "qrcode";
|
||||
import { PassThrough } from "stream";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class QrCreateCommand extends Command {
|
||||
async run() {
|
||||
if (this.args.length === 0) {
|
||||
this.success = false;
|
||||
return "You need to provide some text to generate a QR code!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const writable = new PassThrough();
|
||||
qrcode.toFileStream(writable, this.content, { margin: 1 });
|
||||
const file = await this.streamToBuf(writable);
|
||||
return {
|
||||
contents: file,
|
||||
name: "qr.png"
|
||||
};
|
||||
}
|
||||
|
||||
streamToBuf(stream) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const chunks = [];
|
||||
stream.on("data", (chunk) => {
|
||||
chunks.push(chunk);
|
||||
});
|
||||
stream.once("error", (error) => {
|
||||
reject(error);
|
||||
});
|
||||
stream.once("end", () => {
|
||||
resolve(Buffer.concat(chunks));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static description = "Generates a QR code";
|
||||
static arguments = ["[text]"];
|
||||
}
|
||||
|
||||
export default QrCreateCommand;
|
|
@ -1,34 +1,34 @@
|
|||
import jsqr from "jsqr";
|
||||
import { request } from "undici";
|
||||
import sharp from "sharp";
|
||||
import { clean } from "../../utils/misc.js";
|
||||
import Command from "../../classes/command.js";
|
||||
import imageDetect from "../../utils/imagedetect.js";
|
||||
|
||||
class QrReadCommand extends Command {
|
||||
async run() {
|
||||
const image = await imageDetect(this.client, this.message, this.interaction, this.options);
|
||||
this.success = false;
|
||||
if (image === undefined) return "You need to provide an image/GIF with a QR code to read!";
|
||||
await this.acknowledge();
|
||||
const data = Buffer.from(await (await request(image.path)).body.arrayBuffer());
|
||||
const rawData = await sharp(data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
|
||||
if (!qrBuffer) return "I couldn't find a QR code!";
|
||||
this.success = true;
|
||||
return `\`\`\`\n${await clean(qrBuffer.data)}\n\`\`\``;
|
||||
}
|
||||
|
||||
static description = "Reads a QR code";
|
||||
static flags = [{
|
||||
name: "image",
|
||||
type: 11,
|
||||
description: "An image/GIF attachment"
|
||||
}, {
|
||||
name: "link",
|
||||
type: 3,
|
||||
description: "An image/GIF URL"
|
||||
}];
|
||||
}
|
||||
|
||||
export default QrReadCommand;
|
||||
import jsqr from "jsqr";
|
||||
import { request } from "undici";
|
||||
import sharp from "sharp";
|
||||
import { clean } from "../../utils/misc.js";
|
||||
import Command from "../../classes/command.js";
|
||||
import imageDetect from "../../utils/imagedetect.js";
|
||||
|
||||
class QrReadCommand extends Command {
|
||||
async run() {
|
||||
const image = await imageDetect(this.client, this.message, this.interaction, this.options);
|
||||
this.success = false;
|
||||
if (image === undefined) return "You need to provide an image/GIF with a QR code to read!";
|
||||
await this.acknowledge();
|
||||
const data = Buffer.from(await (await request(image.path)).body.arrayBuffer());
|
||||
const rawData = await sharp(data).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
|
||||
const qrBuffer = jsqr(rawData.data, rawData.info.width, rawData.info.height);
|
||||
if (!qrBuffer) return "I couldn't find a QR code!";
|
||||
this.success = true;
|
||||
return `\`\`\`\n${await clean(qrBuffer.data)}\n\`\`\``;
|
||||
}
|
||||
|
||||
static description = "Reads a QR code";
|
||||
static flags = [{
|
||||
name: "image",
|
||||
type: 11,
|
||||
description: "An image/GIF attachment"
|
||||
}, {
|
||||
name: "link",
|
||||
type: 3,
|
||||
description: "An image/GIF URL"
|
||||
}];
|
||||
}
|
||||
|
||||
export default QrReadCommand;
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
import Command from "../../classes/command.js";
|
||||
import imageDetect from "../../utils/imagedetect.js";
|
||||
|
||||
class RawCommand extends Command {
|
||||
async run() {
|
||||
await this.acknowledge();
|
||||
const image = await imageDetect(this.client, this.message, this.interaction, this.options);
|
||||
if (image === undefined) {
|
||||
this.success = false;
|
||||
return "You need to provide an image/GIF to get a raw URL!";
|
||||
}
|
||||
return image.path;
|
||||
}
|
||||
|
||||
static description = "Gets a direct image URL (useful for saving GIFs from sites like Tenor)";
|
||||
static aliases = ["giflink", "imglink", "getimg", "rawgif", "rawimg"];
|
||||
static flags = [{
|
||||
name: "image",
|
||||
type: 11,
|
||||
description: "An image/GIF attachment"
|
||||
}, {
|
||||
name: "link",
|
||||
type: 3,
|
||||
description: "An image/GIF URL"
|
||||
}];
|
||||
}
|
||||
|
||||
export default RawCommand;
|
||||
import Command from "../../classes/command.js";
|
||||
import imageDetect from "../../utils/imagedetect.js";
|
||||
|
||||
class RawCommand extends Command {
|
||||
async run() {
|
||||
await this.acknowledge();
|
||||
const image = await imageDetect(this.client, this.message, this.interaction, this.options);
|
||||
if (image === undefined) {
|
||||
this.success = false;
|
||||
return "You need to provide an image/GIF to get a raw URL!";
|
||||
}
|
||||
return image.path;
|
||||
}
|
||||
|
||||
static description = "Gets a direct image URL (useful for saving GIFs from sites like Tenor)";
|
||||
static aliases = ["giflink", "imglink", "getimg", "rawgif", "rawimg"];
|
||||
static flags = [{
|
||||
name: "image",
|
||||
type: 11,
|
||||
description: "An image/GIF attachment"
|
||||
}, {
|
||||
name: "link",
|
||||
type: 3,
|
||||
description: "An image/GIF URL"
|
||||
}];
|
||||
}
|
||||
|
||||
export default RawCommand;
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
import Command from "../../classes/command.js";
|
||||
import { load } from "../../utils/handler.js";
|
||||
import { paths } from "../../utils/collections.js";
|
||||
|
||||
class ReloadCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) return "Only the bot owner can reload commands!";
|
||||
const commandName = this.options.cmd ?? this.args.join(" ");
|
||||
if (!commandName || !commandName.trim()) return "You need to provide a command to reload!";
|
||||
await this.acknowledge();
|
||||
const path = paths.get(commandName);
|
||||
if (!path) return "I couldn't find that command!";
|
||||
const result = await load(this.client, path, true);
|
||||
if (result !== commandName) return "I couldn't reload that command!";
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "reload",
|
||||
message: commandName
|
||||
}
|
||||
});
|
||||
}
|
||||
return `The command \`${commandName}\` has been reloaded.`;
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "cmd",
|
||||
type: 3,
|
||||
description: "The command to reload",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Reloads a command";
|
||||
static arguments = ["[command]"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
export default ReloadCommand;
|
||||
import Command from "../../classes/command.js";
|
||||
import { load } from "../../utils/handler.js";
|
||||
import { paths } from "../../utils/collections.js";
|
||||
|
||||
class ReloadCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.sender)) return "Only the bot owner can reload commands!";
|
||||
const commandName = this.options.cmd ?? this.args.join(" ");
|
||||
if (!commandName || !commandName.trim()) return "You need to provide a command to reload!";
|
||||
await this.acknowledge();
|
||||
const path = paths.get(commandName);
|
||||
if (!path) return "I couldn't find that command!";
|
||||
const result = await load(this.matrixClient, path, true);
|
||||
if (result !== commandName) return "I couldn't reload that command!";
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "reload",
|
||||
message: commandName
|
||||
}
|
||||
});
|
||||
}
|
||||
return `The command \`${commandName}\` has been reloaded.`;
|
||||
}
|
||||
|
||||
static flags = [{
|
||||
name: "cmd",
|
||||
type: 3,
|
||||
description: "The command to reload",
|
||||
required: true
|
||||
}];
|
||||
|
||||
static description = "Reloads a command";
|
||||
static arguments = ["[command]"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
export default ReloadCommand;
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import Command from "../../classes/command.js";
|
||||
|
||||
class RestartCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can restart me!";
|
||||
}
|
||||
await this.channel.createMessage(Object.assign({
|
||||
content: "esmBot is restarting."
|
||||
}, this.reference));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
static description = "Restarts me";
|
||||
static aliases = ["reboot"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class RestartCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can restart me!";
|
||||
}
|
||||
await this.channel.createMessage(Object.assign({
|
||||
content: "esmBot is restarting."
|
||||
}, this.reference));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
static description = "Restarts me";
|
||||
static aliases = ["reboot"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
export default RestartCommand;
|
|
@ -1,20 +1,20 @@
|
|||
import Command from "../../classes/command.js";
|
||||
|
||||
class SnowflakeCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (!this.args[0]) return "You need to provide a snowflake ID!";
|
||||
if (!this.args[0].match(/^<?[@#]?[&!]?\d+>?$/) && this.args[0] < 21154535154122752n) return "That's not a valid snowflake!";
|
||||
const id = Math.floor(((this.args[0].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "") / 4194304) + 1420070400000) / 1000);
|
||||
if (isNaN(id)) return "That's not a valid snowflake!";
|
||||
this.success = true;
|
||||
return `<t:${id}:F>`;
|
||||
}
|
||||
|
||||
static description = "Converts a Discord snowflake id into a timestamp";
|
||||
static aliases = ["timestamp", "snowstamp", "snow"];
|
||||
static arguments = ["[id]"];
|
||||
static slashAllowed = false;
|
||||
}
|
||||
|
||||
export default SnowflakeCommand;
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class SnowflakeCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (!this.args[0]) return "You need to provide a snowflake ID!";
|
||||
if (!this.args[0].match(/^<?[@#]?[&!]?\d+>?$/) && this.args[0] < 21154535154122752n) return "That's not a valid snowflake!";
|
||||
const id = Math.floor(((this.args[0].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "") / 4194304) + 1420070400000) / 1000);
|
||||
if (isNaN(id)) return "That's not a valid snowflake!";
|
||||
this.success = true;
|
||||
return `<t:${id}:F>`;
|
||||
}
|
||||
|
||||
static description = "Converts a Discord snowflake id into a timestamp";
|
||||
static aliases = ["timestamp", "snowstamp", "snow"];
|
||||
static arguments = ["[id]"];
|
||||
static slashAllowed = false;
|
||||
}
|
||||
|
||||
export default SnowflakeCommand;
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
import Command from "../../classes/command.js";
|
||||
import { reload } from "../../utils/soundplayer.js";
|
||||
|
||||
class SoundReloadCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can reload Lavalink!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const length = await reload();
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "soundreload"
|
||||
}
|
||||
});
|
||||
}
|
||||
if (length) {
|
||||
return `Successfully connected to ${length} Lavalink node(s).`;
|
||||
} else {
|
||||
return "I couldn't connect to any Lavalink nodes!";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Attempts to reconnect to all available Lavalink nodes";
|
||||
static aliases = ["lava", "lavalink", "lavaconnect", "soundconnect"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
import Command from "../../classes/command.js";
|
||||
import { reload } from "../../utils/soundplayer.js";
|
||||
|
||||
class SoundReloadCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can reload Lavalink!";
|
||||
}
|
||||
await this.acknowledge();
|
||||
const length = await reload();
|
||||
if (process.env.PM2_USAGE) {
|
||||
process.send({
|
||||
type: "process:msg",
|
||||
data: {
|
||||
type: "soundreload"
|
||||
}
|
||||
});
|
||||
}
|
||||
if (length) {
|
||||
return `Successfully connected to ${length} Lavalink node(s).`;
|
||||
} else {
|
||||
return "I couldn't connect to any Lavalink nodes!";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Attempts to reconnect to all available Lavalink nodes";
|
||||
static aliases = ["lava", "lavalink", "lavaconnect", "soundconnect"];
|
||||
static adminOnly = true;
|
||||
}
|
||||
|
||||
export default SoundReloadCommand;
|
|
@ -1,90 +1,90 @@
|
|||
import { readFileSync } from "fs";
|
||||
const { version } = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url)));
|
||||
import os from "os";
|
||||
import Command from "../../classes/command.js";
|
||||
import { VERSION } from "oceanic.js";
|
||||
import pm2 from "pm2";
|
||||
import { getServers } from "../../utils/misc.js";
|
||||
|
||||
class StatsCommand extends Command {
|
||||
async run() {
|
||||
const uptime = process.uptime() * 1000;
|
||||
const connUptime = this.client.uptime;
|
||||
let owner = this.client.users.get(process.env.OWNER.split(",")[0]);
|
||||
if (!owner) owner = await this.client.rest.users.get(process.env.OWNER.split(",")[0]);
|
||||
const servers = await getServers(this.client);
|
||||
const processMem = `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB`;
|
||||
return {
|
||||
embeds: [{
|
||||
"author": {
|
||||
"name": "esmBot Statistics",
|
||||
"iconURL": this.client.user.avatarURL()
|
||||
},
|
||||
"description": `This instance is managed by **${owner.username}#${owner.discriminator}**.`,
|
||||
"color": 16711680,
|
||||
"fields": [{
|
||||
"name": "Version",
|
||||
"value": `v${version}${process.env.NODE_ENV === "development" ? `-dev (${process.env.GIT_REV})` : ""}`
|
||||
},
|
||||
{
|
||||
"name": "Process Memory Usage",
|
||||
"value": processMem,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Total Memory Usage",
|
||||
"value": process.env.PM2_USAGE ? `${((await this.list()).reduce((prev, cur) => prev + cur.monit.memory, 0) / 1024 / 1024).toFixed(2)} MB` : processMem,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Bot Uptime",
|
||||
"value": `${Math.trunc(uptime / 86400000)} days, ${Math.trunc(uptime / 3600000) % 24} hrs, ${Math.trunc(uptime / 60000) % 60} mins, ${Math.trunc(uptime / 1000) % 60} secs`
|
||||
},
|
||||
{
|
||||
"name": "Connection Uptime",
|
||||
"value": `${Math.trunc(connUptime / 86400000)} days, ${Math.trunc(connUptime / 3600000) % 24} hrs, ${Math.trunc(connUptime / 60000) % 60} mins, ${Math.trunc(connUptime / 1000) % 60} secs`
|
||||
},
|
||||
{
|
||||
"name": "Host",
|
||||
"value": `${os.type()} ${os.release()} (${os.arch()})`,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Library",
|
||||
"value": `Oceanic ${VERSION}`,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Node.js Version",
|
||||
"value": process.version,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Shard",
|
||||
"value": this.guild ? this.client.guildShardMap[this.guild.id] : "N/A",
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Servers",
|
||||
"value": servers ? servers : `${this.client.guilds.size} (for this process only)`,
|
||||
"inline": true
|
||||
}
|
||||
]
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
list() {
|
||||
return new Promise((resolve, reject) => {
|
||||
pm2.list((err, list) => {
|
||||
if (err) return reject(err);
|
||||
resolve(list.filter((v) => v.name.includes("esmBot-proc")));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static description = "Gets some statistics about me";
|
||||
static aliases = ["status", "stat"];
|
||||
}
|
||||
|
||||
import { readFileSync } from "fs";
|
||||
const { version } = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url)));
|
||||
import os from "os";
|
||||
import Command from "../../classes/command.js";
|
||||
import { VERSION } from "oceanic.js";
|
||||
import pm2 from "pm2";
|
||||
import { getServers } from "../../utils/misc.js";
|
||||
|
||||
class StatsCommand extends Command {
|
||||
async run() {
|
||||
const uptime = process.uptime() * 1000;
|
||||
const connUptime = this.client.uptime;
|
||||
let owner = this.client.users.get(process.env.OWNER.split(",")[0]);
|
||||
if (!owner) owner = await this.client.rest.users.get(process.env.OWNER.split(",")[0]);
|
||||
const servers = await getServers(this.client);
|
||||
const processMem = `${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)} MB`;
|
||||
return {
|
||||
embeds: [{
|
||||
"author": {
|
||||
"name": "esmBot Statistics",
|
||||
"iconURL": this.client.user.avatarURL()
|
||||
},
|
||||
"description": `This instance is managed by **${owner.username}#${owner.discriminator}**.`,
|
||||
"color": 16711680,
|
||||
"fields": [{
|
||||
"name": "Version",
|
||||
"value": `v${version}${process.env.NODE_ENV === "development" ? `-dev (${process.env.GIT_REV})` : ""}`
|
||||
},
|
||||
{
|
||||
"name": "Process Memory Usage",
|
||||
"value": processMem,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Total Memory Usage",
|
||||
"value": process.env.PM2_USAGE ? `${((await this.list()).reduce((prev, cur) => prev + cur.monit.memory, 0) / 1024 / 1024).toFixed(2)} MB` : processMem,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Bot Uptime",
|
||||
"value": `${Math.trunc(uptime / 86400000)} days, ${Math.trunc(uptime / 3600000) % 24} hrs, ${Math.trunc(uptime / 60000) % 60} mins, ${Math.trunc(uptime / 1000) % 60} secs`
|
||||
},
|
||||
{
|
||||
"name": "Connection Uptime",
|
||||
"value": `${Math.trunc(connUptime / 86400000)} days, ${Math.trunc(connUptime / 3600000) % 24} hrs, ${Math.trunc(connUptime / 60000) % 60} mins, ${Math.trunc(connUptime / 1000) % 60} secs`
|
||||
},
|
||||
{
|
||||
"name": "Host",
|
||||
"value": `${os.type()} ${os.release()} (${os.arch()})`,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Library",
|
||||
"value": `Oceanic ${VERSION}`,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Node.js Version",
|
||||
"value": process.version,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Shard",
|
||||
"value": this.guild ? this.client.guildShardMap[this.guild.id] : "N/A",
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
"name": "Servers",
|
||||
"value": servers ? servers : `${this.client.guilds.size} (for this process only)`,
|
||||
"inline": true
|
||||
}
|
||||
]
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
list() {
|
||||
return new Promise((resolve, reject) => {
|
||||
pm2.list((err, list) => {
|
||||
if (err) return reject(err);
|
||||
resolve(list.filter((v) => v.name.includes("esmBot-proc")));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static description = "Gets some statistics about me";
|
||||
static aliases = ["status", "stat"];
|
||||
}
|
||||
|
||||
export default StatsCommand;
|
|
@ -1,36 +1,36 @@
|
|||
import Command from "../../classes/command.js";
|
||||
import imagedetect from "../../utils/imagedetect.js";
|
||||
|
||||
class StickerCommand extends Command {
|
||||
async run() {
|
||||
const result = await imagedetect(this.client, this.message, this.interaction, this.options, false, false, true);
|
||||
this.success = false;
|
||||
if (!result) return "You need to provide a sticker!";
|
||||
if (result.format_type === 1) { // PNG
|
||||
this.success = true;
|
||||
return `https://cdn.discordapp.com/stickers/${result.id}.png`;
|
||||
} else if (result.format_type === 2) { // APNG
|
||||
this.success = true;
|
||||
return {
|
||||
embeds: [{
|
||||
color: 16711680,
|
||||
description: `[This sticker is an APNG; however, since Discord doesn't allow displaying APNGs outside of stickers, you'll have to save it or open it in your browser to view it.](https://cdn.discordapp.com/stickers/${result.id}.png)`,
|
||||
image: {
|
||||
url: `https://cdn.discordapp.com/stickers/${result.id}.png`
|
||||
}
|
||||
}]
|
||||
};
|
||||
} else if (result.format_type === 3) { // Lottie
|
||||
this.success = true;
|
||||
return `I can't display this sticker because it uses the Lottie animation format; however, I can give you the raw JSON link to it: https://cdn.discordapp.com/stickers/${result.id}.json`;
|
||||
} else {
|
||||
return "I don't recognize that sticker format!";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Gets a raw sticker image";
|
||||
static aliases = ["stick"];
|
||||
static arguments = ["[sticker]"];
|
||||
}
|
||||
|
||||
import Command from "../../classes/command.js";
|
||||
import imagedetect from "../../utils/imagedetect.js";
|
||||
|
||||
class StickerCommand extends Command {
|
||||
async run() {
|
||||
const result = await imagedetect(this.client, this.message, this.interaction, this.options, false, false, true);
|
||||
this.success = false;
|
||||
if (!result) return "You need to provide a sticker!";
|
||||
if (result.format_type === 1) { // PNG
|
||||
this.success = true;
|
||||
return `https://cdn.discordapp.com/stickers/${result.id}.png`;
|
||||
} else if (result.format_type === 2) { // APNG
|
||||
this.success = true;
|
||||
return {
|
||||
embeds: [{
|
||||
color: 16711680,
|
||||
description: `[This sticker is an APNG; however, since Discord doesn't allow displaying APNGs outside of stickers, you'll have to save it or open it in your browser to view it.](https://cdn.discordapp.com/stickers/${result.id}.png)`,
|
||||
image: {
|
||||
url: `https://cdn.discordapp.com/stickers/${result.id}.png`
|
||||
}
|
||||
}]
|
||||
};
|
||||
} else if (result.format_type === 3) { // Lottie
|
||||
this.success = true;
|
||||
return `I can't display this sticker because it uses the Lottie animation format; however, I can give you the raw JSON link to it: https://cdn.discordapp.com/stickers/${result.id}.json`;
|
||||
} else {
|
||||
return "I don't recognize that sticker format!";
|
||||
}
|
||||
}
|
||||
|
||||
static description = "Gets a raw sticker image";
|
||||
static aliases = ["stick"];
|
||||
static arguments = ["[sticker]"];
|
||||
}
|
||||
|
||||
export default StickerCommand;
|
|
@ -1,36 +1,35 @@
|
|||
import { request } from "undici";
|
||||
import { readFileSync } from "fs";
|
||||
const { searx } = JSON.parse(readFileSync(new URL("../../config/servers.json", import.meta.url)));
|
||||
import { random } from "../../utils/misc.js";
|
||||
import paginator from "../../utils/pagination/pagination.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class YouTubeCommand extends Command {
|
||||
async run() {
|
||||
const query = this.options.query ?? this.args.join(" ");
|
||||
this.success = false;
|
||||
if (!query || !query.trim()) return "You need to provide something to search for!";
|
||||
await this.acknowledge();
|
||||
const messages = [];
|
||||
const videos = await request(`${random(searx)}/search?format=json&safesearch=1&categories=videos&q=!youtube%20${encodeURIComponent(query)}`).then(res => res.body.json());
|
||||
if (videos.results.length === 0) return "I couldn't find any results!";
|
||||
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}` });
|
||||
}
|
||||
this.success = true;
|
||||
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 aliases = ["yt", "video", "ytsearch"];
|
||||
static arguments = ["[query]"];
|
||||
}
|
||||
|
||||
import { request } from "undici";
|
||||
import { readFileSync } from "fs";
|
||||
const { searx } = JSON.parse(readFileSync(new URL("../../config/servers.json", import.meta.url)));
|
||||
import { random } from "../../utils/misc.js";
|
||||
// import paginator from "../../utils/pagination/pagination.js";
|
||||
import Command from "../../classes/command.js";
|
||||
|
||||
class YouTubeCommand extends Command {
|
||||
async run() {
|
||||
const query = this.options.query ?? this.args.join(" ");
|
||||
this.success = false;
|
||||
if (!query || !query.trim()) return "You need to provide something to search for!";
|
||||
await this.acknowledge();
|
||||
const messages = [];
|
||||
const videos = await request(`${random(searx)}/search?format=json&safesearch=1&categories=videos&q=!youtube%20${encodeURIComponent(query)}`).then(res => res.body.json());
|
||||
if (videos.results.length === 0) return "I couldn't find any results!";
|
||||
// console.log(videos.results[0])
|
||||
this.success = true;
|
||||
return videos.results[0].url
|
||||
// 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 aliases = ["yt", "video", "ytsearch"];
|
||||
static arguments = ["[query]"];
|
||||
}
|
||||
|
||||
export default YouTubeCommand;
|
Loading…
Add table
Add a link
Reference in a new issue