Initial Oceanic port (still unfinished), update packages, remove serverinfo and userinfo

This commit is contained in:
Essem 2022-09-23 22:25:16 -05:00
parent bf90ae108a
commit 888f2f8b4a
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
49 changed files with 573 additions and 515 deletions

View file

@ -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);

View file

@ -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!");

View file

@ -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;

View file

@ -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.`;
}

View file

@ -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()
}
}]
});

View file

@ -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);
}
}

View file

@ -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()
}
}]
});

View file

@ -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).`,

View file

@ -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: [{

View file

@ -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\`\`\``
});
}
}

View file

@ -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}\`.`;

View file

@ -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"
};
}

View file

@ -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);

View file

@ -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;

View file

@ -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
},
{

View file

@ -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;

View file

@ -4,9 +4,9 @@ import MusicCommand from "../../classes/musicCommand.js";
class HostCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.author.id && !process.env.OWNER.split(",").includes(this.connection.host)) return "Only the current voice session host can choose another host!";
const input = this.options.user ?? this.args.join(" ");
if (input?.trim()) {
@ -33,15 +33,15 @@ class HostCommand extends MusicCommand {
}
if (!user) return "I can't find that user!";
if (user.bot) return "This is illegal, you know.";
const member = this.channel.guild ? this.channel.guild.members.get(user.id) : undefined;
const member = this.guild ? this.guild.members.get(user.id) : undefined;
if (!member) return "That user isn't in this server!";
const object = this.connection;
object.host = member.id;
players.set(this.channel.guild.id, object);
players.set(this.guildID, object);
this.success = true;
return `🔊 ${member.mention} is the new voice channel host.`;
} else {
const member = this.channel.guild ? this.channel.guild.members.get(players.get(this.channel.guild.id).host) : undefined;
const member = this.guild ? this.guild.members.get(players.get(this.guild.id).host) : undefined;
this.success = true;
return `🔊 The current voice channel host is **${member?.username}#${member?.discriminator}**.`;
}

View file

@ -4,13 +4,13 @@ import MusicCommand from "../../classes/musicCommand.js";
class LoopCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.author.id && !this.member.permissions.has("manageChannels")) return "Only the current voice session host can loop the music!";
const object = this.connection;
object.loop = !object.loop;
players.set(this.channel.guild.id, object);
players.set(this.guild.id, object);
this.success = true;
return object.loop ? "🔊 The player is now looping." : "🔊 The player is no longer looping.";
}

View file

