feat: discord.js v13

This commit is contained in:
Hellyson Rodrigo Parteka 2021-11-12 16:30:18 -03:00
parent a4e67d6383
commit 8448feebb6
No known key found for this signature in database
GPG key ID: 3055745CA21934C7
13 changed files with 381 additions and 154 deletions

View file

@ -9,7 +9,7 @@ const DEFAULT_PREFIX = '!';
export default async (guild: Guild): Promise<void> => {
await Settings.upsert({guildId: guild.id, prefix: DEFAULT_PREFIX});
const owner = await guild.client.users.fetch(guild.ownerID);
const owner = await guild.client.users.fetch(guild.ownerId);
let firstStep = '👋 Hi!\n';
firstStep += 'I just need to ask a few questions before you start listening to music.\n\n';
@ -27,7 +27,7 @@ export default async (guild: Guild): Promise<void> => {
const emojiChannels: EmojiChannel[] = [];
for (const [channelId, channel] of guild.channels.cache) {
if (channel.type === 'text') {
if (channel.type === 'GUILD_TEXT') {
emojiChannels.push({
name: channel.name,
id: channelId,
@ -65,7 +65,7 @@ export default async (guild: Guild): Promise<void> => {
await owner.send(secondStep);
const prefixResponses = await firstStepMsg.channel.awaitMessages((r: Message) => r.content.length === 1, {max: 1});
const prefixResponses = await firstStepMsg.channel.awaitMessages({filter: (r: Message) => r.content.length === 1, max: 1});
const prefixCharacter = prefixResponses.first()!.content;

View file

@ -1,4 +1,4 @@
import {VoiceState} from 'discord.js';
import {VoiceChannel, VoiceState} from 'discord.js';
import container from '../inversify.config.js';
import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
@ -10,7 +10,8 @@ export default (oldState: VoiceState, _: VoiceState): void => {
const player = playerManager.get(oldState.guild.id);
if (player.voiceConnection) {
if (getSizeWithoutBots(player.voiceConnection.channel) === 0) {
const voiceChannel: VoiceChannel = oldState.guild.channels.cache.get(player.voiceConnection.joinConfig.channelId!) as VoiceChannel;
if (!voiceChannel || getSizeWithoutBots(voiceChannel) === 0) {
player.disconnect();
}
}