fix owner checks
This commit is contained in:
parent
db9b70bf66
commit
c841b53bdd
18 changed files with 23 additions and 23 deletions
|
@ -4,7 +4,7 @@ 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);
|
||||
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]) {
|
||||
return this.message.mentions.users[0].avatarURL(null, 512);
|
||||
} else if (member && member > 21154535154122752n) {
|
||||
|
|
|
@ -6,7 +6,7 @@ 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
|
||||
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) {
|
||||
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) {
|
||||
|
|
|
@ -5,7 +5,7 @@ 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)) {
|
||||
if (!owners.includes(this.author)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can broadcast messages!";
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import Command from "../../classes/command.js";
|
|||
class EvalCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
if (!owners.includes(this.author)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can use eval!";
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import Command from "../../classes/command.js";
|
|||
class ExecCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
if (!owners.includes(this.author)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can use exec!";
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class ExecCommand extends Command {
|
|||
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\`\`\``;
|
||||
if (execed.stderr) return `\`\`\`xl\n${await clean(execed.stderr)}\n\`\`\``;
|
||||
const cleaned = await clean(execed.stdout);
|
||||
const sendString = `\`\`\`bash\n${cleaned}\n\`\`\``;
|
||||
if (sendString.length >= 2000) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { reloadImageConnections } from "../../utils/image.js";
|
|||
class ImageReloadCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
if (!owners.includes(this.author)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can reload the image servers!";
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@ import Command from "../../classes/command.js";
|
|||
class RestartCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
if (!owners.includes(this.author)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can restart me!";
|
||||
}
|
||||
await this.channel.createMessage(Object.assign({
|
||||
content: "esmBot is restarting."
|
||||
content: "mrmBot is restarting."
|
||||
}, this.reference));
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import { reload } from "../../utils/soundplayer.js";
|
|||
class SoundReloadCommand extends Command {
|
||||
async run() {
|
||||
const owners = process.env.OWNER.split(",");
|
||||
if (!owners.includes(this.author.id)) {
|
||||
if (!owners.includes(this.author)) {
|
||||
this.success = false;
|
||||
return "Only the bot owner can reload Lavalink!";
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class SelectImageCommand extends Command {
|
|||
} else if (image.type === "tenorlimit") {
|
||||
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.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ class HostCommand extends MusicCommand {
|
|||
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.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(" ");
|
||||
if (input?.trim()) {
|
||||
let user;
|
||||
|
|
|
@ -8,7 +8,7 @@ class LoopCommand extends MusicCommand {
|
|||
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.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;
|
||||
object.loop = !object.loop;
|
||||
players.set(this.guild.id, object);
|
||||
|
|
|
@ -8,7 +8,7 @@ class RemoveCommand extends MusicCommand {
|
|||
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.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]);
|
||||
if (isNaN(pos) || pos > this.queue.length || pos < 1) return "That's not a valid position!";
|
||||
const removed = this.queue.splice(pos, 1);
|
||||
|
|
|
@ -7,7 +7,7 @@ class SeekCommand extends MusicCommand {
|
|||
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.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 track = await player.node.rest.decode(player.track);
|
||||
if (!track.isSeekable) return "This track isn't seekable!";
|
||||
|
|
|
@ -8,7 +8,7 @@ class ShuffleCommand extends MusicCommand {
|
|||
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.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;
|
||||
object.shuffle = !object.shuffle;
|
||||
players.set(this.guildID, object);
|
||||
|
|
|
@ -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!";
|
||||
const player = this.connection;
|
||||
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) };
|
||||
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 = {
|
||||
count: votes.count + 1,
|
||||
ids: [...votes.ids, this.author.id].filter(item => !!item),
|
||||
ids: [...votes.ids, this.author].filter(item => !!item),
|
||||
max: votes.max
|
||||
};
|
||||
if (votes.count + 1 === votes.max) {
|
||||
|
|
|
@ -12,7 +12,7 @@ class StopCommand extends MusicCommand {
|
|||
this.success = true;
|
||||
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;
|
||||
connection.node.leaveChannel(this.guild.id);
|
||||
players.delete(this.guild.id);
|
||||
|
|
|
@ -7,7 +7,7 @@ class ToggleCommand extends MusicCommand {
|
|||
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.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;
|
||||
player.setPaused(!player.paused ? true : false);
|
||||
this.success = true;
|
||||
|
|
|
@ -27,7 +27,7 @@ class TagsCommand extends Command {
|
|||
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("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);
|
||||
this.success = true;
|
||||
return `The tag \`${tagName}\` has been deleted!`;
|
||||
|
@ -36,7 +36,7 @@ class TagsCommand extends Command {
|
|||
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("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);
|
||||
this.success = true;
|
||||
return `The tag \`${tagName}\` has been edited!`;
|
||||
|
|
Loading…
Reference in a new issue