@ -4,9 +4,9 @@ import MusicCommand from "../../classes/musicCommand.js";
class NowPlayingCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
const player = this.connection.player;
if (!player) return "I'm not playing anything!";
const track = await player.node.rest.decode(player.track);
@ -17,7 +17,7 @@ class NowPlayingCommand extends MusicCommand {
color: 16711680,
author: {
name: "Now Playing",
icon_url: this.client.user.avatarURL
iconURL: this.client.user.avatarURL
},
fields: [{
name: " Title",
@ -29,7 +29,7 @@ class NowPlayingCommand extends MusicCommand {
},
{
name: "💬 Channel",
value: this.channel.guild.channels.get(this.member.voiceState.channelID).name
value: this.guild.channels.get(this.member.voiceState.channelID).name
},
{
name: "🌐 Node",

View file

@ -7,9 +7,9 @@ import MusicCommand from "../../classes/musicCommand.js";
class QueueCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
const player = this.connection;
const node = nodes.filter((val) => val.name === player.player.node.name)[0];
@ -30,7 +30,7 @@ class QueueCommand extends MusicCommand {
embeds: [{
author: {
name: "Queue",
icon_url: this.client.user.avatarURL
iconURL: this.client.user.avatarURL
},
color: 16711680,
footer: {

View file

@ -4,16 +4,16 @@ import MusicCommand from "../../classes/musicCommand.js";
class RemoveCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.author.id && !process.env.OWNER.split(",").includes(this.connection.host)) return "Only the current voice session host can remove songs from the queue!";
const pos = parseInt(this.options.position ?? this.args[0]);
if (isNaN(pos) || pos > this.queue.length || pos < 1) return "That's not a valid position!";
const removed = this.queue.splice(pos, 1);
if (removed.length === 0) return "That's not a valid position!";
const track = await this.connection.player.node.rest.decode(removed[0]);
queues.set(this.channel.guild.id, this.queue);
queues.set(this.guildID, this.queue);
this.success = true;
return `🔊 The song \`${track.title ? track.title : "(blank)"}\` has been removed from the queue.`;
}

View file

@ -3,9 +3,9 @@ import MusicCommand from "../../classes/musicCommand.js";
class SeekCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.author.id) return "Only the current voice session host can seek the music!";
const player = this.connection.player;
const track = await player.node.rest.decode(player.track);

View file

@ -4,13 +4,13 @@ import MusicCommand from "../../classes/musicCommand.js";
class ShuffleCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.author.id) return "Only the current voice session host can shuffle the music!";
const object = this.connection;
object.shuffle = !object.shuffle;
players.set(this.channel.guild.id, object);
players.set(this.guildID, object);
this.success = true;
return object.shuffle ? "🔊 The player is now shuffling." : "🔊 The player is no longer shuffling.";
}

View file

@ -4,12 +4,12 @@ import MusicCommand from "../../classes/musicCommand.js";
class SkipCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
const player = this.connection;
if (player.host !== this.author.id && !this.member.permissions.has("manageChannels")) {
const votes = skipVotes.get(this.channel.guild.id) ?? { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.filter((i) => i.id !== this.client.user.id && !i.bot).length) };
const votes = skipVotes.get(this.guild.id) ?? { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.filter((i) => i.id !== this.client.user.id && !i.bot).length) };
if (votes.ids.includes(this.author.id)) return "You've already voted to skip!";
const newObject = {
count: votes.count + 1,
@ -17,12 +17,12 @@ class SkipCommand extends MusicCommand {
max: votes.max
};
if (votes.count + 1 === votes.max) {
await player.player.stopTrack(this.channel.guild.id);
skipVotes.set(this.channel.guild.id, { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.filter((i) => i.id !== this.client.user.id && !i.bot).length) });
await player.player.stopTrack(this.guild.id);
skipVotes.set(this.guild.id, { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.filter((i) => i.id !== this.client.user.id && !i.bot).length) });
this.success = true;
if (this.type === "application") return "🔊 The current song has been skipped.";
} else {
skipVotes.set(this.channel.guild.id, newObject);
skipVotes.set(this.guild.id, newObject);
this.success = true;
return `🔊 Voted to skip song (${votes.count + 1}/${votes.max} people have voted).`;
}

View file

@ -4,19 +4,19 @@ import MusicCommand from "../../classes/musicCommand.js";
class StopCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.connection) {
await manager.getNode().leaveChannel(this.channel.guild.id);
await manager.getNode().leaveChannel(this.guild.id);
this.success = true;
return "🔊 The current voice channel session has ended.";
}
if (this.connection.host !== this.author.id && !this.member.permissions.has("manageChannels")) return "Only the current voice session host can stop the music!";
const connection = this.connection.player;
connection.node.leaveChannel(this.channel.guild.id);
players.delete(this.channel.guild.id);
queues.delete(this.channel.guild.id);
connection.node.leaveChannel(this.guild.id);
players.delete(this.guild.id);
queues.delete(this.guild.id);
this.success = true;
return `🔊 The voice channel session in \`${this.connection.voiceChannel.name}\` has ended.`;
}

View file

