Skip to content

Commit

Permalink
fix: get voice channels members synchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilhermeasper committed Aug 29, 2023
1 parent 981e97f commit be258a9
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/services/tempo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

import { BaseGuildVoiceChannel, Message, TextChannel } from 'discord.js';
import { GuildMember, Message } from 'discord.js';
import dotenv from 'dotenv';
import { PlaybackData } from 'src/types';

Expand All @@ -43,14 +43,11 @@ export class TempoDataProvider {
async getPlaybackDataFromMessage(message: Message): Promise<PlaybackData> {
const title = message?.embeds[0]?.title?.slice(this.titlePaddingIndex);

const fetchedMessage = await message.fetch();
const fetchedMember = await fetchedMessage.member?.fetch();
const fetchedMemberVoiceChannel =
await fetchedMember?.voice.channel.fetch();

const listeningUsersId = fetchedMemberVoiceChannel.members.map(
(member) => member.id
);
const members = (message.member as GuildMember)?.voice.channel?.members;
const listeningUsersId: string[] = [];
members?.forEach((member: GuildMember) => {
listeningUsersId.push(member.id);
});

return {
title,
Expand Down

0 comments on commit be258a9

Please sign in to comment.