aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2020-03-25 17:59:09 -0500
committerMax Isom <[email protected]>2020-03-25 17:59:09 -0500
commit4e1a156f9be48eaefbd3f6dc09f302db7deaddb2 (patch)
treebd10d224834684b242aefd87a475241d09e3b324 /src
parentdc70a37e962d39ddc5781525d3178e5d9ebe6861 (diff)
downloadmuse-4e1a156f9be48eaefbd3f6dc09f302db7deaddb2.tar.xz
muse-4e1a156f9be48eaefbd3f6dc09f302db7deaddb2.zip
Bump dependencies
Diffstat (limited to 'src')
-rw-r--r--src/bot.ts2
-rw-r--r--src/events/guild-create.ts6
-rw-r--r--src/packages.d.ts22
-rw-r--r--src/services/get-songs.ts14
-rw-r--r--src/services/player.ts6
5 files changed, 38 insertions, 12 deletions
diff --git a/src/bot.ts b/src/bot.ts
index 4ddbfcb..de59ed2 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -91,7 +91,7 @@ export default class {
await handler.execute(msg, args);
} catch (error) {
debug(error);
- await msg.channel.send(errorMsg(error.message.toLowerCase()));
+ await msg.channel.send(errorMsg((error as Error).message.toLowerCase()));
}
});
diff --git a/src/events/guild-create.ts b/src/events/guild-create.ts
index 3675b2c..e842b13 100644
--- a/src/events/guild-create.ts
+++ b/src/events/guild-create.ts
@@ -1,4 +1,4 @@
-import {Guild, MessageReaction, TextChannel} from 'discord.js';
+import {Guild, MessageReaction, TextChannel, User, Message} from 'discord.js';
import emoji from 'node-emoji';
import {Settings} from '../models';
@@ -45,7 +45,7 @@ export default async (guild: Guild): Promise<void> => {
await msg.react(channel.emoji);
}
- const reactions = await msg.awaitReactions((reaction, user) => user.id !== msg.author.id && emojiChannels.map(e => e.emoji).includes(reaction.emoji.name), {max: 1});
+ const reactions = await msg.awaitReactions((reaction: MessageReaction, user: User) => user.id !== msg.author.id && emojiChannels.map(e => e.emoji).includes(reaction.emoji.name), {max: 1});
const choice = reactions.first() as MessageReaction;
@@ -57,7 +57,7 @@ export default async (guild: Guild): Promise<void> => {
await owner.send(secondStep);
- const prefixResponses = await msg.channel.awaitMessages(r => r.content.length === 1, {max: 1});
+ const prefixResponses = await msg.channel.awaitMessages((r: Message) => r.content.length === 1, {max: 1});
const prefixCharacter = prefixResponses.first()!.content;
diff --git a/src/packages.d.ts b/src/packages.d.ts
index 7e199a3..14bbeed 100644
--- a/src/packages.d.ts
+++ b/src/packages.d.ts
@@ -1,3 +1,19 @@
-declare module 'node-emoji';
-declare module 'ytsr';
-declare module 'array-shuffle';
+declare module 'ytsr' {
+ interface VideoResult {
+ title: string;
+ duration: string;
+ link: string;
+ live: boolean;
+ type: string;
+ }
+
+ interface SearchResult {
+ items: VideoResult[];
+ }
+
+ export default function (search: string, options: object): Promise<SearchResult>;
+}
+
+declare module 'array-shuffle' {
+ export default function <T>(arr: T[]): T[];
+}
diff --git a/src/services/get-songs.ts b/src/services/get-songs.ts
index 4e8d955..8cbb60c 100644
--- a/src/services/get-songs.ts
+++ b/src/services/get-songs.ts
@@ -56,8 +56,16 @@ export default class {
const playlist = await this.youtube.playlists.get(listId);
const {items} = await this.youtube.playlists.items(listId, {maxResults: '50'});
+ interface videoResult {
+ id: string;
+ contentDetails: {
+ videoId: string;
+ duration: string;
+ };
+ }
+
// Unfortunately, package doesn't provide a method for this
- const res: any = await got('https://www.googleapis.com/youtube/v3/videos', {searchParams: {
+ const {items: videos}: {items: videoResult[]} = await got('https://www.googleapis.com/youtube/v3/videos', {searchParams: {
part: 'contentDetails',
id: items.map(item => item.contentDetails.videoId).join(','),
key: this.youtubeKey
@@ -66,7 +74,7 @@ export default class {
const queuedPlaylist = {title: playlist.snippet.title, source: playlist.id};
return items.map(video => {
- const length = toSeconds(parse(res.items.find((i: any) => i.id === video.contentDetails.videoId).contentDetails.duration));
+ const length = toSeconds(parse(videos.find((i: { id: string }) => i.id === video.contentDetails.videoId)!.contentDetails.duration));
return {
title: video.snippet.title,
@@ -178,7 +186,7 @@ export default class {
private async spotifyToYouTube(track: SpotifyApi.TrackObjectSimplified, playlist: QueuedPlaylist | null): Promise<QueuedSong | null> {
try {
const {items} = await ytsr(`"${track.name}" "${track.artists[0].name}" offical`, {limit: 5});
- const video = items.find((item: { type: string }) => item.type === 'video');
+ const video = items.find(item => item.type === 'video');
if (!video) {
throw new Error('No video found for query.');
diff --git a/src/services/player.ts b/src/services/player.ts
index ad25744..074fe5d 100644
--- a/src/services/player.ts
+++ b/src/services/player.ts
@@ -238,7 +238,9 @@ export default class {
}
shuffle(): void {
- this.queue = [...this.queue.slice(0, this.queuePosition + 1), ...shuffle(this.queue.slice(this.queuePosition + 1))];
+ const shuffledSongs = shuffle(this.queue.slice(this.queuePosition + 1));
+
+ this.queue = [...this.queue.slice(0, this.queuePosition + 1), ...shuffledSongs];
}
clear(): void {
@@ -306,7 +308,7 @@ export default class {
const nextBestFormat = (formats: ytdl.videoFormat[]): ytdl.videoFormat | undefined => {
if (formats[0].live) {
- formats = formats.sort((a, b) => (b as any).audioBitrate - (a as any).audioBitrate); // Bad typings
+ formats = formats.sort((a, b) => (b as unknown as {audioBitrate: number}).audioBitrate - (a as unknown as {audioBitrate: number}).audioBitrate); // Bad typings
return formats.find(format => [128, 127, 120, 96, 95, 94, 93].includes(parseInt(format.itag as unknown as string, 10))); // Bad typings
}