@ -3,9 +3,9 @@ import MusicCommand from "../../classes/musicCommand.js";
class ToggleCommand extends MusicCommand {
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!";
if (!this.member.voiceState.channelID) return "You need to be in a voice channel first!";
if (!this.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (this.connection.host !== this.author.id && !this.member.permissions.has("manageChannels")) return "Only the current voice session host can pause/resume the music!";
const player = this.connection.player;
player.setPaused(!player.paused ? true : false);

View file

@ -8,7 +8,7 @@ class TagsCommand extends Command {
// todo: attempt to not make this file the worst thing that human eyes have ever seen
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 cmd = this.type === "classic" ? (this.args[0] ?? "").toLowerCase() : this.optionsArray[0].name;
if (!cmd || !cmd.trim()) return "You need to provide the name of the tag you want to view!";
const tagName = this.type === "classic" ? this.args.slice(1)[0] : (this.optionsArray[0].options[0] ?? {}).value;
@ -16,33 +16,33 @@ class TagsCommand extends Command {
if (cmd === "create" || cmd === "add") {
if (!tagName || !tagName.trim()) return "You need to provide the name of the tag you want to add!";
if (blacklist.includes(tagName)) return "You can't make a tag with that name!";
const getResult = await database.getTag(this.channel.guild.id, tagName);
const getResult = await database.getTag(this.guild.id, tagName);
if (getResult) return "This tag already exists!";
const result = await database.setTag(tagName, { content: this.type === "classic" ? this.args.slice(2).join(" ") : this.optionsArray[0].options[1].value, author: this.member.id }, this.channel.guild);
const result = await database.setTag(tagName, { content: this.type === "classic" ? this.args.slice(2).join(" ") : this.optionsArray[0].options[1].value, author: this.member.id }, this.guild);
this.success = true;
if (result) return result;
return `The tag \`${tagName}\` has been added!`;
} else if (cmd === "delete" || cmd === "remove") {
if (!tagName || !tagName.trim()) return "You need to provide the name of the tag you want to delete!";
const getResult = await database.getTag(this.channel.guild.id, tagName);
const getResult = await database.getTag(this.guild.id, tagName);
if (!getResult) return "This tag doesn't exist!";
const owners = process.env.OWNER.split(",");
if (getResult.author !== this.author.id && !this.member.permissions.has("manageMessages") && !owners.includes(this.author.id)) return "You don't own this tag!";
await database.removeTag(tagName, this.channel.guild);
await database.removeTag(tagName, this.guild);
this.success = true;
return `The tag \`${tagName}\` has been deleted!`;
} else if (cmd === "edit") {
if (!tagName || !tagName.trim()) return "You need to provide the name of the tag you want to edit!";
const getResult = await database.getTag(this.channel.guild.id, tagName);
const getResult = await database.getTag(this.guild.id, tagName);
if (!getResult) return "This tag doesn't exist!";
const owners = process.env.OWNER.split(",");
if (getResult.author !== this.author.id && !this.member.permissions.has("manageMessages") && !owners.includes(this.author.id)) return "You don't own this tag!";
await database.editTag(tagName, { content: this.type === "classic" ? this.args.slice(2).join(" ") : this.optionsArray[0].options[1].value, author: this.member.id }, this.channel.guild);
await database.editTag(tagName, { content: this.type === "classic" ? this.args.slice(2).join(" ") : this.optionsArray[0].options[1].value, author: this.member.id }, this.guild);
this.success = true;
return `The tag \`${tagName}\` has been edited!`;
} else if (cmd === "own" || cmd === "owner") {
if (!tagName || !tagName.trim()) return "You need to provide the name of the tag you want to check the owner of!";
const getResult = await database.getTag(this.channel.guild.id, tagName);
const getResult = await database.getTag(this.guild.id, tagName);
if (!getResult) return "This tag doesn't exist!";
const user = this.client.users.get(getResult.author);
this.success = true;
@ -58,7 +58,7 @@ class TagsCommand extends Command {
}
} else if (cmd === "list") {
if (!this.channel.permissionsOf(this.client.user.id).has("embedLinks")) return "I don't have the `Embed Links` permission!";
const tagList = await database.getTags(this.channel.guild.id);
const tagList = await database.getTags(this.guild.id);
const embeds = [];
const groups = Object.keys(tagList).map((item, index) => {
return index % 15 === 0 ? Object.keys(tagList).slice(index, index + 15) : null;
@ -76,7 +76,7 @@ class TagsCommand extends Command {
description: value.join("\n"),
author: {
name: this.author.username,
icon_url: this.author.avatarURL
iconURL: this.author.avatarURL
}
}]
});
@ -87,10 +87,10 @@ class TagsCommand extends Command {
} else {
let getResult;
if (cmd === "random") {
const tagList = await database.getTags(this.channel.guild.id);
const tagList = await database.getTags(this.guild.id);
getResult = tagList[random(Object.keys(tagList))];
} else {
getResult = await database.getTag(this.channel.guild.id, this.type === "classic" ? cmd : tagName);
getResult = await database.getTag(this.guild.id, this.type === "classic" ? cmd : tagName);
}
if (!getResult) return "This tag doesn't exist!";
this.success = true;