fix owner checks

This commit is contained in:
murm 2023-03-15 10:12:35 -04:00
parent db9b70bf66
commit c841b53bdd
18 changed files with 23 additions and 23 deletions

View File

@ -4,7 +4,7 @@ const mentionRegex = /^<?[@#]?[&!]?(\d+)>?$/;
class AvatarCommand extends Command { class AvatarCommand extends Command {
async run() { async run() {
const member = this.options.member ?? this.args[0]; 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); const self = this.client.users.get(this.author) ?? await this.client.rest.users.get(this.author);
if (this.type === "classic" && this.message.mentions.users[0]) { if (this.type === "classic" && this.message.mentions.users[0]) {
return this.message.mentions.users[0].avatarURL(null, 512); return this.message.mentions.users[0].avatarURL(null, 512);
} else if (member && member > 21154535154122752n) { } else if (member && member > 21154535154122752n) {

View File

@ -6,7 +6,7 @@ class BannerCommand extends Command {
// this command sucks // this command sucks
async run() { async run() {
const member = this.options.member ?? this.args[0]; 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 const self = await this.client.rest.users.get(this.author); // banners are only available over REST
if (this.type === "classic" && this.message.mentions.users[0] && this.message.mentions.users[0].banner) { 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); 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) { } else if (member && member > 21154535154122752n) {

View File

@ -5,7 +5,7 @@ import { endBroadcast, startBroadcast } from "../../utils/misc.js";
class BroadcastCommand extends Command { class BroadcastCommand extends Command {
async run() { async run() {
const owners = process.env.OWNER.split(","); const owners = process.env.OWNER.split(",");
if (!owners.includes(this.author.id)) { if (!owners.includes(this.author)) {
this.success = false; this.success = false;
return "Only the bot owner can broadcast messages!"; return "Only the bot owner can broadcast messages!";
} }

View File

@ -4,7 +4,7 @@ import Command from "../../classes/command.js";
class EvalCommand extends Command { class EvalCommand extends Command {
async run() { async run() {
const owners = process.env.OWNER.split(","); const owners = process.env.OWNER.split(",");
if (!owners.includes(this.author.id)) { if (!owners.includes(this.author)) {
this.success = false; this.success = false;
return "Only the bot owner can use eval!"; return "Only the bot owner can use eval!";
} }

View File

@ -7,7 +7,7 @@ import Command from "../../classes/command.js";
class ExecCommand extends Command { class ExecCommand extends Command {
async run() { async run() {
const owners = process.env.OWNER.split(","); const owners = process.env.OWNER.split(",");
if (!owners.includes(this.author.id)) { if (!owners.includes(this.author)) {
this.success = false; this.success = false;
return "Only the bot owner can use exec!"; return "Only the bot owner can use exec!";
} }
@ -15,7 +15,7 @@ class ExecCommand extends Command {
const code = this.options.cmd ?? this.args.join(" "); const code = this.options.cmd ?? this.args.join(" ");
try { try {
const execed = await exec(code); const execed = await exec(code);
if (execed.stderr) return `\`ERROR\` \`\`\`xl\n${await clean(execed.stderr)}\n\`\`\``; if (execed.stderr) return `\`\`\`xl\n${await clean(execed.stderr)}\n\`\`\``;
const cleaned = await clean(execed.stdout); const cleaned = await clean(execed.stdout);
const sendString = `\`\`\`bash\n${cleaned}\n\`\`\``; const sendString = `\`\`\`bash\n${cleaned}\n\`\`\``;
if (sendString.length >= 2000) { if (sendString.length >= 2000) {

View File

@ -4,7 +4,7 @@ import { reloadImageConnections } from "../../utils/image.js";
class ImageReloadCommand extends Command { class ImageReloadCommand extends Command {
async run() { async run() {
const owners = process.env.OWNER.split(","); const owners = process.env.OWNER.split(",");
if (!owners.includes(this.author.id)) { if (!owners.includes(this.author)) {
this.success = false; this.success = false;
return "Only the bot owner can reload the image servers!"; return "Only the bot owner can reload the image servers!";
} }

View File

@ -3,12 +3,12 @@ import Command from "../../classes/command.js";
class RestartCommand extends Command { class RestartCommand extends Command {
async run() { async run() {
const owners = process.env.OWNER.split(","); const owners = process.env.OWNER.split(",");
if (!owners.includes(this.author.id)) { if (!owners.includes(this.author)) {
this.success = false; this.success = false;
return "Only the bot owner can restart me!"; return "Only the bot owner can restart me!";
} }
await this.channel.createMessage(Object.assign({ await this.channel.createMessage(Object.assign({
content: "esmBot is restarting." content: "mrmBot is restarting."
}, this.reference)); }, this.reference));
process.exit(1); process.exit(1);
} }

View File

@ -4,7 +4,7 @@ import { reload } from "../../utils/soundplayer.js";
class SoundReloadCommand extends Command { class SoundReloadCommand extends Command {
async run() { async run() {
const owners = process.env.OWNER.split(","); const owners = process.env.OWNER.split(",");
if (!owners.includes(this.author.id)) { if (!owners.includes(this.author)) {
this.success = false; this.success = false;
return "Only the bot owner can reload Lavalink!"; return "Only the bot owner can reload Lavalink!";
} }

View File

@ -15,7 +15,7 @@ class SelectImageCommand extends Command {
} else if (image.type === "tenorlimit") { } else if (image.type === "tenorlimit") {
return "I've been rate-limited by Tenor. Please try uploading your GIF elsewhere."; return "I've been rate-limited by Tenor. Please try uploading your GIF elsewhere.";
} }
selectedImages.set(this.author.id, image); selectedImages.set(this.author, image);
return "The image has been selected for your next command."; return "The image has been selected for your next command.";
} }
} }

View File

@ -8,7 +8,7 @@ class HostCommand extends MusicCommand {
if (!this.member.voiceState) return "You need to be in a voice channel first!"; if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!"; if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!"; if (!this.connection) return "I haven't completely connected yet!";
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!"; if (this.connection.host !== this.author && !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(" "); const input = this.options.user ?? this.args.join(" ");
if (input?.trim()) { if (input?.trim()) {
let user; let user;

View File

@ -8,7 +8,7 @@ class LoopCommand extends MusicCommand {
if (!this.member.voiceState) return "You need to be in a voice channel first!"; if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!"; if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!"; if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id && !this.member.permissions.has("MANAGE_CHANNELS")) return "Only the current voice session host can loop the music!"; if (this.connection.host !== this.author && !this.member.permissions.has("MANAGE_CHANNELS")) return "Only the current voice session host can loop the music!";
const object = this.connection; const object = this.connection;
object.loop = !object.loop; object.loop = !object.loop;
players.set(this.guild.id, object); players.set(this.guild.id, object);

View File

@ -8,7 +8,7 @@ class RemoveCommand extends MusicCommand {
if (!this.member.voiceState) return "You need to be in a voice channel first!"; if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!"; if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!"; if (!this.connection) return "I haven't completely connected yet!";
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!"; if (this.connection.host !== this.author && !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]); 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!"; if (isNaN(pos) || pos > this.queue.length || pos < 1) return "That's not a valid position!";
const removed = this.queue.splice(pos, 1); const removed = this.queue.splice(pos, 1);

View File

@ -7,7 +7,7 @@ class SeekCommand extends MusicCommand {
if (!this.member.voiceState) return "You need to be in a voice channel first!"; if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!"; if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!"; if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id) return "Only the current voice session host can seek the music!"; if (this.connection.host !== this.author) return "Only the current voice session host can seek the music!";
const player = this.connection.player; const player = this.connection.player;
const track = await player.node.rest.decode(player.track); const track = await player.node.rest.decode(player.track);
if (!track.isSeekable) return "This track isn't seekable!"; if (!track.isSeekable) return "This track isn't seekable!";

View File

@ -8,7 +8,7 @@ class ShuffleCommand extends MusicCommand {
if (!this.member.voiceState) return "You need to be in a voice channel first!"; if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!"; if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!"; if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id) return "Only the current voice session host can shuffle the music!"; if (this.connection.host !== this.author) return "Only the current voice session host can shuffle the music!";
const object = this.connection; const object = this.connection;
object.shuffle = !object.shuffle; object.shuffle = !object.shuffle;
players.set(this.guildID, object); players.set(this.guildID, object);

View File

@ -9,12 +9,12 @@ class SkipCommand extends MusicCommand {
if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!"; if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!";
const player = this.connection; const player = this.connection;
if (!player) return "I haven't completely connected yet!"; if (!player) return "I haven't completely connected yet!";
if (player.host !== this.author.id && !this.member.permissions.has("MANAGE_CHANNELS")) { if (player.host !== this.author && !this.member.permissions.has("MANAGE_CHANNELS")) {
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) }; 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!"; if (votes.ids.includes(this.author)) return "You've already voted to skip!";
const newObject = { const newObject = {
count: votes.count + 1, count: votes.count + 1,
ids: [...votes.ids, this.author.id].filter(item => !!item), ids: [...votes.ids, this.author].filter(item => !!item),
max: votes.max max: votes.max
}; };
if (votes.count + 1 === votes.max) { if (votes.count + 1 === votes.max) {

View File

@ -12,7 +12,7 @@ class StopCommand extends MusicCommand {
this.success = true; this.success = true;
return "🔊 The current voice channel session has ended."; return "🔊 The current voice channel session has ended.";
} }
if (this.connection.host !== this.author.id && !this.member.permissions.has("MANAGE_CHANNELS")) return "Only the current voice session host can stop the music!"; if (this.connection.host !== this.author && !this.member.permissions.has("MANAGE_CHANNELS")) return "Only the current voice session host can stop the music!";
const connection = this.connection.player; const connection = this.connection.player;
connection.node.leaveChannel(this.guild.id); connection.node.leaveChannel(this.guild.id);
players.delete(this.guild.id); players.delete(this.guild.id);

View File

@ -7,7 +7,7 @@ class ToggleCommand extends MusicCommand {
if (!this.member.voiceState) return "You need to be in a voice channel first!"; if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!"; if (!this.guild.voiceStates.has(this.client.user.id)) return "I'm not in a voice channel!";
if (!this.connection) return "I haven't completely connected yet!"; if (!this.connection) return "I haven't completely connected yet!";
if (this.connection.host !== this.author.id && !this.member.permissions.has("MANAGE_CHANNELS")) return "Only the current voice session host can pause/resume the music!"; if (this.connection.host !== this.author && !this.member.permissions.has("MANAGE_CHANNELS")) return "Only the current voice session host can pause/resume the music!";
const player = this.connection.player; const player = this.connection.player;
player.setPaused(!player.paused ? true : false); player.setPaused(!player.paused ? true : false);
this.success = true; this.success = true;

View File

@ -27,7 +27,7 @@ class TagsCommand extends Command {
const getResult = await database.getTag(this.guild.id, tagName); const getResult = await database.getTag(this.guild.id, tagName);
if (!getResult) return "This tag doesn't exist!"; if (!getResult) return "This tag doesn't exist!";
const owners = process.env.OWNER.split(","); const owners = process.env.OWNER.split(",");
if (getResult.author !== this.author.id && !this.member.permissions.has("MANAGE_MESSAGES") && !owners.includes(this.author.id)) return "You don't own this tag!"; if (getResult.author !== this.author && !this.member.permissions.has("MANAGE_MESSAGES") && !owners.includes(this.author)) return "You don't own this tag!";
await database.removeTag(tagName, this.guild); await database.removeTag(tagName, this.guild);
this.success = true; this.success = true;
return `The tag \`${tagName}\` has been deleted!`; return `The tag \`${tagName}\` has been deleted!`;
@ -36,7 +36,7 @@ class TagsCommand extends Command {
const getResult = await database.getTag(this.guild.id, tagName); const getResult = await database.getTag(this.guild.id, tagName);
if (!getResult) return "This tag doesn't exist!"; if (!getResult) return "This tag doesn't exist!";
const owners = process.env.OWNER.split(","); const owners = process.env.OWNER.split(",");
if (getResult.author !== this.author.id && !this.member.permissions.has("MANAGE_MESSAGES") && !owners.includes(this.author.id)) return "You don't own this tag!"; if (getResult.author !== this.author && !this.member.permissions.has("MANAGE_MESSAGES") && !owners.includes(this.author)) 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.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; this.success = true;
return `The tag \`${tagName}\` has been edited!`; return `The tag \`${tagName}\` has been edited!`;