Allow player.destroy() to take a boolean as parameter

Hello, I would love to have the option to call something like this: player.destroy(false) and have the player destroyed, but the bot does not disconnect from the voice channel.. To achieve that I modified the destroy() method in the "MoonlinkPlayers.ts" file to this exact one here:
public async destroy(disconnect: boolean = true): Promise<boolean> {
if (typeof disconnect !== 'boolean') {
throw new Error('[ @Moonlink/Player ]: The parameter must be a boolean value');
}

if (disconnect && this.connected) {
this.disconnect();
}

if ((this.rest.node.version as string).replace(/\./g, '') <= '374') {
this.sendWs({
op: 'destroy',
guildId: this.guildId,
});
} else {
await this.rest.destroy(this.guildId);
}

this.queue.db.delete(`queue.${this.guildId}`);
let players = this.map.get('players');
delete players[this.guildId];
this.map.set('players', players);
return true;
}
public async destroy(disconnect: boolean = true): Promise<boolean> {
if (typeof disconnect !== 'boolean') {
throw new Error('[ @Moonlink/Player ]: The parameter must be a boolean value');
}

if (disconnect && this.connected) {
this.disconnect();
}

if ((this.rest.node.version as string).replace(/\./g, '') <= '374') {
this.sendWs({
op: 'destroy',
guildId: this.guildId,
});
} else {
await this.rest.destroy(this.guildId);
}

this.queue.db.delete(`queue.${this.guildId}`);
let players = this.map.get('players');
delete players[this.guildId];
this.map.set('players', players);
return true;
}
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?