Fixes for thread channels, voice commands, image handling, and snowflake, update packages

This commit is contained in:
Essem 2022-09-27 14:46:07 -05:00
parent 238f44967b
commit c70f86607f
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
18 changed files with 130 additions and 119 deletions

View file

@ -5,8 +5,10 @@ class SnowflakeCommand extends Command {
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:${Math.floor(((this.args[0].replaceAll("@", "").replaceAll("#", "").replaceAll("!", "").replaceAll("&", "").replaceAll("<", "").replaceAll(">", "") / 4194304) + 1420070400000) / 1000)}:F>`;
return `<t:${id}:F>`;
}
static description = "Converts a Discord snowflake id into a timestamp";

View file

@ -5,14 +5,14 @@ class HostCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) 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()) {
let user;
if (this.type === "classic") {
const getUser = this.message.mentions.length >= 1 ? this.message.mentions[0] : this.client.users.get(input);
const getUser = this.message.mentions.users.length >= 1 ? this.message.mentions.users[0] : this.client.users.get(input);
if (getUser) {
user = getUser;
} else if (input.match(/^<?[@#]?[&!]?\d+>?$/) && input >= 21154535154122752n) {

View file

@ -5,8 +5,8 @@ class LoopCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (this.connection.host !== this.author.id && !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;

View file

@ -5,8 +5,8 @@ class NowPlayingCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) 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);

View file

@ -8,8 +8,8 @@ class QueueCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.channel.permissionsOf(this.client.user.id.toString()).has("EMBED_LINKS")) 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];

View file

@ -5,8 +5,8 @@ class RemoveCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) 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!";

View file

@ -4,8 +4,8 @@ class SeekCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) 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

@ -5,8 +5,8 @@ class ShuffleCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) 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;

View file

@ -5,8 +5,8 @@ class SkipCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
const player = this.connection;
if (player.host !== this.author.id && !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) };

View file

@ -5,8 +5,8 @@ class StopCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
if (!this.connection) {
await manager.getNode().leaveChannel(this.guild.id);
this.success = true;

View file

@ -4,8 +4,8 @@ class ToggleCommand extends MusicCommand {
async run() {
this.success = false;
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.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
if (!this.member.voiceState) return "You need to be in a voice channel first!";
if (!this.guild.members.get(this.client.user.id).voiceState) return "I'm not in a voice channel!";
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!";
const player = this.connection.player;
player.setPaused(!player.paused ? true : false);

View file

@ -11,6 +11,7 @@ class SoundboardAIOCommand extends Command {
return "You need to provide a sound to play!";
}
const name = sounds.get(soundName);
await this.acknowledge();
return await play(this.client, name, { channel: this.channel, member: this.member, type: this.type, interaction: this.interaction });
}