Initial Oceanic port (still unfinished), update packages, remove serverinfo and userinfo
This commit is contained in:
parent
bf90ae108a
commit
888f2f8b4a
49 changed files with 573 additions and 515 deletions
|
@ -26,8 +26,8 @@ class AvatarCommand extends Command {
|
|||
} else {
|
||||
return self.dynamicAvatarURL(null, 512);
|
||||
}
|
||||
} else if (this.args.join(" ") !== "" && this.channel.guild) {
|
||||
const searched = await this.channel.guild.searchMembers(this.args.join(" "));
|
||||
} else if (this.args.join(" ") !== "" && this.guild) {
|
||||
const searched = await this.guild.searchMembers(this.args.join(" "));
|
||||
if (searched.length === 0) return self.dynamicAvatarURL(null, 512);
|
||||
const user = await this.client.getRESTUser(searched[0].user.id);
|
||||
return user ? user.dynamicAvatarURL(null, 512) : self.dynamicAvatarURL(null, 512);
|
||||
|
|
|
@ -26,8 +26,8 @@ class BannerCommand extends Command {
|
|||
} else {
|
||||
return "This user doesn't have a banner!";
|
||||
}
|
||||
} else if (this.args.join(" ") !== "" && this.channel.guild) {
|
||||
const searched = await this.channel.guild.searchMembers(this.args.join(" "));
|
||||
} else if (this.args.join(" ") !== "" && this.guild) {
|
||||
const searched = await this.guild.searchMembers(this.args.join(" "));
|
||||
if (searched.length === 0) return self.dynamicBannerURL(null, 512) ?? "This user doesn't have a banner!";
|
||||
const user = await this.client.getRESTUser(searched[0].user.id);
|
||||
return user.dynamicBannerURL(null, 512) ?? (self.dynamicBannerURL(null, 512) ?? "This user doesn't have a banner!");
|
||||
|
|
|
@ -4,20 +4,20 @@ import Command from "../../classes/command.js";
|
|||
class ChannelCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (!this.channel.guild) return "This command only works in servers!";
|
||||
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.channel.guild.id);
|
||||
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.channel.guild.channels.get(id);
|
||||
channel = this.guild.channels.get(id);
|
||||
} else {
|
||||
if (guildDB.disabled.includes(this.channel.id)) return "I'm already disabled in this channel!";
|
||||
channel = this.channel;
|
||||
|
@ -31,7 +31,7 @@ class ChannelCommand extends Command {
|
|||
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.channel.guild.channels.get(id);
|
||||
channel = this.guild.channels.get(id);
|
||||
} else {
|
||||
if (!guildDB.disabled.includes(this.channel.id)) return "I'm not disabled in this channel!";
|
||||
channel = this.channel;
|
||||
|
|
|
@ -5,7 +5,7 @@ import * as collections from "../../utils/collections.js";
|
|||
class CommandCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (!this.channel.guild) return "This command only works in servers!";
|
||||
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!";
|
||||
|
@ -13,7 +13,7 @@ class CommandCommand extends Command {
|
|||
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.channel.guild.id);
|
||||
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();
|
||||
|
||||
|
@ -21,13 +21,13 @@ class CommandCommand extends Command {
|
|||
if (command === "command") return "You can't disable that command!";
|
||||
if (disabled?.includes(command)) return "That command is already disabled!";
|
||||
|
||||
await db.disableCommand(this.channel.guild.id, command);
|
||||
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.channel.guild.id, command);
|
||||
await db.enableCommand(this.guild.id, command);
|
||||
this.success = true;
|
||||
return `The command \`${command}\` has been re-enabled.`;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class CountCommand extends Command {
|
||||
async run() {
|
||||
if (this.channel.guild && !this.channel.permissionsOf(this.client.user.id).has("embedLinks")) {
|
||||
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!";
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class CountCommand extends Command {
|
|||
description: value.join("\n"),
|
||||
author: {
|
||||
name: this.author.username,
|
||||
icon_url: this.author.avatarURL
|
||||
iconURL: this.author.avatarURL()
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Constants } from "eris";
|
||||
import { Constants } from "oceanic.js";
|
||||
import database from "../../utils/database.js";
|
||||
import * as collections from "../../utils/collections.js";
|
||||
import { random } from "../../utils/misc.js";
|
||||
|
@ -10,7 +10,7 @@ const argTypes = Object.keys(Constants.ApplicationCommandOptionTypes);
|
|||
|
||||
class HelpCommand extends Command {
|
||||
async run() {
|
||||
const { prefix } = this.channel.guild ? await database.getGuild(this.channel.guild.id) : "N/A";
|
||||
const { prefix } = this.guild ? await database.getGuild(this.guild.id) : "N/A";
|
||||
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);
|
||||
|
@ -19,9 +19,9 @@ class HelpCommand extends Command {
|
|||
embeds: [{
|
||||
author: {
|
||||
name: "esmBot Help",
|
||||
icon_url: this.client.user.avatarURL
|
||||
iconURL: this.client.user.avatarURL()
|
||||
},
|
||||
title: `${this.channel.guild ? prefix : ""}${command}`,
|
||||
title: `${this.guild ? prefix : ""}${command}`,
|
||||
url: "https://projectlounge.pw/esmBot/help.html",
|
||||
description: command === "tags" ? "The main tags command. Check the help page for more info: https://projectlounge.pw/esmBot/help.html" : info.description,
|
||||
color: 16711680,
|
||||
|
@ -54,12 +54,12 @@ class HelpCommand extends Command {
|
|||
}
|
||||
return embed;
|
||||
} else {
|
||||
if (this.channel.guild && !this.channel.permissionsOf(this.client.user.id).has("embedLinks")) {
|
||||
if (this.guild && !this.channel.permissionsOf(this.client.user.id).has("EMBED_LINKS")) {
|
||||
this.success = false;
|
||||
return "I don't have the `Embed Links` permission!";
|
||||
}
|
||||
const pages = [];
|
||||
if (help.categories === help.categoryTemplate && !help.generated) await help.generateList();
|
||||
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;
|
||||
|
@ -83,7 +83,7 @@ class HelpCommand extends Command {
|
|||
embeds: [{
|
||||
author: {
|
||||
name: "esmBot Help",
|
||||
icon_url: this.client.user.avatarURL
|
||||
iconURL: this.client.user.avatarURL()
|
||||
},
|
||||
title: value.title,
|
||||
description: value.page.join("\n"),
|
||||
|
@ -93,7 +93,7 @@ class HelpCommand extends Command {
|
|||
},
|
||||
fields: [{
|
||||
name: "Prefix",
|
||||
value: this.channel.guild ? prefix : "N/A"
|
||||
value: this.guild ? prefix : "N/A"
|
||||
}, {
|
||||
name: "Tip",
|
||||
value: random(tips)
|
||||
|
@ -101,7 +101,7 @@ class HelpCommand extends Command {
|
|||
}]
|
||||
});
|
||||
}
|
||||
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, channel: this.channel, author: this.author }, embeds);
|
||||
return paginator(this.client, { type: this.type, message: this.message, interaction: this.interaction, author: this.author }, embeds);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import Command from "../../classes/command.js";
|
|||
class ImageSearchCommand extends Command {
|
||||
async run() {
|
||||
this.success = false;
|
||||
if (this.channel.guild && !this.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
|
||||
if (this.channel && !this.channel.permissionsOf(this.client.user.id).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();
|
||||
|
@ -30,7 +30,7 @@ class ImageSearchCommand extends Command {
|
|||
},
|
||||
author: {
|
||||
name: this.author.username,
|
||||
icon_url: this.author.avatarURL
|
||||
iconURL: this.author.avatarURL()
|
||||
}
|
||||
}]
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ class ImageStatsCommand extends Command {
|
|||
embeds: [{
|
||||
"author": {
|
||||
"name": "esmBot Image Statistics",
|
||||
"icon_url": this.client.user.avatarURL
|
||||
"iconURL": this.client.user.avatarURL
|
||||
},
|
||||
"color": 16711680,
|
||||
"description": `The bot is currently connected to ${connections.size} image server(s).`,
|
||||
|
|
|
@ -5,7 +5,8 @@ import { getServers } from "../../utils/misc.js";
|
|||
|
||||
class InfoCommand extends Command {
|
||||
async run() {
|
||||
const owner = await this.client.getRESTUser(process.env.OWNER.split(",")[0]);
|
||||
let owner = this.client.users.get(process.env.OWNER.split(",")[0]);
|
||||
if (!owner) owner = await this.client.getRESTUser(process.env.OWNER.split(",")[0]);
|
||||
const servers = await getServers(this.client);
|
||||
await this.acknowledge();
|
||||
return {
|
||||
|
@ -13,7 +14,7 @@ class InfoCommand extends Command {
|
|||
color: 16711680,
|
||||
author: {
|
||||
name: "esmBot Info/Credits",
|
||||
icon_url: this.client.user.avatarURL
|
||||
iconURL: this.client.user.avatarURL()
|
||||
},
|
||||
description: `This instance is managed by **${owner.username}#${owner.discriminator}**.`,
|
||||
fields: [{
|
||||
|
|
|
@ -3,14 +3,20 @@ import Command from "../../classes/command.js";
|
|||
class PingCommand extends Command {
|
||||
async run() {
|
||||
if (this.type === "classic") {
|
||||
const pingMessage = await this.client.createMessage(this.channel.id, Object.assign({
|
||||
const pingMessage = await this.client.rest.channels.createMessage(this.message.channelID, Object.assign({
|
||||
content: "🏓 Ping?"
|
||||
}, this.reference));
|
||||
await pingMessage.edit(`🏓 Pong!\n\`\`\`\nLatency: ${pingMessage.timestamp - this.message.timestamp}ms${this.channel.guild ? `\nShard Latency: ${Math.round(this.client.shards.get(this.client.guildShardMap[this.channel.guild.id]).latency)}ms` : ""}\n\`\`\``);
|
||||
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("🏓 Ping?");
|
||||
const pingMessage = await this.interaction.getOriginalMessage();
|
||||
await this.interaction.editOriginalMessage(`🏓 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\`\`\``);
|
||||
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\`\`\``
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,15 @@ import Command from "../../classes/command.js";
|
|||
|
||||
class PrefixCommand extends Command {
|
||||
async run() {
|
||||
if (!this.channel.guild) return `The current prefix is \`${process.env.PREFIX}\``;
|
||||
const guild = await database.getGuild(this.channel.guild.id);
|
||||
if (!this.guild) return `The current prefix is \`${process.env.PREFIX}\`.`;
|
||||
const guild = await database.getGuild(this.guild.id);
|
||||
if (this.args.length !== 0) {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!this.member.permissions.has("administrator") && !owners.includes(this.member.id)) {
|
||||
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.channel.guild);
|
||||
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}\`.`;
|
||||
|
|
|
@ -13,7 +13,7 @@ class QrCreateCommand extends Command {
|
|||
qrcode.toFileStream(writable, this.content, { margin: 1 });
|
||||
const file = await this.streamToBuf(writable);
|
||||
return {
|
||||
file: file,
|
||||
contents: file,
|
||||
name: "qr.png"
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class RestartCommand extends Command {
|
|||
this.success = false;
|
||||
return "Only the bot owner can restart me!";
|
||||
}
|
||||
await this.client.createMessage(this.channel.id, Object.assign({
|
||||
await this.message.channel.createMessage(Object.assign({
|
||||
content: "esmBot is restarting."
|
||||
}, this.reference));
|
||||
process.exit(1);
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
import Command from "../../classes/command.js";
|
||||
|
||||
class ServerInfoCommand extends Command {
|
||||
async run() {
|
||||
if (!this.channel.guild) {
|
||||
this.success = false;
|
||||
return "This command only works in servers!";
|
||||
}
|
||||
const owner = await this.channel.guild.members.get(this.channel.guild.ownerID);
|
||||
return {
|
||||
embeds: [{
|
||||
title: this.channel.guild.name,
|
||||
thumbnail: {
|
||||
url: this.channel.guild.iconURL
|
||||
},
|
||||
image: {
|
||||
url: this.channel.guild.bannerURL
|
||||
},
|
||||
color: 16711680,
|
||||
fields: [
|
||||
{
|
||||
name: "🔢 **ID:**",
|
||||
value: this.channel.guild.id
|
||||
},
|
||||
{
|
||||
name: "👤 **Owner:**",
|
||||
value: owner ? `${owner.user.username}#${owner.user.discriminator}` : this.channel.guild.ownerID
|
||||
},
|
||||
{
|
||||
name: "🗓 **Created on:**",
|
||||
value: `<t:${Math.floor(this.channel.guild.createdAt / 1000)}:F>`
|
||||
},
|
||||
{
|
||||
name: "👥 **Users:**",
|
||||
value: this.channel.guild.memberCount,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "💬 **Channels:**",
|
||||
value: this.channel.guild.channels.size,
|
||||
inline: true
|
||||
},
|
||||
{
|
||||
name: "😃 **Emojis:**",
|
||||
value: this.channel.guild.emojis.length,
|
||||
inline: true
|
||||
}
|
||||
]
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
static description = "Gets some info about the server";
|
||||
static aliases = ["server"];
|
||||
static directAllowed = false;
|
||||
}
|
||||
|
||||
export default ServerInfoCommand;
|
|
@ -2,7 +2,7 @@ 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 "eris";
|
||||
import { VERSION } from "oceanic.js";
|
||||
import pm2 from "pm2";
|
||||
import { getServers } from "../../utils/misc.js";
|
||||
|
||||
|
@ -10,14 +10,15 @@ class StatsCommand extends Command {
|
|||
async run() {
|
||||
const uptime = process.uptime() * 1000;
|
||||
const connUptime = this.client.uptime;
|
||||
const owner = await this.client.getRESTUser(process.env.OWNER.split(",")[0]);
|
||||
let owner = this.client.users.get(process.env.OWNER.split(",")[0]);
|
||||
if (!owner) owner = await this.client.getRESTUser(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",
|
||||
"icon_url": this.client.user.avatarURL
|
||||
"iconURL": this.client.user.avatarURL()
|
||||
},
|
||||
"description": `This instance is managed by **${owner.username}#${owner.discriminator}**.`,
|
||||
"color": 16711680,
|
||||
|
@ -50,7 +51,7 @@ class StatsCommand extends Command {
|
|||
},
|
||||
{
|
||||
"name": "Library",
|
||||
"value": `Eris ${VERSION}`,
|
||||
"value": `Oceanic ${VERSION}`,
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
|
@ -60,7 +61,7 @@ class StatsCommand extends Command {
|
|||
},
|
||||
{
|
||||
"name": "Shard",
|
||||
"value": this.channel.guild ? this.client.guildShardMap[this.channel.guild.id] : "N/A",
|
||||
"value": this.guild ? this.client.guildShardMap[this.guild.id] : "N/A",
|
||||
"inline": true
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
import Command from "../../classes/command.js";
|
||||
|
||||
class UserInfoCommand extends Command {
|
||||
async run() {
|
||||
const getUser = this.message.mentions.length >= 1 ? this.message.mentions[0] : (this.args.length !== 0 ? this.client.users.get(this.args[0]) : this.author);
|
||||
let user;
|
||||
if (getUser) {
|
||||
user = getUser;
|
||||
} else if (this.args[0].match(/^<?[@#]?[&!]?\d+>?$/) && this.args[0] >= 21154535154122752n) {
|
||||
try {
|
||||
user = await this.client.getRESTUser(this.args[0]);
|
||||
} catch {
|
||||
user = this.author;
|
||||
}
|
||||
} else if (this.args.join(" ") !== "") {
|
||||
const userRegex = new RegExp(this.args.join("|"), "i");
|
||||
const member = this.client.users.find(element => {
|
||||
return userRegex.test(element.username);
|
||||
});
|
||||
user = member ?? this.author;
|
||||
} else {
|
||||
user = this.author;
|
||||
}
|
||||
const member = this.channel.guild ? this.channel.guild.members.get(user.id) : undefined;
|
||||
return {
|
||||
embeds: [{
|
||||
title: `${user.username}#${user.discriminator}`,
|
||||
thumbnail: {
|
||||
url: user.avatarURL
|
||||
},
|
||||
color: 16711680,
|
||||
fields: [
|
||||
{
|
||||
name: "🔢 **ID:**",
|
||||
value: user.id
|
||||
},
|
||||
{
|
||||
name: "📛 **Nickname:**",
|
||||
value: member ? (member.nick ?? "None") : "N/A"
|
||||
},
|
||||
{
|
||||
name: "🤖 **Bot:**",
|
||||
value: user.bot ? "Yes" : "No"
|
||||
},
|
||||
{
|
||||
name: "🗓️ **Joined Discord on:**",
|
||||
value: `<t:${Math.floor(user.createdAt / 1000)}:F>`
|
||||
},
|
||||
{
|
||||
name: "💬 **Joined this server on:**",
|
||||
value: member ? `<t:${Math.floor(member.joinedAt / 1000)}:F>` : "N/A"
|
||||
}
|
||||
]
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
static description = "Gets info about a user";
|
||||
static aliases = ["user"];
|
||||
static arguments = ["[mention/id]"];
|
||||
static slashAllowed = false;
|
||||
}
|
||||
|
||||
export default UserInfoCommand;
|
Loading…
Add table
Add a link
Reference in a new issue