Migrate to slash commands (#431)

Co-authored-by: Federico fuji97 Rapetti <fuji1097@gmail.com>
This commit is contained in:
Max Isom 2022-02-05 16:16:17 -06:00 committed by GitHub
parent e883275d83
commit 56a469a999
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 1270 additions and 1294 deletions

BIN
.github/hero.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

View file

@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Migrated to [Slash Commands](https://support.discord.com/hc/en-us/articles/1500000368501-Slash-Commands-FAQ)
- Upgrading **will cause unavoidable data loss**. Because slash commands work differently, **all shortcuts will be lost**. Functionality similar to shortcuts is provided by the `/favorites` command.
- Because slash commands require different permissions, **you must kick Muse and re-add Muse to your server** before you can use the bot.
## [0.5.4] - 2022-02-01
### Fixed

View file

@ -35,6 +35,11 @@ COPY --from=builder /usr/app/migrations migrations
RUN yarn prisma generate
ARG COMMIT_HASH=unknown
ENV DATA_DIR /data
ENV NODE_ENV production
ENV BUILD_DATE $(date)
ENV COMMIT_HASH $COMMIT_HASH
CMD ["yarn", "start"]

View file

@ -4,7 +4,9 @@
Muse is a **highly-opinionated midwestern self-hosted** Discord music bot **that doesn't suck**. It's made for small to medium-sized Discord servers/guilds (think about a group the size of you, your friends, and your friend's friends).
### Features
![Hero graphic](.github/hero.png)
## Features
- 🎥 Livestreams
- ⏩ Seeking within a song/video
@ -16,11 +18,7 @@ Muse is a **highly-opinionated midwestern self-hosted** Discord music bot **that
- ✍️ Written in TypeScript, easily extendable
- ❤️ Loyal Packers fan
### Design Philosophy
I believe it makes much more sense to let Discord handle user permissions (whenever possible) rather than building them into a bot and adding additional complexity. Instead of only allowing users with a certain role to control Muse, Muse allows anyone who has access to its bound channel to control it. Instead of specifying the owner as a user ID in the config, Muse simply looks at the guild owner.
### Running
## Running
Muse is written in TypeScript. You can either run Muse with Docker (recommended) or directly with Node.js. Both methods require API keys passed in as environment variables:
@ -30,14 +28,14 @@ Muse is written in TypeScript. You can either run Muse with Docker (recommended)
Muse will log a URL when run. Open this URL in a browser to invite Muse to your server. Muse will DM the server owner after it's added with setup instructions.
#### Versioning
### Versioning
The `master` branch acts as the developing / bleeding edge branch and is not guaranteed to be stable.
When running a production instance, I recommend that you use the [latest release](https://github.com/codetheweb/muse/releases/).
#### Docker
### 🐳 Docker
There are a variety of image tags available:
- `:2`: versions >= 2.0.0
@ -71,7 +69,7 @@ services:
- SPOTIFY_CLIENT_SECRET=
```
#### Node.js
### Node.js
**Prerequisites**: Node.js, ffmpeg
@ -84,6 +82,12 @@ services:
**Note**: if you're on Windows, you may need to manually set the ffmpeg path. See [#345](https://github.com/codetheweb/muse/issues/345) for details.
#### Advanced
## ⚙️ Additional configuration (advanced)
### Cache
By default, Muse limits the total cache size to around 2 GB. If you want to change this, set the environment variable `CACHE_LIMIT`. For example, `CACHE_LIMIT=512MB` or `CACHE_LIMIT=10GB`.
### Bot-wide commands
If you have Muse running in a lot of guilds (10+) you may want to switch to registering commands bot-wide rather than for each guild. (The downside to this is that command updates can take up to an hour to propagate.) To do this, set the environment variable `REGISTER_COMMANDS_ON_BOT` to `true`.

View file

@ -0,0 +1,10 @@
-- CreateTable
CREATE TABLE "FavoriteQuery" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"guildId" TEXT NOT NULL,
"authorId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"query" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

View file

@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the `Shortcut` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropTable
PRAGMA foreign_keys=off;
DROP TABLE "Shortcut";
PRAGMA foreign_keys=on;

View file

@ -0,0 +1,8 @@
/*
Warnings:
- A unique constraint covering the columns `[name]` on the table `FavoriteQuery` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "FavoriteQuery_name_key" ON "FavoriteQuery"("name");

View file

@ -0,0 +1,11 @@
/*
Warnings:
- A unique constraint covering the columns `[guildId,name]` on the table `FavoriteQuery` will be added. If there are existing duplicate values, this will fail.
*/
-- DropIndex
DROP INDEX "FavoriteQuery_name_key";
-- CreateIndex
CREATE UNIQUE INDEX "FavoriteQuery_guildId_name_key" ON "FavoriteQuery"("guildId", "name");

View file

@ -0,0 +1,21 @@
/*
Warnings:
- You are about to drop the column `finishedSetup` on the `Setting` table. All the data in the column will be lost.
- You are about to drop the column `prefix` on the `Setting` table. All the data in the column will be lost.
*/
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Setting" (
"guildId" TEXT NOT NULL PRIMARY KEY,
"channel" TEXT,
"playlistLimit" INTEGER NOT NULL DEFAULT 50,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
INSERT INTO "new_Setting" ("channel", "createdAt", "guildId", "playlistLimit", "updatedAt") SELECT "channel", "createdAt", "guildId", "playlistLimit", "updatedAt" FROM "Setting";
DROP TABLE "Setting";
ALTER TABLE "new_Setting" RENAME TO "Setting";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;

View file

@ -0,0 +1,19 @@
/*
Warnings:
- You are about to drop the column `channel` on the `Setting` table. All the data in the column will be lost.
*/
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Setting" (
"guildId" TEXT NOT NULL PRIMARY KEY,
"playlistLimit" INTEGER NOT NULL DEFAULT 50,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
INSERT INTO "new_Setting" ("createdAt", "guildId", "playlistLimit", "updatedAt") SELECT "createdAt", "guildId", "playlistLimit", "updatedAt" FROM "Setting";
DROP TABLE "Setting";
ALTER TABLE "new_Setting" RENAME TO "Setting";
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Setting" ADD COLUMN "roleId" TEXT;

View file

@ -17,8 +17,8 @@
"dts"
],
"scripts": {
"lint": "eslint 'src/**/*.ts'",
"lint:fix": "eslint 'src/**/*.ts' --fix",
"lint": "eslint \"src/**/*.{ts,tsx}\"",
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
"clean": "rm -rf dist dts",
"test": "npm run lint",
"build": "tsc",
@ -52,7 +52,7 @@
"eslint-config-xo-typescript": "^0.44.0",
"husky": "^4.3.8",
"nodemon": "^2.0.7",
"prisma": "^3.7.0",
"prisma": "^3.8.1",
"release-it": "^14.11.8",
"ts-node": "^10.4.0",
"type-fest": "^2.8.0",
@ -81,9 +81,11 @@
}
},
"dependencies": {
"@discordjs/builders": "^0.12.0",
"@discordjs/opus": "^0.7.0",
"@discordjs/rest": "^0.3.0",
"@discordjs/voice": "^0.8.0",
"@prisma/client": "^3.7.0",
"@prisma/client": "^3.8.1",
"@types/libsodium-wrappers": "^0.7.9",
"array-shuffle": "^3.0.0",
"debug": "^4.3.3",

View file

@ -25,25 +25,20 @@ model KeyValueCache {
model Setting {
guildId String @id
prefix String
channel String?
finishedSetup Boolean @default(false)
playlistLimit Int @default(50)
roleId String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Shortcut {
model FavoriteQuery {
id Int @id @default(autoincrement())
guildId String
authorId String
shortcut String
command String
name String
query String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([shortcut], map: "shortcuts_shortcut")
@@index([guildId], map: "shortcuts_guild_id")
@@index([guildId, shortcut])
@@unique([guildId, name])
}

View file

@ -1,147 +1,167 @@
import {Client, Message, Collection} from 'discord.js';
import {Client, Collection, User} from 'discord.js';
import {inject, injectable} from 'inversify';
import ora from 'ora';
import {TYPES} from './types.js';
import {prisma} from './utils/db.js';
import container from './inversify.config.js';
import Command from './commands/index.js';
import debug from './utils/debug.js';
import NaturalLanguage from './services/natural-language-commands.js';
import handleGuildCreate from './events/guild-create.js';
import handleVoiceStateUpdate from './events/voice-state-update.js';
import handleGuildUpdate from './events/guild-update.js';
import errorMsg from './utils/error-msg.js';
import {isUserInVoice} from './utils/channels.js';
import Config from './services/config.js';
import {generateDependencyReport} from '@discordjs/voice';
import {REST} from '@discordjs/rest';
import {Routes} from 'discord-api-types/v9';
import updatePermissionsForGuild from './utils/update-permissions-for-guild.js';
@injectable()
export default class {
private readonly client: Client;
private readonly naturalLanguage: NaturalLanguage;
private readonly token: string;
private readonly commands!: Collection<string, Command>;
private readonly shouldRegisterCommandsOnBot: boolean;
private readonly commandsByName!: Collection<string, Command>;
private readonly commandsByButtonId!: Collection<string, Command>;
constructor(
@inject(TYPES.Client) client: Client,
@inject(TYPES.Services.NaturalLanguage) naturalLanguage: NaturalLanguage,
@inject(TYPES.Config) config: Config,
) {
this.client = client;
this.naturalLanguage = naturalLanguage;
this.token = config.DISCORD_TOKEN;
this.commands = new Collection();
this.shouldRegisterCommandsOnBot = config.REGISTER_COMMANDS_ON_BOT;
this.commandsByName = new Collection();
this.commandsByButtonId = new Collection();
}
public async listen(): Promise<string> {
public async register(): Promise<void> {
// Load in commands
container.getAll<Command>(TYPES.Command).forEach(command => {
const commandNames = [command.name, ...command.aliases];
commandNames.forEach(commandName =>
this.commands.set(commandName, command),
);
});
this.client.on('messageCreate', async (msg: Message) => {
// Get guild settings
if (!msg.guild) {
return;
}
const settings = await prisma.setting.findUnique({
where: {
guildId: msg.guild.id,
},
});
if (!settings) {
// Got into a bad state, send owner welcome message
this.client.emit('guildCreate', msg.guild);
return;
}
const {prefix, channel} = settings;
if (
!msg.content.startsWith(prefix)
&& !msg.author.bot
&& msg.channel.id === channel
&& (await this.naturalLanguage.execute(msg))
) {
// Natural language command handled message
return;
}
if (
!msg.content.startsWith(prefix)
|| msg.author.bot
|| msg.channel.id !== channel
) {
return;
}
let args = msg.content.slice(prefix.length).split(/ +/);
const command = args.shift()!.toLowerCase();
const shortcut = await prisma.shortcut.findFirst({
where: {
guildId: msg.guild.id,
shortcut: command,
},
});
let handler: Command;
if (this.commands.has(command)) {
handler = this.commands.get(command)!;
} else if (shortcut) {
const possibleHandler = this.commands.get(
shortcut.command.split(' ')[0],
);
if (possibleHandler) {
handler = possibleHandler;
args = shortcut.command.split(/ +/).slice(1);
} else {
return;
}
} else {
return;
}
for (const command of container.getAll<Command>(TYPES.Command)) {
// Make sure we can serialize to JSON without errors
try {
if (handler.requiresVC && !isUserInVoice(msg.guild, msg.author)) {
await msg.channel.send(errorMsg('gotta be in a voice channel'));
return;
}
command.slashCommand.toJSON();
} catch (error) {
console.error(error);
throw new Error(`Could not serialize /${command.slashCommand.name ?? ''} to JSON`);
}
await handler.execute(msg, args);
if (command.slashCommand.name) {
this.commandsByName.set(command.slashCommand.name, command);
}
if (command.handledButtonIds) {
for (const buttonId of command.handledButtonIds) {
this.commandsByButtonId.set(buttonId, command);
}
}
}
// Register event handlers
this.client.on('interactionCreate', async interaction => {
try {
if (interaction.isCommand()) {
const command = this.commandsByName.get(interaction.commandName);
if (!command) {
return;
}
if (!interaction.guild) {
await interaction.reply(errorMsg('you can\'t use this bot in a DM'));
return;
}
const requiresVC = command.requiresVC instanceof Function ? command.requiresVC(interaction) : command.requiresVC;
if (requiresVC && interaction.member && !isUserInVoice(interaction.guild, interaction.member.user as User)) {
await interaction.reply({content: errorMsg('gotta be in a voice channel'), ephemeral: true});
return;
}
if (command.execute) {
await command.execute(interaction);
}
} else if (interaction.isButton()) {
const command = this.commandsByButtonId.get(interaction.customId);
if (!command) {
return;
}
if (command.handleButtonInteraction) {
await command.handleButtonInteraction(interaction);
}
} else if (interaction.isAutocomplete()) {
const command = this.commandsByName.get(interaction.commandName);
if (!command) {
return;
}
if (command.handleAutocompleteInteraction) {
await command.handleAutocompleteInteraction(interaction);
}
}
} catch (error: unknown) {
debug(error);
await msg.channel.send(
errorMsg((error as Error).message.toLowerCase()),
);
// This can fail if the message was deleted, and we don't want to crash the whole bot
try {
if ((interaction.isApplicationCommand() || interaction.isButton()) && (interaction.replied || interaction.deferred)) {
await interaction.editReply(errorMsg(error as Error));
} else if (interaction.isApplicationCommand() || interaction.isButton()) {
await interaction.reply({content: errorMsg(error as Error), ephemeral: true});
}
} catch {}
}
});
const spinner = ora('📡 connecting to Discord...').start();
this.client.on('ready', () => {
this.client.once('ready', async () => {
debug(generateDependencyReport());
spinner.succeed(
`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''
}&scope=bot&permissions=36752448`,
);
// Update commands
const rest = new REST({version: '9'}).setToken(this.token);
if (this.shouldRegisterCommandsOnBot) {
spinner.text = '📡 updating commands on bot...';
await rest.put(
Routes.applicationCommands(this.client.user!.id),
{body: this.commandsByName.map(command => command.slashCommand.toJSON())},
);
} else {
spinner.text = '📡 updating commands in all guilds...';
await Promise.all([
...this.client.guilds.cache.map(async guild => {
await rest.put(
Routes.applicationGuildCommands(this.client.user!.id, guild.id),
{body: this.commandsByName.map(command => command.slashCommand.toJSON())},
);
}),
// Remove commands registered on bot (if they exist)
rest.put(Routes.applicationCommands(this.client.user!.id), {body: []}),
],
);
}
// Update permissions
spinner.text = '📡 updating permissions...';
await Promise.all(this.client.guilds.cache.map(async guild => updatePermissionsForGuild(guild)));
spinner.succeed(`Ready! Invite the bot with https://discordapp.com/oauth2/authorize?client_id=${this.client.user?.id ?? ''}&scope=bot%20applications.commands&permissions=36700160`);
});
this.client.on('error', console.error);
this.client.on('debug', debug);
// Register event handlers
this.client.on('guildCreate', handleGuildCreate);
this.client.on('voiceStateUpdate', handleVoiceStateUpdate);
this.client.on('guildUpdate', handleGuildUpdate);
return this.client.login(this.token);
await this.client.login(this.token);
}
}

View file

@ -1,16 +1,15 @@
import {inject, injectable} from 'inversify';
import {Message} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
import Command from '.';
@injectable()
export default class implements Command {
public name = 'clear';
public aliases = ['c'];
public examples = [
['clear', 'clears all songs in queue except currently playing'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('clear')
.setDescription('clears all songs in queue except currently playing song');
public requiresVC = true;
@ -20,9 +19,9 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, _: string []): Promise<void> {
this.playerManager.get(msg.guild!.id).clear();
public async execute(interaction: CommandInteraction) {
this.playerManager.get(interaction.guild!.id).clear();
await msg.channel.send('clearer than a field after a fresh harvest');
await interaction.reply('clearer than a field after a fresh harvest');
}
}

View file

@ -1,121 +1,103 @@
import {TextChannel, Message, GuildChannel, ThreadChannel} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {CommandInteraction, MessageEmbed} from 'discord.js';
import {injectable} from 'inversify';
import errorMsg from '../utils/error-msg.js';
import Command from '.';
import {prisma} from '../utils/db.js';
import updatePermissionsForGuild from '../utils/update-permissions-for-guild.js';
import Command from './index.js';
@injectable()
export default class implements Command {
public name = 'config';
public aliases = [];
public examples = [
['config prefix !', 'set the prefix to !'],
['config channel music-commands', 'bind the bot to the music-commands channel'],
['config playlist-limit 30', 'set the playlist song limit to 30'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('config')
.setDescription('configure bot settings')
.addSubcommand(subcommand => subcommand
.setName('set-playlist-limit')
.setDescription('set the maximum number of tracks that can be added from a playlist')
.addIntegerOption(option => option
.setName('limit')
.setDescription('maximum number of tracks')
.setRequired(true)))
.addSubcommand(subcommand => subcommand
.setName('set-role')
.setDescription('set the role that is allowed to use the bot')
.addRoleOption(option => option
.setName('role')
.setDescription('allowed role')
.setRequired(true)))
.addSubcommand(subcommand => subcommand
.setName('get')
.setDescription('show all settings'));
public async execute(msg: Message, args: string []): Promise<void> {
if (args.length === 0) {
// Show current settings
const settings = await prisma.setting.findUnique({
where: {
guildId: msg.guild!.id,
},
});
async execute(interaction: CommandInteraction) {
switch (interaction.options.getSubcommand()) {
case 'set-playlist-limit': {
const limit = interaction.options.getInteger('limit')!;
if (settings?.channel) {
let response = `prefix: \`${settings.prefix}\`\n`;
// eslint-disable-next-line @typescript-eslint/no-base-to-string
response += `channel: ${msg.guild!.channels.cache.get(settings.channel)!.toString()}\n`;
response += `playlist-limit: ${settings.playlistLimit}`;
await msg.channel.send(response);
}
return;
}
const setting = args[0];
if (args.length !== 2) {
await msg.channel.send(errorMsg('incorrect number of arguments'));
return;
}
if (msg.author.id !== msg.guild!.ownerId) {
await msg.channel.send(errorMsg('not authorized'));
return;
}
switch (setting) {
case 'prefix': {
const newPrefix = args[1];
await prisma.setting.update({
where: {
guildId: msg.guild!.id,
},
data: {
prefix: newPrefix,
},
});
await msg.channel.send(`👍 prefix updated to \`${newPrefix}\``);
break;
}
case 'channel': {
let channel: GuildChannel | ThreadChannel | undefined;
if (args[1].includes('<#') && args[1].includes('>')) {
channel = msg.guild!.channels.cache.find(c => c.id === args[1].slice(2, args[1].indexOf('>')));
} else {
channel = msg.guild!.channels.cache.find(c => c.name === args[1]);
}
if (channel && channel.type === 'GUILD_TEXT') {
await prisma.setting.update({
where: {
guildId: msg.guild!.id,
},
data: {
channel: channel.id,
},
});
await Promise.all([
(channel as TextChannel).send('hey apparently I\'m bound to this channel now'),
msg.react('👍'),
]);
} else {
await msg.channel.send(errorMsg('either that channel doesn\'t exist or you want me to become sentient and listen to a voice channel'));
}
break;
}
case 'playlist-limit': {
const playlistLimit = parseInt(args[1], 10);
if (playlistLimit <= 0) {
await msg.channel.send(errorMsg('please enter a valid number'));
return;
if (limit < 1) {
throw new Error('invalid limit');
}
await prisma.setting.update({
where: {
guildId: msg.guild!.id,
guildId: interaction.guild!.id,
},
data: {
playlistLimit,
playlistLimit: limit,
},
});
await msg.channel.send(`👍 playlist-limit updated to ${playlistLimit}`);
await interaction.reply('👍 limit updated');
break;
}
case 'set-role': {
const role = interaction.options.getRole('role')!;
await prisma.setting.update({
where: {
guildId: interaction.guild!.id,
},
data: {
roleId: role.id,
},
});
await updatePermissionsForGuild(interaction.guild!);
await interaction.reply('👍 role updated');
break;
}
case 'get': {
const embed = new MessageEmbed().setTitle('Config');
const config = await prisma.setting.findUnique({where: {guildId: interaction.guild!.id}});
if (!config) {
throw new Error('no config found');
}
const settingsToShow = {
'Playlist Limit': config.playlistLimit,
Role: config.roleId ? `<@&${config.roleId}>` : 'not set',
};
let description = '';
for (const [key, value] of Object.entries(settingsToShow)) {
description += `**${key}**: ${value}\n`;
}
embed.setDescription(description);
await interaction.reply({embeds: [embed]});
break;
}
default:
await msg.channel.send(errorMsg('I\'ve never met this setting in my life'));
throw new Error('unknown subcommand');
}
}
}

View file

@ -1,17 +1,15 @@
import {Message} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
import errorMsg from '../utils/error-msg.js';
import Command from '.';
@injectable()
export default class implements Command {
public name = 'disconnect';
public aliases = ['dc'];
public examples = [
['disconnect', 'pauses and disconnects player'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('disconnect')
.setDescription('pauses and disconnects player');
public requiresVC = true;
@ -21,16 +19,15 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, _: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
public async execute(interaction: CommandInteraction) {
const player = this.playerManager.get(interaction.guild!.id);
if (!player.voiceConnection) {
await msg.channel.send(errorMsg('not connected'));
return;
throw new Error('not connected');
}
player.disconnect();
await msg.channel.send('u betcha');
await interaction.reply('u betcha');
}
}

195
src/commands/favorites.ts Normal file
View file

@ -0,0 +1,195 @@
import {SlashCommandBuilder} from '@discordjs/builders';
import {AutocompleteInteraction, CommandInteraction, MessageEmbed} from 'discord.js';
import {inject, injectable} from 'inversify';
import Command from '.';
import AddQueryToQueue from '../services/add-query-to-queue.js';
import {TYPES} from '../types.js';
import {prisma} from '../utils/db.js';
@injectable()
export default class implements Command {
public readonly slashCommand = new SlashCommandBuilder()
.setName('favorites')
.setDescription('adds a song to your favorites')
.addSubcommand(subcommand => subcommand
.setName('use')
.setDescription('use a favorite')
.addStringOption(option => option
.setName('name')
.setDescription('name of favorite')
.setRequired(true)
.setAutocomplete(true))
.addBooleanOption(option => option
.setName('immediate')
.setDescription('add track to the front of the queue'))
.addBooleanOption(option => option
.setName('shuffle')
.setDescription('shuffle the input if you\'re adding multiple tracks')))
.addSubcommand(subcommand => subcommand
.setName('list')
.setDescription('list all favorites'))
.addSubcommand(subcommand => subcommand
.setName('create')
.setDescription('create a new favorite')
.addStringOption(option => option
.setName('name')
.setDescription('you\'ll type this when using this favorite')
.setRequired(true))
.addStringOption(option => option
.setName('query')
.setDescription('any input you\'d normally give to the play command')
.setRequired(true),
))
.addSubcommand(subcommand => subcommand
.setName('remove')
.setDescription('remove a favorite')
.addStringOption(option => option
.setName('name')
.setDescription('name of favorite')
.setAutocomplete(true)
.setRequired(true),
),
);
constructor(@inject(TYPES.Services.AddQueryToQueue) private readonly addQueryToQueue: AddQueryToQueue) {}
requiresVC = (interaction: CommandInteraction) => interaction.options.getSubcommand() === 'use';
async execute(interaction: CommandInteraction) {
switch (interaction.options.getSubcommand()) {
case 'use':
await this.use(interaction);
break;
case 'list':
await this.list(interaction);
break;
case 'create':
await this.create(interaction);
break;
case 'remove':
await this.remove(interaction);
break;
default:
throw new Error('unknown subcommand');
}
}
async handleAutocompleteInteraction(interaction: AutocompleteInteraction) {
const subcommand = interaction.options.getSubcommand();
const query = interaction.options.getString('name')!.trim();
const favorites = await prisma.favoriteQuery.findMany({
where: {
guildId: interaction.guild!.id,
},
});
let results = query === '' ? favorites : favorites.filter(f => f.name.startsWith(query));
if (subcommand === 'remove') {
// Only show favorites that user is allowed to remove
results = interaction.member?.user.id === interaction.guild?.ownerId ? results : results.filter(r => r.authorId === interaction.member!.user.id);
}
await interaction.respond(results.map(r => ({
name: r.name,
value: r.name,
})));
}
private async use(interaction: CommandInteraction) {
const name = interaction.options.getString('name')!.trim();
const favorite = await prisma.favoriteQuery.findFirst({
where: {
name,
guildId: interaction.guild!.id,
},
});
if (!favorite) {
throw new Error('no favorite with that name exists');
}
await this.addQueryToQueue.addToQueue({
interaction,
query: favorite.query,
shuffleAdditions: interaction.options.getBoolean('shuffle') ?? false,
addToFrontOfQueue: interaction.options.getBoolean('immediate') ?? false,
});
}
private async list(interaction: CommandInteraction) {
const favorites = await prisma.favoriteQuery.findMany({
where: {
guildId: interaction.guild!.id,
},
});
if (favorites.length === 0) {
await interaction.reply('there aren\'t any favorites yet');
return;
}
const embed = new MessageEmbed().setTitle('Favorites');
let description = '';
for (const favorite of favorites) {
description += `**${favorite.name}**: ${favorite.query} (<@${favorite.authorId}>)\n`;
}
embed.setDescription(description);
await interaction.reply({
embeds: [embed],
});
}
private async create(interaction: CommandInteraction) {
const name = interaction.options.getString('name')!.trim();
const query = interaction.options.getString('query')!.trim();
const existingFavorite = await prisma.favoriteQuery.findFirst({where: {
guildId: interaction.guild!.id,
name,
}});
if (existingFavorite) {
throw new Error('a favorite with that name already exists');
}
await prisma.favoriteQuery.create({
data: {
authorId: interaction.member!.user.id,
guildId: interaction.guild!.id,
name,
query,
},
});
await interaction.reply('👍 favorite created');
}
private async remove(interaction: CommandInteraction) {
const name = interaction.options.getString('name')!.trim();
const favorite = await prisma.favoriteQuery.findFirst({where: {
name,
guildId: interaction.guild!.id,
}});
if (!favorite) {
throw new Error('no favorite with that name exists');
}
const isUserGuildOwner = interaction.member!.user.id === interaction.guild!.ownerId;
if (favorite.authorId !== interaction.member!.user.id && !isUserGuildOwner) {
throw new Error('you can only remove your own favorites');
}
await prisma.favoriteQuery.delete({where: {id: favorite.id}});
await interaction.reply('👍 favorite removed');
}
}

View file

@ -1,18 +1,20 @@
import {Message, TextChannel} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
import LoadingMessage from '../utils/loading-message.js';
import errorMsg from '../utils/error-msg.js';
import Command from '.';
import {prettyTime} from '../utils/time.js';
@injectable()
export default class implements Command {
public name = 'fseek';
public aliases = [];
public examples = [
['fseek 10', 'skips forward in current song by 10 seconds'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('fseek')
.setDescription('seek forward in the current song')
.addNumberOption(option => option
.setName('seconds')
.setDescription('the number of seconds to skip forward')
.setRequired(true));
public requiresVC = true;
@ -22,38 +24,34 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, args: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
public async execute(interaction: CommandInteraction): Promise<void> {
const player = this.playerManager.get(interaction.guild!.id);
const currentSong = player.getCurrent();
if (!currentSong) {
await msg.channel.send(errorMsg('nothing is playing'));
return;
throw new Error('nothing is playing');
}
if (currentSong.isLive) {
await msg.channel.send(errorMsg('can\'t seek in a livestream'));
return;
throw new Error('can\'t seek in a livestream');
}
const seekTime = parseInt(args[0], 10);
const seekTime = interaction.options.getNumber('seconds');
if (!seekTime) {
throw new Error('missing number of seconds to seek');
}
if (seekTime + player.getPosition() > currentSong.length) {
await msg.channel.send(errorMsg('can\'t seek past the end of the song'));
return;
throw new Error('can\'t seek past the end of the song');
}
const loading = new LoadingMessage(msg.channel as TextChannel);
await Promise.all([
player.forwardSeek(seekTime),
interaction.deferReply(),
]);
await loading.start();
try {
await player.forwardSeek(seekTime);
await loading.stop();
} catch (error: unknown) {
await loading.stop(errorMsg(error as Error));
}
await interaction.editReply(`👍 seeked to ${prettyTime(player.getPosition())}`);
}
}

View file

@ -1,70 +0,0 @@
import {Message, Util} from 'discord.js';
import {injectable} from 'inversify';
import Command from '.';
import {TYPES} from '../types.js';
import container from '../inversify.config.js';
import {prisma} from '../utils/db.js';
@injectable()
export default class implements Command {
public name = 'help';
public aliases = ['h'];
public examples = [
['help', 'you don\'t need a description'],
];
private commands: Command[] = [];
public async execute(msg: Message, _: string []): Promise<void> {
if (this.commands.length === 0) {
// Lazy load to avoid circular dependencies
this.commands = container.getAll<Command>(TYPES.Command);
}
const settings = await prisma.setting.findUnique({
where: {
guildId: msg.guild!.id,
},
});
if (!settings) {
return;
}
const {prefix} = settings;
const res = Util.splitMessage(this.commands.sort((a, b) => a.name.localeCompare(b.name)).reduce((content, command) => {
const aliases = command.aliases.reduce((str, alias, i) => {
str += alias;
if (i !== command.aliases.length - 1) {
str += ', ';
}
return str;
}, '');
if (aliases === '') {
content += `**${command.name}**:\n`;
} else {
content += `**${command.name}** (${aliases}):\n`;
}
command.examples.forEach(example => {
content += `- \`${prefix}${example[0]}\`: ${example[1]}\n`;
});
content += '\n';
return content;
}, ''));
for (const r of res) {
// eslint-disable-next-line no-await-in-loop
await msg.author.send(r);
}
await msg.react('🇩');
await msg.react('🇲');
}
}

View file

@ -1,9 +1,11 @@
import {Message} from 'discord.js';
import {SlashCommandBuilder, SlashCommandSubcommandsOnlyBuilder} from '@discordjs/builders';
import {AutocompleteInteraction, ButtonInteraction, CommandInteraction} from 'discord.js';
export default interface Command {
name: string;
aliases: string[];
examples: string[][];
requiresVC?: boolean;
execute: (msg: Message, args: string[]) => Promise<void>;
readonly slashCommand: Partial<SlashCommandBuilder | SlashCommandSubcommandsOnlyBuilder> & Pick<SlashCommandBuilder, 'toJSON'>;
readonly handledButtonIds?: readonly string[];
readonly requiresVC?: boolean | ((interaction: CommandInteraction) => boolean);
execute: (interaction: CommandInteraction) => Promise<void>;
handleButtonInteraction?: (interaction: ButtonInteraction) => Promise<void>;
handleAutocompleteInteraction?: (interaction: AutocompleteInteraction) => Promise<void>;
}

View file

@ -1,18 +1,16 @@
import {Message} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
import {STATUS} from '../services/player.js';
import errorMsg from '../utils/error-msg.js';
import Command from '.';
@injectable()
export default class implements Command {
public name = 'pause';
public aliases = [];
public examples = [
['pause', 'pauses currently playing song'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('pause')
.setDescription('pauses the current song');
public requiresVC = true;
@ -22,15 +20,14 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, _: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
public async execute(interaction: CommandInteraction) {
const player = this.playerManager.get(interaction.guild!.id);
if (player.status !== STATUS.PLAYING) {
await msg.channel.send(errorMsg('not currently playing'));
return;
throw new Error('not currently playing');
}
player.pause();
await msg.channel.send('the stop-and-go light is now red');
await interaction.reply('the stop-and-go light is now red');
}
}

View file

@ -1,211 +1,113 @@
import {TextChannel, Message} from 'discord.js';
import {AutocompleteInteraction, CommandInteraction, GuildMember} from 'discord.js';
import {URL} from 'url';
import {Except} from 'type-fest';
import shuffle from 'array-shuffle';
import {TYPES} from '../types.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {inject, injectable} from 'inversify';
import {QueuedSong, STATUS} from '../services/player.js';
import PlayerManager from '../managers/player.js';
import {getMostPopularVoiceChannel, getMemberVoiceChannel} from '../utils/channels.js';
import LoadingMessage from '../utils/loading-message.js';
import errorMsg from '../utils/error-msg.js';
import Spotify from 'spotify-web-api-node';
import Command from '.';
import GetSongs from '../services/get-songs.js';
import {prisma} from '../utils/db.js';
import {TYPES} from '../types.js';
import ThirdParty from '../services/third-party.js';
import getYouTubeAndSpotifySuggestionsFor from '../utils/get-youtube-and-spotify-suggestions-for.js';
import KeyValueCacheProvider from '../services/key-value-cache.js';
import {ONE_HOUR_IN_SECONDS} from '../utils/constants.js';
import AddQueryToQueue from '../services/add-query-to-queue.js';
import PlayerManager from '../managers/player.js';
import {STATUS} from '../services/player.js';
import {buildPlayingMessageEmbed} from '../utils/build-embed.js';
import {getMemberVoiceChannel, getMostPopularVoiceChannel} from '../utils/channels.js';
@injectable()
export default class implements Command {
public name = 'play';
public aliases = ['p'];
public examples = [
['play', 'resume paused playback'],
['play https://www.youtube.com/watch?v=dQw4w9WgXcQ', 'plays a YouTube video'],
['play cool music', 'plays the first search result for "cool music" from YouTube'],
['play https://www.youtube.com/watch?list=PLi9drqWffJ9FWBo7ZVOiaVy0UQQEm4IbP', 'adds the playlist to the queue'],
['play https://open.spotify.com/track/3ebXMykcMXOcLeJ9xZ17XH?si=tioqSuyMRBWxhThhAW51Ig', 'plays a song from Spotify'],
['play https://open.spotify.com/album/5dv1oLETxdsYOkS2Sic00z?si=bDa7PaloRx6bMIfKdnvYQw', 'adds all songs from album to the queue'],
['play https://open.spotify.com/playlist/37i9dQZF1DX94qaYRnkufr?si=r2fOVL_QQjGxFM5MWb84Xw', 'adds all songs from playlist to the queue'],
['play cool music immediate', 'adds the first search result for "cool music" to the front of the queue'],
['play cool music i', 'adds the first search result for "cool music" to the front of the queue'],
['play https://www.youtube.com/watch?list=PLi9drqWffJ9FWBo7ZVOiaVy0UQQEm4IbP shuffle', 'adds the shuffled playlist to the queue'],
['play https://www.youtube.com/watch?list=PLi9drqWffJ9FWBo7ZVOiaVy0UQQEm4IbP s', 'adds the shuffled playlist to the queue'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('play')
// TODO: make sure verb tense is consistent between all command descriptions
.setDescription('play a song or resume playback')
.addStringOption(option => option
.setName('query')
.setDescription('YouTube URL, Spotify URL, or search query')
.setAutocomplete(true))
.addBooleanOption(option => option
.setName('immediate')
.setDescription('add track to the front of the queue'))
.addBooleanOption(option => option
.setName('shuffle')
.setDescription('shuffle the input if you\'re adding multiple tracks'));
public requiresVC = true;
private readonly spotify: Spotify;
private readonly cache: KeyValueCacheProvider;
private readonly addQueryToQueue: AddQueryToQueue;
private readonly playerManager: PlayerManager;
private readonly getSongs: GetSongs;
constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager, @inject(TYPES.Services.GetSongs) getSongs: GetSongs) {
constructor(@inject(TYPES.ThirdParty) thirdParty: ThirdParty, @inject(TYPES.KeyValueCache) cache: KeyValueCacheProvider, @inject(TYPES.Services.AddQueryToQueue) addQueryToQueue: AddQueryToQueue, @inject(TYPES.Managers.Player) playerManager: PlayerManager) {
this.spotify = thirdParty.spotify;
this.cache = cache;
this.addQueryToQueue = addQueryToQueue;
this.playerManager = playerManager;
this.getSongs = getSongs;
}
// eslint-disable-next-line complexity
public async execute(msg: Message, args: string[]): Promise<void> {
const [targetVoiceChannel] = getMemberVoiceChannel(msg.member!) ?? getMostPopularVoiceChannel(msg.guild!);
const setting = await prisma.setting.findUnique({
where: {
guildId: msg.guild!.id,
}});
if (!setting) {
throw new Error(`Couldn't find settings for guild ${msg.guild!.id}`);
}
public async execute(interaction: CommandInteraction): Promise<void> {
const query = interaction.options.getString('query');
const {playlistLimit} = setting;
const player = this.playerManager.get(interaction.guild!.id);
const [targetVoiceChannel] = getMemberVoiceChannel(interaction.member as GuildMember) ?? getMostPopularVoiceChannel(interaction.guild!);
const res = new LoadingMessage(msg.channel as TextChannel);
await res.start();
try {
const player = this.playerManager.get(msg.guild!.id);
const wasPlayingSong = player.getCurrent() !== null;
if (args.length === 0) {
if (player.status === STATUS.PLAYING) {
await res.stop(errorMsg('already playing, give me a song name'));
return;
}
// Must be resuming play
if (!wasPlayingSong) {
await res.stop(errorMsg('nothing to play'));
return;
}
await player.connect(targetVoiceChannel);
await player.play();
await Promise.all([
res.stop('the stop-and-go light is now green'),
msg.channel.send({embeds: [buildPlayingMessageEmbed(player)]}),
]);
return;
if (!query) {
if (player.status === STATUS.PLAYING) {
throw new Error('already playing, give me a song name');
}
const addToFrontOfQueue = args[args.length - 1] === 'i' || args[args.length - 1] === 'immediate';
const shuffleAdditions = args[args.length - 1] === 's' || args[args.length - 1] === 'shuffle';
let newSongs: Array<Except<QueuedSong, 'addedInChannelId' | 'requestedBy'>> = [];
let extraMsg = '';
// Test if it's a complete URL
try {
const url = new URL(args[0]);
const YOUTUBE_HOSTS = [
'www.youtube.com',
'youtu.be',
'youtube.com',
'music.youtube.com',
'www.music.youtube.com',
];
if (YOUTUBE_HOSTS.includes(url.host)) {
// YouTube source
if (url.searchParams.get('list')) {
// YouTube playlist
newSongs.push(...await this.getSongs.youtubePlaylist(url.searchParams.get('list')!));
} else {
// Single video
const song = await this.getSongs.youtubeVideo(url.href);
if (song) {
newSongs.push(song);
} else {
await res.stop(errorMsg('that doesn\'t exist'));
return;
}
}
} else if (url.protocol === 'spotify:' || url.host === 'open.spotify.com') {
const [convertedSongs, nSongsNotFound, totalSongs] = await this.getSongs.spotifySource(args[0], playlistLimit);
if (totalSongs > playlistLimit) {
extraMsg = `a random sample of ${playlistLimit} songs was taken`;
}
if (totalSongs > playlistLimit && nSongsNotFound !== 0) {
extraMsg += ' and ';
}
if (nSongsNotFound !== 0) {
if (nSongsNotFound === 1) {
extraMsg += '1 song was not found';
} else {
extraMsg += `${nSongsNotFound.toString()} songs were not found`;
}
}
newSongs.push(...convertedSongs);
}
} catch (_: unknown) {
// Not a URL, must search YouTube
const query = addToFrontOfQueue ? args.slice(0, args.length - 1).join(' ') : args.join(' ');
const song = await this.getSongs.youtubeVideoSearch(query);
if (song) {
newSongs.push(song);
} else {
await res.stop(errorMsg('that doesn\'t exist'));
return;
}
// Must be resuming play
if (!player.getCurrent()) {
throw new Error('nothing to play');
}
if (newSongs.length === 0) {
await res.stop(errorMsg('no songs found'));
return;
}
await player.connect(targetVoiceChannel);
await player.play();
if (shuffleAdditions) {
newSongs = shuffle(newSongs);
}
newSongs.forEach(song => {
player.add({...song, addedInChannelId: msg.channel.id, requestedBy: msg.author.id}, {immediate: addToFrontOfQueue});
await interaction.reply({
content: 'the stop-and-go light is now green',
embeds: [buildPlayingMessageEmbed(player)],
});
const firstSong = newSongs[0];
let statusMsg = '';
if (player.voiceConnection === null) {
await player.connect(targetVoiceChannel);
// Resume / start playback
await player.play();
if (wasPlayingSong) {
statusMsg = 'resuming playback';
}
await msg.channel.send({embeds: [buildPlayingMessageEmbed(player)]});
}
// Build response message
if (statusMsg !== '') {
if (extraMsg === '') {
extraMsg = statusMsg;
} else {
extraMsg = `${statusMsg}, ${extraMsg}`;
}
}
if (extraMsg !== '') {
extraMsg = ` (${extraMsg})`;
}
if (newSongs.length === 1) {
await res.stop(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${extraMsg}`);
} else {
await res.stop(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`);
}
} catch (error) {
await res.stop();
throw error;
return;
}
await this.addQueryToQueue.addToQueue({
interaction,
query: query.trim(),
addToFrontOfQueue: interaction.options.getBoolean('immediate') ?? false,
shuffleAdditions: interaction.options.getBoolean('shuffle') ?? false,
});
}
public async handleAutocompleteInteraction(interaction: AutocompleteInteraction): Promise<void> {
const query = interaction.options.getString('query')?.trim();
if (!query || query.length === 0) {
await interaction.respond([]);
return;
}
try {
// Don't return suggestions for URLs
// eslint-disable-next-line no-new
new URL(query);
await interaction.respond([]);
return;
} catch {}
const suggestions = await this.cache.wrap(
getYouTubeAndSpotifySuggestionsFor,
query,
this.spotify,
10,
{
expiresIn: ONE_HOUR_IN_SECONDS,
key: `autocomplete:${query}`,
});
await interaction.respond(suggestions);
}
}

View file

@ -1,4 +1,5 @@
import {Message} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {inject, injectable} from 'inversify';
import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
@ -7,12 +8,13 @@ import {buildQueueEmbed} from '../utils/build-embed.js';
@injectable()
export default class implements Command {
public name = 'queue';
public aliases = ['q'];
public examples = [
['queue', 'shows current queue'],
['queue 2', 'shows second page of queue'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('queue')
.setDescription('show the current queue')
.addIntegerOption(option => option
.setName('page')
.setDescription('page of queue to show [default: 1]')
.setRequired(false));
private readonly playerManager: PlayerManager;
@ -20,11 +22,11 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, args: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
public async execute(interaction: CommandInteraction) {
const player = this.playerManager.get(interaction.guild!.id);
const embed = buildQueueEmbed(player, args[0] ? parseInt(args[0], 10) : 1);
const embed = buildQueueEmbed(player, interaction.options.getInteger('page') ?? 1);
await msg.channel.send({embeds: [embed]});
await interaction.reply({embeds: [embed]});
}
}

View file

@ -1,18 +1,24 @@
import {Message} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {inject, injectable} from 'inversify';
import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
import Command from '.';
import errorMsg from '../utils/error-msg.js';
import {SlashCommandBuilder} from '@discordjs/builders';
@injectable()
export default class implements Command {
public name = 'remove';
public aliases = ['rm'];
public examples = [
['remove 1', 'removes the next song in the queue'],
['rm 5-7', 'remove every song in range 5 - 7 (inclusive) from the queue'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('remove')
.setDescription('remove songs from the queue')
.addIntegerOption(option =>
option.setName('position')
.setDescription('position of the song to remove [default: 1]')
.setRequired(false),
)
.addIntegerOption(option =>
option.setName('range')
.setDescription('number of songs to remove [default: 1]')
.setRequired(false));
private readonly playerManager: PlayerManager;
@ -20,57 +26,22 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, args: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
public async execute(interaction: CommandInteraction): Promise<void> {
const player = this.playerManager.get(interaction.guild!.id);
if (args.length === 0) {
await msg.channel.send(errorMsg('missing song position or range'));
return;
const position = interaction.options.getInteger('position') ?? 1;
const range = interaction.options.getInteger('range') ?? 1;
if (position < 1) {
throw new Error('position must be at least 1');
}
const reg = /^(\d+)-(\d+)$|^(\d+)$/g; // Expression has 3 groups: x-y or z. x-y is range, z is a single digit.
const match = reg.exec(args[0]);
if (match === null) {
await msg.channel.send(errorMsg('incorrect format'));
return;
if (range < 1) {
throw new Error('range must be at least 1');
}
if (match[3] === undefined) { // 3rd group (z) doesn't exist -> a range
const range = [parseInt(match[1], 10), parseInt(match[2], 10)];
player.removeFromQueue(position, range);
if (range[0] < 1) {
await msg.channel.send(errorMsg('position must be greater than 0'));
return;
}
if (range[1] > player.queueSize()) {
await msg.channel.send(errorMsg('position is outside of the queue\'s range'));
return;
}
if (range[0] < range[1]) {
player.removeFromQueue(range[0], range[1] - range[0] + 1);
} else {
await msg.channel.send(errorMsg('range is backwards'));
return;
}
} else { // 3rd group exists -> just one song
const index = parseInt(match[3], 10);
if (index < 1) {
await msg.channel.send(errorMsg('position must be greater than 0'));
return;
}
if (index > player.queueSize()) {
await msg.channel.send(errorMsg('position is outside of the queue\'s range'));
return;
}
player.removeFromQueue(index, 1);
}
await msg.channel.send(':wastebasket: removed');
await interaction.reply(':wastebasket: removed');
}
}

View file

@ -1,21 +1,21 @@
import {Message, TextChannel} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
import LoadingMessage from '../utils/loading-message.js';
import errorMsg from '../utils/error-msg.js';
import Command from '.';
import {parseTime} from '../utils/time.js';
import {parseTime, prettyTime} from '../utils/time.js';
import {SlashCommandBuilder} from '@discordjs/builders';
@injectable()
export default class implements Command {
public name = 'seek';
public aliases = [];
public examples = [
['seek 10', 'seeks to 10 seconds from beginning of song'],
['seek 1:30', 'seeks to 1 minute and 30 seconds from beginning of song'],
['seek 1:00:00', 'seeks to 1 hour from beginning of song'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('seek')
.setDescription('seek to a position from beginning of song')
.addStringOption(option =>
option.setName('time')
.setDescription('time to seek')
.setRequired(true),
);
public requiresVC = true;
@ -25,22 +25,20 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, args: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
public async execute(interaction: CommandInteraction): Promise<void> {
const player = this.playerManager.get(interaction.guild!.id);
const currentSong = player.getCurrent();
if (!currentSong) {
await msg.channel.send(errorMsg('nothing is playing'));
return;
throw new Error('nothing is playing');
}
if (currentSong.isLive) {
await msg.channel.send(errorMsg('can\'t seek in a livestream'));
return;
throw new Error('can\'t seek in a livestream');
}
const time = args[0];
const time = interaction.options.getString('time')!;
let seekTime = 0;
@ -51,20 +49,14 @@ export default class implements Command {
}
if (seekTime > currentSong.length) {
await msg.channel.send(errorMsg('can\'t seek past the end of the song'));
return;
throw new Error('can\'t seek past the end of the song');
}
const loading = new LoadingMessage(msg.channel as TextChannel);
await Promise.all([
player.seek(seekTime),
interaction.deferReply(),
]);
await loading.start();
try {
await player.seek(seekTime);
await loading.stop();
} catch (error: unknown) {
await loading.stop(errorMsg(error as Error));
}
await interaction.editReply(`👍 seeked to ${prettyTime(player.getPosition())}`);
}
}

View file

@ -1,128 +0,0 @@
import {Message} from 'discord.js';
import {injectable} from 'inversify';
import errorMsg from '../utils/error-msg.js';
import Command from '.';
import {prisma} from '../utils/db.js';
@injectable()
export default class implements Command {
public name = 'shortcuts';
public aliases = [];
public examples = [
['shortcuts', 'show all shortcuts'],
['shortcuts set s skip', 'aliases `s` to `skip`'],
['shortcuts set party play https://www.youtube.com/watch?v=zK6oOJ1wz8k', 'aliases `party` to a specific play command'],
['shortcuts delete party', 'removes the `party` shortcut'],
];
public async execute(msg: Message, args: string []): Promise<void> {
if (args.length === 0) {
// Get shortcuts for guild
const shortcuts = await prisma.shortcut.findMany({
where: {
guildId: msg.guild!.id,
},
});
if (shortcuts.length === 0) {
await msg.channel.send('no shortcuts exist');
return;
}
// Get prefix for guild
const settings = await prisma.setting.findUnique({
where: {
guildId: msg.guild!.id,
},
});
if (!settings) {
return;
}
const {prefix} = settings;
const res = shortcuts.reduce((accum, shortcut) => {
accum += `${prefix}${shortcut.shortcut}: ${shortcut.command}\n`;
return accum;
}, '');
await msg.channel.send(res);
} else {
const action = args[0];
const shortcutName = args[1];
switch (action) {
case 'set': {
const shortcut = await prisma.shortcut.findFirst({
where: {
guildId: msg.guild!.id,
shortcut: shortcutName,
},
});
const command = args.slice(2).join(' ');
const newShortcut = {shortcut: shortcutName, command, guildId: msg.guild!.id, authorId: msg.author.id};
if (shortcut) {
if (shortcut.authorId !== msg.author.id && msg.author.id !== msg.guild!.ownerId) {
await msg.channel.send(errorMsg('you do\'nt have permission to do that'));
return;
}
await prisma.shortcut.update({
where: {
id: shortcut.id,
},
data: newShortcut,
});
await msg.channel.send('shortcut updated');
} else {
await prisma.shortcut.create({data: newShortcut});
await msg.channel.send('shortcut created');
}
break;
}
case 'delete': {
// Check if shortcut exists
const shortcut = await prisma.shortcut.findFirst({
where: {
guildId: msg.guild!.id,
shortcut: shortcutName,
},
});
if (!shortcut) {
await msg.channel.send(errorMsg('shortcut doesn\'t exist'));
return;
}
// Check permissions
if (shortcut.authorId !== msg.author.id && msg.author.id !== msg.guild!.ownerId) {
await msg.channel.send(errorMsg('you don\'t have permission to do that'));
return;
}
await prisma.shortcut.delete({
where: {
id: shortcut.id,
},
});
await msg.channel.send('shortcut deleted');
break;
}
default: {
await msg.channel.send(errorMsg('unknown command'));
}
}
}
}
}

View file

@ -1,17 +1,15 @@
import {Message} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
import errorMsg from '../utils/error-msg.js';
import Command from '.';
import {SlashCommandBuilder} from '@discordjs/builders';
@injectable()
export default class implements Command {
public name = 'shuffle';
public aliases = [];
public examples = [
['shuffle', 'shuffles the current queue'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('shuffle')
.setDescription('shuffles the current queue');
public requiresVC = true;
@ -21,16 +19,15 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, _: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
public async execute(interaction: CommandInteraction): Promise<void> {
const player = this.playerManager.get(interaction.guild!.id);
if (player.isQueueEmpty()) {
await msg.channel.send(errorMsg('not enough songs to shuffle'));
return;
throw new Error('not enough songs to shuffle');
}
player.shuffle();
await msg.channel.send('shuffled');
await interaction.reply('shuffled');
}
}

View file

@ -1,20 +1,20 @@
import {Message, TextChannel} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
import Command from '.';
import LoadingMessage from '../utils/loading-message.js';
import errorMsg from '../utils/error-msg.js';
import {SlashCommandBuilder} from '@discordjs/builders';
import {buildPlayingMessageEmbed} from '../utils/build-embed.js';
@injectable()
export default class implements Command {
public name = 'skip';
public aliases = ['s'];
public examples = [
['skip', 'skips the current song'],
['skip 2', 'skips the next 2 songs'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('skip')
.setDescription('skips the next songs')
.addIntegerOption(option => option
.setName('number')
.setDescription('number of songs to skip [default: 1]')
.setRequired(false));
public requiresVC = true;
@ -24,37 +24,23 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, args: string []): Promise<void> {
let numToSkip = 1;
public async execute(interaction: CommandInteraction): Promise<void> {
const numToSkip = interaction.options.getInteger('skip') ?? 1;
if (args.length === 1) {
if (!Number.isNaN(parseInt(args[0], 10))) {
numToSkip = parseInt(args[0], 10);
}
if (numToSkip < 1) {
throw new Error('invalid number of songs to skip');
}
const player = this.playerManager.get(msg.guild!.id);
const loader = new LoadingMessage(msg.channel as TextChannel);
const player = this.playerManager.get(interaction.guild!.id);
try {
await loader.start();
await player.forward(numToSkip);
await interaction.reply({
content: 'keep \'er movin\'',
embeds: player.getCurrent() ? [buildPlayingMessageEmbed(player)] : [],
});
} catch (_: unknown) {
await loader.stop(errorMsg('no song to skip to'));
return;
throw new Error('no song to skip to');
}
const promises = [
loader.stop('keep \'er movin\''),
];
if (player.getCurrent()) {
promises.push(msg.channel.send({
embeds: [buildPlayingMessageEmbed(player)],
}));
}
await Promise.all(promises);
}
}

View file

@ -1,18 +1,16 @@
import {Message} from 'discord.js';
import {CommandInteraction} from 'discord.js';
import {TYPES} from '../types.js';
import {inject, injectable} from 'inversify';
import PlayerManager from '../managers/player.js';
import errorMsg from '../utils/error-msg.js';
import Command from '.';
import {SlashCommandBuilder} from '@discordjs/builders';
import {buildPlayingMessageEmbed} from '../utils/build-embed.js';
@injectable()
export default class implements Command {
public name = 'unskip';
public aliases = ['back'];
public examples = [
['unskip', 'goes back in the queue by one song'],
];
public readonly slashCommand = new SlashCommandBuilder()
.setName('unskip')
.setDescription('goes back in the queue by one song');
public requiresVC = true;
@ -22,19 +20,17 @@ export default class implements Command {
this.playerManager = playerManager;
}
public async execute(msg: Message, _: string []): Promise<void> {
const player = this.playerManager.get(msg.guild!.id);
public async execute(interaction: CommandInteraction): Promise<void> {
const player = this.playerManager.get(interaction.guild!.id);
try {
await player.back();
await interaction.reply({
content: 'back \'er up\'',
embeds: player.getCurrent() ? [buildPlayingMessageEmbed(player)] : [],
});
} catch (_: unknown) {
await msg.channel.send(errorMsg('no song to go back to'));
return;
throw new Error('no song to go back to');
}
await msg.channel.send({
content: 'back \'er up\'',
embeds: [buildPlayingMessageEmbed(player)],
});
}
}

View file

@ -1,10 +1,11 @@
import {Guild, TextChannel, Message, MessageReaction, User} from 'discord.js';
import emoji from 'node-emoji';
import pEvent from 'p-event';
import {chunk} from '../utils/arrays.js';
import {Guild, Client} from 'discord.js';
import container from '../inversify.config.js';
import Command from '../commands';
import {TYPES} from '../types.js';
import Config from '../services/config.js';
import {prisma} from '../utils/db.js';
const DEFAULT_PREFIX = '!';
import {REST} from '@discordjs/rest';
import {Routes} from 'discord-api-types/v9';
export default async (guild: Guild): Promise<void> => {
await prisma.setting.upsert({
@ -13,88 +14,26 @@ export default async (guild: Guild): Promise<void> => {
},
create: {
guildId: guild.id,
prefix: DEFAULT_PREFIX,
},
update: {
prefix: DEFAULT_PREFIX,
},
update: {},
});
const owner = await guild.client.users.fetch(guild.ownerId);
const config = container.get<Config>(TYPES.Config);
let firstStep = '👋 Hi!\n';
firstStep += 'I just need to ask a few questions before you start listening to music.\n\n';
firstStep += 'First, what channel should I listen to for music commands?\n\n';
// Setup slash commands
if (!config.REGISTER_COMMANDS_ON_BOT) {
const token = container.get<Config>(TYPES.Config).DISCORD_TOKEN;
const client = container.get<Client>(TYPES.Client);
const firstStepMsg = await owner.send(firstStep);
const rest = new REST({version: '9'}).setToken(token);
// Show emoji selector
interface EmojiChannel {
name: string;
id: string;
emoji: string;
await rest.put(
Routes.applicationGuildCommands(client.user!.id, guild.id),
{body: container.getAll<Command>(TYPES.Command).map(command => command.slashCommand.toJSON())},
);
}
const emojiChannels: EmojiChannel[] = [];
const owner = await guild.fetchOwner();
for (const [channelId, channel] of guild.channels.cache) {
if (channel.type === 'GUILD_TEXT') {
emojiChannels.push({
name: channel.name,
id: channelId,
emoji: emoji.random().emoji,
});
}
}
const sentMessageIds: string[] = [];
chunk(emojiChannels, 10).map(async chunk => {
let str = '';
for (const channel of chunk) {
str += `${channel.emoji}: #${channel.name}\n`;
}
const msg = await owner.send(str);
sentMessageIds.push(msg.id);
await Promise.all(chunk.map(async channel => msg.react(channel.emoji)));
});
// Wait for response from user
const [choice] = await pEvent(guild.client, 'messageReactionAdd', {
multiArgs: true,
filter: ([reaction, user]: [MessageReaction, User]) => sentMessageIds.includes(reaction.message.id) && user.id === owner.id,
});
const chosenChannel = emojiChannels.find(e => e.emoji === (choice as unknown as MessageReaction).emoji.name)!;
// Second setup step (get prefix)
let secondStep = `👍 Cool, I'll listen to **#${chosenChannel.name}** \n\n`;
secondStep += 'Last question: what character should I use for a prefix? Type a single character and hit enter.';
await owner.send(secondStep);
const prefixResponses = await firstStepMsg.channel.awaitMessages({filter: (r: Message) => r.content.length === 1, max: 1});
const prefixCharacter = prefixResponses.first()!.content;
// Save settings
await prisma.setting.update({
where: {
guildId: guild.id,
},
data: {
channel: chosenChannel.id,
prefix: prefixCharacter,
},
});
// Send welcome
const boundChannel = guild.client.channels.cache.get(chosenChannel.id) as TextChannel;
await boundChannel.send(`hey <@${owner.id}> try \`${prefixCharacter}play https://www.youtube.com/watch?v=dQw4w9WgXcQ\``);
await firstStepMsg.channel.send(`Sounds good. Check out **#${chosenChannel.name}** to get started.`);
await owner.send('👋 Hi! Someone (probably you) just invited me to a server you own. I can\'t be used by your server members until you complete setup by running /config set-role in your server.');
};

View file

@ -0,0 +1,10 @@
import {Guild} from 'discord.js';
import updatePermissionsForGuild from '../utils/update-permissions-for-guild.js';
const handleGuildUpdate = async (oldGuild: Guild, newGuild: Guild) => {
if (oldGuild.ownerId !== newGuild.ownerId) {
await updatePermissionsForGuild(newGuild);
}
};
export default handleGuildUpdate;

View file

@ -18,7 +18,7 @@ const startBot = async () => {
await container.get<FileCacheProvider>(TYPES.FileCache).cleanup();
await bot.listen();
await bot.register();
};
export {startBot};

View file

@ -8,23 +8,22 @@ import ConfigProvider from './services/config.js';
// Managers
import PlayerManager from './managers/player.js';
// Helpers
// Services
import AddQueryToQueue from './services/add-query-to-queue.js';
import GetSongs from './services/get-songs.js';
import NaturalLanguage from './services/natural-language-commands.js';
// Comands
import Command from './commands';
import Clear from './commands/clear.js';
import Config from './commands/config.js';
import Disconnect from './commands/disconnect.js';
import Favorites from './commands/favorites.js';
import ForwardSeek from './commands/fseek.js';
import Help from './commands/help.js';
import Pause from './commands/pause.js';
import Play from './commands/play.js';
import QueueCommand from './commands/queue.js';
import Remove from './commands/remove.js';
import Seek from './commands/seek.js';
import Shortcuts from './commands/shortcuts.js';
import Shuffle from './commands/shuffle.js';
import Skip from './commands/skip.js';
import Unskip from './commands/unskip.js';
@ -49,23 +48,22 @@ container.bind<Client>(TYPES.Client).toConstantValue(new Client({intents}));
// Managers
container.bind<PlayerManager>(TYPES.Managers.Player).to(PlayerManager).inSingletonScope();
// Helpers
// Services
container.bind<GetSongs>(TYPES.Services.GetSongs).to(GetSongs).inSingletonScope();
container.bind<NaturalLanguage>(TYPES.Services.NaturalLanguage).to(NaturalLanguage).inSingletonScope();
container.bind<AddQueryToQueue>(TYPES.Services.AddQueryToQueue).to(AddQueryToQueue).inSingletonScope();
// Commands
[
Clear,
Config,
Disconnect,
Favorites,
ForwardSeek,
Help,
Pause,
Play,
QueueCommand,
Remove,
Seek,
Shortcuts,
Shuffle,
Skip,
Unskip,

View file

@ -1,5 +1,4 @@
import {inject, injectable} from 'inversify';
import {Client} from 'discord.js';
import {TYPES} from '../types.js';
import Player from '../services/player.js';
import FileCacheProvider from '../services/file-cache.js';
@ -7,12 +6,10 @@ import FileCacheProvider from '../services/file-cache.js';
@injectable()
export default class {
private readonly guildPlayers: Map<string, Player>;
private readonly discordClient: Client;
private readonly fileCache: FileCacheProvider;
constructor(@inject(TYPES.FileCache) fileCache: FileCacheProvider, @inject(TYPES.Client) client: Client) {
constructor(@inject(TYPES.FileCache) fileCache: FileCacheProvider) {
this.guildPlayers = new Map();
this.discordClient = client;
this.fileCache = fileCache;
}
@ -20,7 +17,7 @@ export default class {
let player = this.guildPlayers.get(guildId);
if (!player) {
player = new Player(this.discordClient, this.fileCache);
player = new Player(this.fileCache, guildId);
this.guildPlayers.set(guildId, player);
}

View file

@ -2,12 +2,14 @@ import {DATA_DIR} from '../services/config.js';
import createDatabaseUrl from '../utils/create-database-url.js';
import {execa} from 'execa';
process.env.DATABASE_URL = createDatabaseUrl(DATA_DIR);
(async () => {
await execa(process.argv[2], process.argv.slice(3), {
preferLocal: true,
stderr: process.stderr,
stdout: process.stdout,
stdin: process.stdin,
env: {
DATABASE_URL: createDatabaseUrl(DATA_DIR),
},
});
})();

View file

@ -0,0 +1,155 @@
import {CommandInteraction, GuildMember} from 'discord.js';
import {inject, injectable} from 'inversify';
import {Except} from 'type-fest';
import shuffle from 'array-shuffle';
import {TYPES} from '../types.js';
import GetSongs from '../services/get-songs.js';
import {QueuedSong} from './player.js';
import PlayerManager from '../managers/player.js';
import {prisma} from '../utils/db.js';
import {buildPlayingMessageEmbed} from '../utils/build-embed.js';
import {getMemberVoiceChannel, getMostPopularVoiceChannel} from '../utils/channels.js';
@injectable()
export default class AddQueryToQueue {
constructor(@inject(TYPES.Services.GetSongs) private readonly getSongs: GetSongs, @inject(TYPES.Managers.Player) private readonly playerManager: PlayerManager) {}
public async addToQueue({
query,
addToFrontOfQueue,
shuffleAdditions,
interaction,
}: {
query: string;
addToFrontOfQueue: boolean;
shuffleAdditions: boolean;
interaction: CommandInteraction;
}): Promise<void> {
const guildId = interaction.guild!.id;
const player = this.playerManager.get(guildId);
const wasPlayingSong = player.getCurrent() !== null;
const [targetVoiceChannel] = getMemberVoiceChannel(interaction.member as GuildMember) ?? getMostPopularVoiceChannel(interaction.guild!);
const settings = await prisma.setting.findUnique({where: {guildId}});
if (!settings) {
throw new Error('Could not find settings for guild');
}
const {playlistLimit} = settings;
await interaction.deferReply();
let newSongs: Array<Except<QueuedSong, 'addedInChannelId' | 'requestedBy'>> = [];
let extraMsg = '';
// Test if it's a complete URL
try {
const url = new URL(query);
const YOUTUBE_HOSTS = [
'www.youtube.com',
'youtu.be',
'youtube.com',
'music.youtube.com',
'www.music.youtube.com',
];
if (YOUTUBE_HOSTS.includes(url.host)) {
// YouTube source
if (url.searchParams.get('list')) {
// YouTube playlist
newSongs.push(...await this.getSongs.youtubePlaylist(url.searchParams.get('list')!));
} else {
const song = await this.getSongs.youtubeVideo(url.href);
if (song) {
newSongs.push(song);
} else {
throw new Error('that doesn\'t exist');
}
}
} else if (url.protocol === 'spotify:' || url.host === 'open.spotify.com') {
const [convertedSongs, nSongsNotFound, totalSongs] = await this.getSongs.spotifySource(query, playlistLimit);
if (totalSongs > playlistLimit) {
extraMsg = `a random sample of ${playlistLimit} songs was taken`;
}
if (totalSongs > playlistLimit && nSongsNotFound !== 0) {
extraMsg += ' and ';
}
if (nSongsNotFound !== 0) {
if (nSongsNotFound === 1) {
extraMsg += '1 song was not found';
} else {
extraMsg += `${nSongsNotFound.toString()} songs were not found`;
}
}
newSongs.push(...convertedSongs);
}
} catch (_: unknown) {
// Not a URL, must search YouTube
const song = await this.getSongs.youtubeVideoSearch(query);
if (song) {
newSongs.push(song);
} else {
throw new Error('that doesn\'t exist');
}
}
if (newSongs.length === 0) {
throw new Error('no songs found');
}
if (shuffleAdditions) {
newSongs = shuffle(newSongs);
}
newSongs.forEach(song => {
player.add({...song, addedInChannelId: interaction.channel!.id, requestedBy: interaction.member!.user.id}, {immediate: addToFrontOfQueue ?? false});
});
const firstSong = newSongs[0];
let statusMsg = '';
if (player.voiceConnection === null) {
await player.connect(targetVoiceChannel);
// Resume / start playback
await player.play();
if (wasPlayingSong) {
statusMsg = 'resuming playback';
}
await interaction.editReply({
embeds: [buildPlayingMessageEmbed(player)],
});
}
// Build response message
if (statusMsg !== '') {
if (extraMsg === '') {
extraMsg = statusMsg;
} else {
extraMsg = `${statusMsg}, ${extraMsg}`;
}
}
if (extraMsg !== '') {
extraMsg = ` (${extraMsg})`;
}
if (newSongs.length === 1) {
await interaction.editReply(`u betcha, **${firstSong.title}** added to the${addToFrontOfQueue ? ' front of the' : ''} queue${extraMsg}`);
} else {
await interaction.editReply(`u betcha, **${firstSong.title}** and ${newSongs.length - 1} other songs were added to the queue${extraMsg}`);
}
}
}

View file

@ -13,6 +13,7 @@ const CONFIG_MAP = {
YOUTUBE_API_KEY: process.env.YOUTUBE_API_KEY,
SPOTIFY_CLIENT_ID: process.env.SPOTIFY_CLIENT_ID,
SPOTIFY_CLIENT_SECRET: process.env.SPOTIFY_CLIENT_SECRET,
REGISTER_COMMANDS_ON_BOT: process.env.REGISTER_COMMANDS_ON_BOT === 'true',
DATA_DIR,
CACHE_DIR: path.join(DATA_DIR, 'cache'),
CACHE_LIMIT_IN_BYTES: xbytes.parseSize(process.env.CACHE_LIMIT ?? '2GB'),
@ -24,6 +25,7 @@ export default class Config {
readonly YOUTUBE_API_KEY!: string;
readonly SPOTIFY_CLIENT_ID!: string;
readonly SPOTIFY_CLIENT_SECRET!: string;
readonly REGISTER_COMMANDS_ON_BOT!: boolean;
readonly DATA_DIR!: string;
readonly CACHE_DIR!: string;
readonly CACHE_LIMIT_IN_BYTES!: number;
@ -39,6 +41,8 @@ export default class Config {
this[key as ConditionalKeys<typeof CONFIG_MAP, number>] = value;
} else if (typeof value === 'string') {
this[key as ConditionalKeys<typeof CONFIG_MAP, string>] = value.trim();
} else if (typeof value === 'boolean') {
this[key as ConditionalKeys<typeof CONFIG_MAP, boolean>] = value;
} else {
throw new Error(`Unsupported type for ${key}`);
}

View file

@ -15,12 +15,10 @@ import {cleanUrl} from '../utils/url.js';
import ThirdParty from './third-party.js';
import Config from './config.js';
import KeyValueCacheProvider from './key-value-cache.js';
import {ONE_HOUR_IN_SECONDS, ONE_MINUTE_IN_SECONDS} from '../utils/constants.js';
type SongMetadata = Except<QueuedSong, 'addedInChannelId' | 'requestedBy'>;
const ONE_HOUR_IN_SECONDS = 60 * 60;
const ONE_MINUTE_IN_SECONDS = 1 * 60;
@injectable()
export default class {
private readonly youtube: YouTube;

View file

@ -1,131 +0,0 @@
import {inject, injectable} from 'inversify';
import {Message, Guild, GuildMember} from 'discord.js';
import {TYPES} from '../types.js';
import PlayerManager from '../managers/player.js';
import {QueuedSong} from '../services/player.js';
import {getMostPopularVoiceChannel, getMemberVoiceChannel} from '../utils/channels.js';
@injectable()
export default class {
private readonly playerManager: PlayerManager;
constructor(@inject(TYPES.Managers.Player) playerManager: PlayerManager) {
this.playerManager = playerManager;
}
async execute(msg: Message): Promise<boolean> {
if (msg.content.startsWith('say') && msg.content.endsWith('muse')) {
const res = msg.content.slice(3, msg.content.indexOf('muse')).trim();
await msg.channel.send(res);
return true;
}
if (msg.content.toLowerCase().includes('packers')) {
await Promise.all([
msg.channel.send('GO PACKERS GO!!!'),
this.playClip(msg.guild!, msg.member!, {
title: 'GO PACKERS!',
artist: 'Unknown',
url: 'https://www.youtube.com/watch?v=qkdtID7mY3E',
length: 204,
playlist: null,
isLive: false,
addedInChannelId: msg.channel.id,
thumbnailUrl: null,
requestedBy: msg.author.id,
}, 8, 10),
]);
return true;
}
if (msg.content.toLowerCase().includes('bears')) {
await Promise.all([
msg.channel.send('F*** THE BEARS'),
this.playClip(msg.guild!, msg.member!, {
title: 'GO PACKERS!',
artist: 'Charlie Berens',
url: 'https://www.youtube.com/watch?v=UaqlE9Pyy_Q',
length: 385,
playlist: null,
isLive: false,
addedInChannelId: msg.channel.id,
thumbnailUrl: null,
requestedBy: msg.author.id,
}, 358, 5.5),
]);
return true;
}
if (msg.content.toLowerCase().includes('bitconnect')) {
await Promise.all([
msg.channel.send('🌊 🌊 🌊 🌊'),
this.playClip(msg.guild!, msg.member!, {
title: 'BITCONNEEECCT',
artist: 'Carlos Matos',
url: 'https://www.youtube.com/watch?v=lCcwn6bGUtU',
length: 227,
playlist: null,
isLive: false,
addedInChannelId: msg.channel.id,
thumbnailUrl: null,
requestedBy: msg.author.id,
}, 50, 13),
]);
return true;
}
return false;
}
private async playClip(guild: Guild, member: GuildMember, song: QueuedSong, position: number, duration: number): Promise<void> {
const player = this.playerManager.get(guild.id);
const [channel, n] = getMemberVoiceChannel(member) ?? getMostPopularVoiceChannel(guild);
if (!player.voiceConnection && n === 0) {
return;
}
if (!player.voiceConnection) {
await player.connect(channel);
}
const isPlaying = player.getCurrent() !== null;
let oldPosition = 0;
player.add(song, {immediate: true});
if (isPlaying) {
oldPosition = player.getPosition();
player.manualForward(1);
}
await player.seek(position);
return new Promise((resolve, reject) => {
try {
setTimeout(async () => {
if (player.getCurrent()?.title === song.title) {
player.removeCurrent();
if (isPlaying) {
await player.back();
await player.seek(oldPosition);
} else {
player.disconnect();
}
}
resolve();
}, duration * 1000);
} catch (error: unknown) {
reject(error);
}
});
}
}

View file

@ -1,13 +1,13 @@
import {VoiceChannel, Snowflake, Client, TextChannel} from 'discord.js';
import {VoiceChannel, Snowflake} from 'discord.js';
import {Readable} from 'stream';
import hasha from 'hasha';
import ytdl from 'ytdl-core';
import {WriteStream} from 'fs-capacitor';
import ffmpeg from 'fluent-ffmpeg';
import shuffle from 'array-shuffle';
import errorMsg from '../utils/error-msg.js';
import {AudioPlayer, AudioPlayerStatus, createAudioPlayer, createAudioResource, joinVoiceChannel, StreamType, VoiceConnection, VoiceConnectionStatus} from '@discordjs/voice';
import FileCacheProvider from './file-cache.js';
import debug from '../utils/debug.js';
export interface QueuedPlaylist {
title: string;
@ -31,9 +31,15 @@ export enum STATUS {
PAUSED,
}
export interface PlayerEvents {
statusChange: (oldStatus: STATUS, newStatus: STATUS) => void;
}
export default class {
public status = STATUS.PAUSED;
public voiceConnection: VoiceConnection | null = null;
public status = STATUS.PAUSED;
public guildId: string;
private queue: QueuedSong[] = [];
private queuePosition = 0;
private audioPlayer: AudioPlayer | null = null;
@ -43,12 +49,11 @@ export default class {
private positionInSeconds = 0;
private readonly discordClient: Client;
private readonly fileCache: FileCacheProvider;
constructor(client: Client, fileCache: FileCacheProvider) {
this.discordClient = client;
constructor(fileCache: FileCacheProvider, guildId: string) {
this.fileCache = fileCache;
this.guildId = guildId;
}
async connect(channel: VoiceChannel): Promise<void> {
@ -150,9 +155,11 @@ export default class {
},
});
this.voiceConnection.subscribe(this.audioPlayer);
this.audioPlayer.play(createAudioResource(stream, {
const resource = createAudioResource(stream, {
inputType: StreamType.WebmOpus,
}));
});
this.audioPlayer.play(resource);
this.attachListeners();
@ -167,14 +174,13 @@ export default class {
this.lastSongURL = currentSong.url;
}
} catch (error: unknown) {
const currentSong = this.getCurrent();
await this.forward(1);
if ((error as {statusCode: number}).statusCode === 410 && currentSong) {
const channelId = currentSong.addedInChannelId;
if (channelId) {
await (this.discordClient.channels.cache.get(channelId) as TextChannel).send(errorMsg(`${currentSong.title} is unavailable`));
debug(`${currentSong.title} is unavailable`);
return;
}
}
@ -213,8 +219,12 @@ export default class {
}
}
canGoForward(skip: number) {
return (this.queuePosition + skip - 1) < this.queue.length;
}
manualForward(skip: number): void {
if ((this.queuePosition + skip - 1) < this.queue.length) {
if (this.canGoForward(skip)) {
this.queuePosition += skip;
this.positionInSeconds = 0;
this.stopTrackingPosition();
@ -223,8 +233,12 @@ export default class {
}
}
canGoBack() {
return this.queuePosition - 1 >= 0;
}
async back(): Promise<void> {
if (this.queuePosition - 1 >= 0) {
if (this.canGoBack()) {
this.queuePosition--;
this.positionInSeconds = 0;
this.stopTrackingPosition();
@ -397,6 +411,9 @@ export default class {
.on('error', error => {
console.error(error);
reject(error);
})
.on('start', command => {
debug(`Spawned ffmpeg with ${command as string}`);
});
youtubeStream.pipe(capacitor);

View file

@ -8,9 +8,10 @@ export const TYPES = {
ThirdParty: Symbol('ThirdParty'),
Managers: {
Player: Symbol('PlayerManager'),
UpdatingQueueEmbed: Symbol('UpdatingQueueEmbed'),
},
Services: {
AddQueryToQueue: Symbol('AddQueryToQueue'),
GetSongs: Symbol('GetSongs'),
NaturalLanguage: Symbol('NaturalLanguage'),
},
};

2
src/utils/constants.ts Normal file
View file

@ -0,0 +1,2 @@
export const ONE_HOUR_IN_SECONDS = 60 * 60;
export const ONE_MINUTE_IN_SECONDS = 1 * 60;

View file

@ -5,7 +5,7 @@ export default (error?: string | Error): string => {
if (typeof error === 'string') {
str = `🚫 ${error}`;
} else if (error instanceof Error) {
str = `🚫 ope: ${error.name}`;
str = `🚫 ope: ${error.message}`;
}
}

View file

@ -0,0 +1,70 @@
import {ApplicationCommandOptionChoice} from 'discord.js';
import SpotifyWebApi from 'spotify-web-api-node';
import getYouTubeSuggestionsFor from './get-youtube-suggestions-for.js';
const filterDuplicates = <T extends {name: string}>(items: T[]) => {
const results: T[] = [];
for (const item of items) {
if (!results.some(result => result.name === item.name)) {
results.push(item);
}
}
return results;
};
const getYouTubeAndSpotifySuggestionsFor = async (query: string, spotify: SpotifyWebApi, limit = 10): Promise<ApplicationCommandOptionChoice[]> => {
const [youtubeSuggestions, spotifyResults] = await Promise.all([
getYouTubeSuggestionsFor(query),
spotify.search(query, ['track', 'album'], {limit: 5}),
]);
const totalYouTubeResults = youtubeSuggestions.length;
const spotifyAlbums = filterDuplicates(spotifyResults.body.albums?.items ?? []);
const spotifyTracks = filterDuplicates(spotifyResults.body.tracks?.items ?? []);
const totalSpotifyResults = spotifyAlbums.length + spotifyTracks.length;
// Number of results for each source should be roughly the same.
// If we don't have enough Spotify suggestions, prioritize YouTube results.
const maxSpotifySuggestions = Math.floor(limit / 2);
const numOfSpotifySuggestions = Math.min(maxSpotifySuggestions, totalSpotifyResults);
const maxYouTubeSuggestions = limit - numOfSpotifySuggestions;
const numOfYouTubeSuggestions = Math.min(maxYouTubeSuggestions, totalYouTubeResults);
const suggestions: ApplicationCommandOptionChoice[] = [];
suggestions.push(
...youtubeSuggestions
.slice(0, numOfYouTubeSuggestions)
.map(suggestion => ({
name: `YouTube: ${suggestion}`,
value: suggestion,
}),
));
const maxSpotifyAlbums = Math.floor(numOfSpotifySuggestions / 2);
const numOfSpotifyAlbums = Math.min(maxSpotifyAlbums, spotifyResults.body.albums?.items.length ?? 0);
const maxSpotifyTracks = numOfSpotifySuggestions - numOfSpotifyAlbums;
suggestions.push(
...spotifyAlbums.slice(0, maxSpotifyAlbums).map(album => ({
name: `Spotify: 💿 ${album.name}${album.artists.length > 0 ? ` - ${album.artists[0].name}` : ''}`,
value: `spotify:album:${album.id}`,
})),
);
suggestions.push(
...spotifyTracks.slice(0, maxSpotifyTracks).map(track => ({
name: `Spotify: 🎵 ${track.name}${track.artists.length > 0 ? ` - ${track.artists[0].name}` : ''}`,
value: `spotify:track:${track.id}`,
})),
);
return suggestions;
};
export default getYouTubeAndSpotifySuggestionsFor;

View file

@ -0,0 +1,15 @@
import got from 'got';
const getYouTubeSuggestionsFor = async (query: string): Promise<string[]> => {
const [_, suggestions] = await got('https://suggestqueries.google.com/complete/search?client=firefox&ds=yt&q=', {
searchParams: {
client: 'firefox',
ds: 'yt',
q: query,
},
}).json<[string, string[]]>();
return suggestions;
};
export default getYouTubeSuggestionsFor;

View file

@ -1,81 +0,0 @@
import {TextChannel, Message, MessageReaction} from 'discord.js';
import delay from 'delay';
const INITAL_DELAY = 500;
const PERIOD = 500;
export default class {
public isStopped = true;
private readonly channel: TextChannel;
private readonly text: string;
private msg!: Message;
constructor(channel: TextChannel, text = 'cows! count \'em') {
this.channel = channel;
this.text = text;
}
async start(): Promise<void> {
this.msg = await this.channel.send(this.text);
const icons = ['🐮', '🐴', '🐄'];
const reactions: MessageReaction[] = [];
let i = 0;
let isRemoving = false;
this.isStopped = false;
(async () => {
await delay(INITAL_DELAY);
while (!this.isStopped) {
if (reactions.length === icons.length) {
isRemoving = true;
}
// eslint-disable-next-line no-await-in-loop
await delay(PERIOD);
if (isRemoving) {
const reactionToRemove = reactions.shift();
if (reactionToRemove) {
// eslint-disable-next-line no-await-in-loop
await reactionToRemove.users.remove(this.msg.client.user!.id);
} else {
isRemoving = false;
}
} else {
if (!this.isStopped) {
// eslint-disable-next-line no-await-in-loop
reactions.push(await this.msg.react(icons[i % icons.length]));
}
i++;
}
}
})();
}
async stop(str = 'u betcha'): Promise<Message> {
const wasAlreadyStopped = this.isStopped;
this.isStopped = true;
const editPromise = str ? this.msg.edit(str) : null;
const reactPromise = str && !wasAlreadyStopped ? (async () => {
await this.msg.fetch();
await Promise.all(this.msg.reactions.cache.map(async react => {
if (react.me) {
await react.users.remove(this.msg.client.user!.id);
}
}));
})() : null;
await Promise.all([editPromise, reactPromise]);
return this.msg;
}
}

View file

@ -9,6 +9,7 @@ const logBanner = () => {
paypalUser: 'codetheweb',
githubSponsor: 'codetheweb',
madeByPrefix: 'Made with 🎶 by ',
buildDate: process.env.BUILD_DATE ? new Date(process.env.BUILD_DATE) : undefined,
}).join('\n'));
console.log('\n');
};

View file

@ -0,0 +1,44 @@
import {ApplicationCommandPermissionData, Guild} from 'discord.js';
import {prisma} from './db.js';
const COMMANDS_TO_LIMIT_TO_GUILD_OWNER = ['config'];
const updatePermissionsForGuild = async (guild: Guild) => {
const settings = await prisma.setting.findUnique({
where: {
guildId: guild.id,
},
});
if (!settings) {
throw new Error('could not find settings for guild');
}
const permissions: ApplicationCommandPermissionData[] = [
{
id: guild.ownerId,
type: 'USER',
permission: true,
},
{
id: guild.roles.everyone.id,
type: 'ROLE',
permission: false,
},
];
const commands = await guild.commands.fetch();
await guild.commands.permissions.set({fullPermissions: commands.map(command => ({
id: command.id,
permissions: COMMANDS_TO_LIMIT_TO_GUILD_OWNER.includes(command.name) ? permissions : [
...permissions,
...(settings.roleId ? [{
id: settings.roleId,
type: 'ROLE' as const,
permission: true,
}] : []),
],
}))});
};
export default updatePermissionsForGuild;

View file

@ -1,6 +1,6 @@
{
"compilerOptions": {
"lib": ["ES2019"],
"lib": ["ES2019", "DOM"],
"target": "es2018",
"module": "ES2020",
"moduleResolution": "node",

292
yarn.lock
View file

@ -22,9 +22,9 @@
integrity sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==
"@babel/highlight@^7.10.4", "@babel/highlight@^7.16.7":
version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.7.tgz#81a01d7d675046f0d96f82450d9d9578bdfd6b0b"
integrity sha512-aKpPMfLvGO3Q97V0qhw/V2SWNWlwfJknuwAunU7wZLSfrM4xTBvg7E5opUVi1kJTBKihE38CPg4nBiqX83PWYw==
version "7.16.10"
resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.10.tgz#744f2eb81579d6eea753c227b0f570ad785aba88"
integrity sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==
dependencies:
"@babel/helper-validator-identifier" "^7.16.7"
chalk "^2.0.0"
@ -53,6 +53,17 @@
tslib "^2.3.1"
zod "^3.11.6"
"@discordjs/builders@^0.12.0":
version "0.12.0"
resolved "https://registry.yarnpkg.com/@discordjs/builders/-/builders-0.12.0.tgz#5f6d95d1b231fa975a7e28ca3f8098e517676887"
integrity sha512-Vx2MjUZd6QVo1uS2uWt708Fd6cHWGFblAvbpL5EBO+kLl0BADmPwwvts+YJ/VfSywed6Vsk6K2cEooR/Ytjhjw==
dependencies:
"@sindresorhus/is" "^4.3.0"
discord-api-types "^0.26.1"
ts-mixer "^6.0.0"
tslib "^2.3.1"
zod "^3.11.6"
"@discordjs/collection@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@discordjs/collection/-/collection-0.4.0.tgz#b6488286a1cc7b41b644d7e6086f25a1c1e6f837"
@ -81,6 +92,19 @@
"@discordjs/node-pre-gyp" "^0.4.2"
node-addon-api "^4.2.0"
"@discordjs/rest@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@discordjs/rest/-/rest-0.3.0.tgz#89e06a42b168c91598891d6bf860353e28fba5d2"
integrity sha512-F9aeP3odlAlllM1ciBZLdd+adiAyBj4VaZBejj4UMj4afE2wfCkNTGvYYiRxrXUE9fN7e/BuDP2ePl0tVA2m7Q==
dependencies:
"@discordjs/collection" "^0.4.0"
"@sapphire/async-queue" "^1.1.9"
"@sapphire/snowflake" "^3.0.1"
discord-api-types "^0.26.1"
form-data "^4.0.0"
node-fetch "^2.6.5"
tslib "^2.3.1"
"@discordjs/voice@^0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@discordjs/voice/-/voice-0.8.0.tgz#5d790fc25b883698f6eb7762efe1af00b6440947"
@ -221,15 +245,15 @@
once "^1.4.0"
"@octokit/request@^5.6.0":
version "5.6.2"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.2.tgz#1aa74d5da7b9e04ac60ef232edd9a7438dcf32d8"
integrity sha512-je66CvSEVf0jCpRISxkUcCa0UkxmFs6eGDRSbfJtAVwbLH5ceqF+YEyC8lj8ystKyZTy8adWr0qmkY52EfOeLA==
version "5.6.3"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0"
integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==
dependencies:
"@octokit/endpoint" "^6.0.1"
"@octokit/request-error" "^2.1.0"
"@octokit/types" "^6.16.1"
is-plain-object "^5.0.0"
node-fetch "^2.6.1"
node-fetch "^2.6.7"
universal-user-agent "^6.0.0"
"@octokit/rest@18.12.0":
@ -249,22 +273,22 @@
dependencies:
"@octokit/openapi-types" "^11.2.0"
"@prisma/client@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-3.7.0.tgz#9cafc105f12635c95e9b7e7b18e8fbf52cf3f18a"
integrity sha512-fUJMvBOX5C7JPc0e3CJD6Gbelbu4dMJB4ScYpiht8HMUnRShw20ULOipTopjNtl6ekHQJ4muI7pXlQxWS9nMbw==
"@prisma/client@^3.8.1":
version "3.8.1"
resolved "https://registry.yarnpkg.com/@prisma/client/-/client-3.8.1.tgz#c11eda8e84760867552ffde4de7b48fb2cf1e1c0"
integrity sha512-NxD1Xbkx1eT1mxSwo1RwZe665mqBETs0VxohuwNfFIxMqcp0g6d4TgugPxwZ4Jb4e5wCu8mQ9quMedhNWIWcZQ==
dependencies:
"@prisma/engines-version" "3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f"
"@prisma/engines-version" "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f"
"@prisma/engines-version@3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f":
version "3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f"
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f.tgz#055f36ac8b06c301332c14963cd0d6c795942c90"
integrity sha512-+qx2b+HK7BKF4VCa0LZ/t1QCXsu6SmvhUQyJkOD2aPpmOzket4fEnSKQZSB0i5tl7rwCDsvAiSeK8o7rf+yvwg==
"@prisma/engines-version@3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f":
version "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f"
resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f.tgz#4c8d9744b5e54650a8ba5fde0a711399d6adba24"
integrity sha512-G2JH6yWt6ixGKmsRmVgaQYahfwMopim0u/XLIZUo2o/mZ5jdu7+BL+2V5lZr7XiG1axhyrpvlyqE/c0OgYSl3g==
"@prisma/engines@3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f":
version "3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f"
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f.tgz#12f28d5b78519fbd84c89a5bdff457ff5095e7a2"
integrity sha512-W549ub5NlgexNhR8EFstA/UwAWq3Zq0w9aNkraqsozVCt2CsX+lK4TK7IW5OZVSnxHwRjrgEAt3r9yPy8nZQRg==
"@prisma/engines@3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f":
version "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f"
resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f.tgz#4479099b99f6a082ce5843ee7208943ccedd127f"
integrity sha512-bHYubuItSN/DGYo36aDu7xJiJmK52JOSHs4MK+KbceAtwS20BCWadRgtpQ3iZ2EXfN/B1T0iCXlNraaNwnpU2w==
"@release-it/keep-a-changelog@^2.3.0":
version "2.3.0"
@ -274,19 +298,24 @@
detect-newline "^3.1.0"
"@sapphire/async-queue@^1.1.9":
version "1.1.9"
resolved "https://registry.yarnpkg.com/@sapphire/async-queue/-/async-queue-1.1.9.tgz#ce69611c8753c4affd905a7ef43061c7eb95c01b"
integrity sha512-CbXaGwwlEMq+l1TRu01FJCvySJ1CEFKFclHT48nIfNeZXaAAmmwwy7scUKmYHPUa3GhoMp6Qr1B3eAJux6XgOQ==
version "1.2.0"
resolved "https://registry.yarnpkg.com/@sapphire/async-queue/-/async-queue-1.2.0.tgz#7a56afd318101d338433d7180ebd6af349243268"
integrity sha512-O5ND5Ljpef86X5oy8zXorQ754TMjWALcPSAgPBu4+76HLtDTrNoDyzU2uGE2G4A8Wv51u0MXHzGQ0WZ4GMtpIw==
"@sapphire/snowflake@^3.0.1":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@sapphire/snowflake/-/snowflake-3.1.0.tgz#1c2d9781d3b1de0bcb02b7079898947ce754d394"
integrity sha512-K+OiqXSx4clIaXcoaghrCV56zsm3bZZ5SBpgJkgvAKegFFdETMntHviUfypjt8xVleIuDaNyQA4APOIl3BMcxg==
"@sindresorhus/is@^0.14.0":
version "0.14.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea"
integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==
"@sindresorhus/is@^4.0.0", "@sindresorhus/is@^4.2.0":
version "4.2.1"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.2.1.tgz#b88b5724283db80b507cd612caee9a1947412a20"
integrity sha512-BrzrgtaqEre0qfvI8sMTaEvx+bayuhPmfe2rfeUGPPHYr/PLxCOqkOe4TQTDPb+qcqgNcsAtXV/Ew74mcDIE8w==
"@sindresorhus/is@^4.0.0", "@sindresorhus/is@^4.2.0", "@sindresorhus/is@^4.3.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.4.0.tgz#e277e5bdbdf7cb1e20d320f02f5e2ed113cd3185"
integrity sha512-QppPM/8l3Mawvh4rn9CNEYIU9bxpXUCRMaX9yUpvBk1nMKusLKpfXGDEKExKaPhLzcn3lzil7pR6rnJ11HgeRQ==
"@szmarczak/http-timer@^1.1.2":
version "1.1.2"
@ -406,9 +435,9 @@
form-data "^3.0.0"
"@types/node@*", "@types/node@^17.0.0":
version "17.0.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.8.tgz#50d680c8a8a78fe30abe6906453b21ad8ab0ad7b"
integrity sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==
version "17.0.13"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.13.tgz#5ed7ed7c662948335fcad6c412bb42d99ea754e3"
integrity sha512-Y86MAxASe25hNzlDbsviXl8jQHb0RDvKt4c40ZJQ1Don0AAL0STLZSs4N+6gLEO55pedy7r2cLwS+ZDxPm/2Bw==
"@types/parse-json@^4.0.0":
version "4.0.0"
@ -428,9 +457,9 @@
integrity sha512-rHmG4soR13N3jDCu0QL9cv6q3jMM/AU/0w5w7ukTt89e23rv5Vz86BNqXP/34wEzYWgiTNSG+f+xGT1rjABj4g==
"@types/spotify-web-api-node@^5.0.2":
version "5.0.4"
resolved "https://registry.yarnpkg.com/@types/spotify-web-api-node/-/spotify-web-api-node-5.0.4.tgz#457f3a82d08aa0a561f98ebc1d5f78228e3b0c5d"
integrity sha512-t2a0wqe/9ydzqPTvL6CKys8v3mS3jR942BqSlg2e9lOtskUFSim9pXwathV0A9MTout5dpeWC3jW1yNUzJhovg==
version "5.0.7"
resolved "https://registry.yarnpkg.com/@types/spotify-web-api-node/-/spotify-web-api-node-5.0.7.tgz#de5cb576781e0aaa38568744dfb891c86a7938ee"
integrity sha512-8ajd4xS3+l4Zau1OyggPv7DjeSFEIGYvG5Q8PbbBMKiaRFD53IkcvU4Bx4Ijyzw+l+Kc09L5L+MXRj0wyVLx9Q==
dependencies:
"@types/spotify-api" "*"
@ -559,9 +588,9 @@ ajv@^6.10.0, ajv@^6.12.4:
uri-js "^4.2.2"
ajv@^8.0.1:
version "8.8.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.8.2.tgz#01b4fef2007a28bf75f0b7fc009f62679de4abbb"
integrity sha512-x9VuX+R/jcFj1DHo/fCp99esgGDWiHENrKxaCENuCxpoMCmAt/COCGVDwA7kleEpEzJjDnvh3yGoOuLu0Dtllw==
version "8.9.0"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.9.0.tgz#738019146638824dea25edcf299dcba1b0e7eb18"
integrity sha512-qOKJyNj/h+OWx7s5DePL6Zu1KeM9jPZhwBqs+7DzP6bGOvqzVCSf0xueYmVuaC/oQ/VtS2zLMLHdQFbkka+XDQ==
dependencies:
fast-deep-equal "^3.1.1"
json-schema-traverse "^1.0.0"
@ -667,9 +696,9 @@ async-retry@1.3.3:
retry "0.13.1"
async@>=0.2.9:
version "3.2.2"
resolved "https://registry.yarnpkg.com/async/-/async-3.2.2.tgz#2eb7671034bb2194d45d30e31e24ec7e7f9670cd"
integrity sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g==
version "3.2.3"
resolved "https://registry.yarnpkg.com/async/-/async-3.2.3.tgz#ac53dafd3f4720ee9e8a160628f18ea91df196c9"
integrity sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==
asynckit@^0.4.0:
version "0.4.0"
@ -848,9 +877,9 @@ chardet@^0.7.0:
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==
chokidar@^3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75"
integrity sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==
version "3.5.3"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd"
integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
dependencies:
anymatch "~3.1.2"
braces "~3.0.2"
@ -1054,20 +1083,13 @@ date-fns@^2.16.1:
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.28.0.tgz#9570d656f5fc13143e50c975a3b6bbeb46cd08b2"
integrity sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw==
debug@4, debug@^4.0.1, debug@^4.1.1, debug@^4.3.1, debug@^4.3.3:
debug@4, debug@4.3.3, debug@^4.0.1, debug@^4.1.1, debug@^4.3.1, debug@^4.3.3:
version "4.3.3"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664"
integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==
dependencies:
ms "2.1.2"
debug@4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
dependencies:
ms "2.1.2"
debug@=3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
@ -1143,14 +1165,6 @@ delegates@^1.0.0:
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=
deprecated-obj@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/deprecated-obj/-/deprecated-obj-2.0.0.tgz#e6ba93a3989f6ed18d685e7d99fb8d469b4beffc"
integrity sha512-CkdywZC2rJ8RGh+y3MM1fw1EJ4oO/oNExGbRFv0AQoMS+faTd3nO7slYjkj/6t8OnIMUE+wxh6G97YHhK1ytrw==
dependencies:
flat "^5.0.2"
lodash "^4.17.20"
deprecation@^2.0.0, deprecation@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
@ -1467,10 +1481,10 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==
fast-glob@^3.1.1:
version "3.2.8"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.8.tgz#b4c563b4750cee1cbe8d8d41d3abf5cd6e211923"
integrity sha512-UsiHHXoDbC3iS7vBOFvld7Q9XqBu318xztdHiL10Fjov3AK5GI5bek2ZJkxZcjPguOYH39UL1W4A6w+l7tpNtw==
fast-glob@^3.1.1, fast-glob@^3.2.9:
version "3.2.11"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9"
integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==
dependencies:
"@nodelib/fs.stat" "^2.0.2"
"@nodelib/fs.walk" "^1.2.3"
@ -1549,15 +1563,10 @@ flat-cache@^3.0.4:
flatted "^3.1.0"
rimraf "^3.0.2"
flat@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==
flatted@^3.1.0:
version "3.2.4"
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.4.tgz#28d9969ea90661b5134259f312ab6aa7929ac5e2"
integrity sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw==
version "3.2.5"
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3"
integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==
fluent-ffmpeg@^2.1.2:
version "2.1.2"
@ -1735,7 +1744,7 @@ globals@^13.6.0, globals@^13.9.0:
dependencies:
type-fest "^0.20.2"
globby@11.0.4, globby@^11.0.3:
globby@11.0.4:
version "11.0.4"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5"
integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg==
@ -1747,6 +1756,18 @@ globby@11.0.4, globby@^11.0.3:
merge2 "^1.3.0"
slash "^3.0.0"
globby@^11.0.3:
version "11.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==
dependencies:
array-union "^2.1.0"
dir-glob "^3.0.1"
fast-glob "^3.2.9"
ignore "^5.2.0"
merge2 "^1.4.1"
slash "^3.0.0"
got@11.8.3:
version "11.8.3"
resolved "https://registry.yarnpkg.com/got/-/got-11.8.3.tgz#f496c8fdda5d729a90b4905d2b07dbd148170770"
@ -1765,9 +1786,9 @@ got@11.8.3:
responselike "^2.0.0"
got@^12.0.0:
version "12.0.0"
resolved "https://registry.yarnpkg.com/got/-/got-12.0.0.tgz#2ee3d5ff25eabc47dae975d376ddcee1d450bec1"
integrity sha512-gNNNghQ1yw0hyzie1FLK6gY90BQlXU9zSByyRygnbomHPruKQ6hAKKbpO1RfNZp8b+qNzNipGeRG3tUelKcVsA==
version "12.0.1"
resolved "https://registry.yarnpkg.com/got/-/got-12.0.1.tgz#78747f1c5bc7069bbd739636ed8b70c7f2140a39"
integrity sha512-1Zhoh+lDej3t7Ks1BP/Jufn+rNqdiHQgUOcTxHzg2Dao1LQfp5S4Iq0T3iBxN4Zdo7QqCJL+WJUNzDX6rCP2Ew==
dependencies:
"@sindresorhus/is" "^4.2.0"
"@szmarczak/http-timer" "^5.0.1"
@ -1932,7 +1953,7 @@ ignore@^4.0.6:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==
ignore@^5.1.4, ignore@^5.1.8:
ignore@^5.1.4, ignore@^5.1.8, ignore@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==
@ -2048,7 +2069,7 @@ is-ci@^2.0.0:
dependencies:
ci-info "^2.0.0"
is-core-module@^2.8.0:
is-core-module@^2.8.1:
version "2.8.1"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.1.tgz#f59fdfca701d5879d0a6b100a40aa1560ce27211"
integrity sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==
@ -2225,9 +2246,9 @@ keyv@^3.0.0:
json-buffer "3.0.0"
keyv@^4.0.0:
version "4.0.4"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.0.4.tgz#f040b236ea2b06ed15ed86fbef8407e1a1c8e376"
integrity sha512-vqNHbAc8BBsxk+7QBYLW0Y219rWcClspR6WSeoHYKG5mnsSoOH+BL1pWq02DDCVdvvuUny5rkBlzMRzoqc+GIg==
version "4.0.5"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.0.5.tgz#bb12b467aba372fab2a44d4420c00d3c4ebd484c"
integrity sha512-531pkGLqV3BMg0eDqqJFI0R1mkK1Nm5xIP2mM6keP5P8WfFtCkg2IOwplTUmlGoTgIg9yQYZ/kdihhz89XH3vA==
dependencies:
json-buffer "3.0.1"
@ -2280,7 +2301,7 @@ lodash.truncate@^4.4.2:
resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193"
integrity sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=
lodash@4.17.21, lodash@^4.17.20, lodash@^4.17.21:
lodash@4.17.21, lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
@ -2324,11 +2345,11 @@ lru-cache@^6.0.0:
yallist "^4.0.0"
m3u8stream@^0.8.4:
version "0.8.4"
resolved "https://registry.yarnpkg.com/m3u8stream/-/m3u8stream-0.8.4.tgz#15b49d0c2b510755ea43c1e53f85d7aaa4dc65c2"
integrity sha512-sco80Db+30RvcaIOndenX6E6oQNgTiBKeJbFPc+yDXwPQIkryfboEbCvXPlBRq3mQTCVPQO93TDVlfRwqpD35w==
version "0.8.6"
resolved "https://registry.yarnpkg.com/m3u8stream/-/m3u8stream-0.8.6.tgz#0d6de4ce8ee69731734e6b616e7b05dd9d9a55b1"
integrity sha512-LZj8kIVf9KCphiHmH7sbFQTVe4tOemb202fWwvJwR9W5ENW/1hxJN6ksAWGhQgSBSa3jyWhnjKU1Fw1GaOdbyA==
dependencies:
miniget "^4.0.0"
miniget "^4.2.2"
sax "^1.2.4"
macos-release@^2.5.0:
@ -2353,7 +2374,7 @@ merge-stream@^2.0.0:
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==
merge2@^1.3.0:
merge2@^1.3.0, merge2@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
@ -2408,10 +2429,10 @@ mimic-response@^3.1.0:
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-3.1.0.tgz#2d1d59af9c1b129815accc2c46a022a5ce1fa3c9"
integrity sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==
miniget@^4.0.0, miniget@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/miniget/-/miniget-4.2.1.tgz#11a1c24817a059e292378eb9cff4328d9240c665"
integrity sha512-O/DduzDR6f+oDtVype9S/Qu5hhnx73EDYGyZKwU/qN82lehFZdfhoa4DT51SpsO+8epYrB3gcRmws56ROfTIoQ==
miniget@^4.0.0, miniget@^4.2.1, miniget@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/miniget/-/miniget-4.2.2.tgz#db20320f265efdc4c1826a0be431d56753074475"
integrity sha512-a7voNL1N5lDMxvTMExOkg+Fq89jM2vY8pAi9ZEWzZtfNmdfP6RXkvUtFnCAXoCv2T9k1v/fUJVaAEuepGcvLYA==
minimatch@^3.0.4:
version "3.0.4"
@ -2478,9 +2499,9 @@ new-github-release-url@1.0.0:
type-fest "^0.4.1"
node-addon-api@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.2.0.tgz#117cbb5a959dff0992e1c586ae0393573e4d2a87"
integrity sha512-eazsqzwG2lskuzBqCGPi7Ac2UgOoMz8JVOXVhTvvPDYhthvNpefx8jWD8Np7Gv+2Sz0FlPWZk0nJV0z598Wn8Q==
version "4.3.0"
resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.3.0.tgz#52a1a0b475193e0928e98e0426a0d1254782b77f"
integrity sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ==
node-emoji@^1.10.0:
version "1.11.0"
@ -2489,10 +2510,10 @@ node-emoji@^1.10.0:
dependencies:
lodash "^4.17.21"
node-fetch@^2.6.1, node-fetch@^2.6.5:
version "2.6.6"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
integrity sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==
node-fetch@^2.6.1, node-fetch@^2.6.5, node-fetch@^2.6.7:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
dependencies:
whatwg-url "^5.0.0"
@ -2850,12 +2871,12 @@ prism-media@^1.3.2:
resolved "https://registry.yarnpkg.com/prism-media/-/prism-media-1.3.2.tgz#a1f04423ec15d22f3d62b1987b6a25dc49aad13b"
integrity sha512-L6UsGHcT6i4wrQhFF1aPK+MNYgjRqR2tUoIqEY+CG1NqVkMjPRKzS37j9f8GiYPlD6wG9ruBj+q5Ax+bH8Ik1g==
prisma@^3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/prisma/-/prisma-3.7.0.tgz#9c73eeb2f16f767fdf523d0f4cc4c749734d62e2"
integrity sha512-pzgc95msPLcCHqOli7Hnabu/GRfSGSUWl5s2P6N13T/rgMB+NNeKbxCmzQiZT2yLOeLEPivV6YrW1oeQIwJxcg==
prisma@^3.8.1:
version "3.8.1"
resolved "https://registry.yarnpkg.com/prisma/-/prisma-3.8.1.tgz#44395cef7cbb1ea86216cb84ee02f856c08a7873"
integrity sha512-Q8zHwS9m70TaD7qI8u+8hTAmiTpK+IpvRYF3Rgb/OeWGQJOMgZCFFvNCiSfoLEQ95wilK7ctW3KOpc9AuYnRUA==
dependencies:
"@prisma/engines" "3.7.0-31.8746e055198f517658c08a0c426c7eec87f5a85f"
"@prisma/engines" "3.8.0-43.34df67547cf5598f5a6cd3eb45f14ee70c3fb86f"
progress@^2.0.0:
version "2.0.3"
@ -2893,9 +2914,9 @@ pupa@^2.1.1:
escape-goat "^2.0.0"
qs@^6.9.4:
version "6.10.2"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.2.tgz#c1431bea37fc5b24c5bdbafa20f16bdf2a4b9ffe"
integrity sha512-mSIdjzqznWgfd4pMii7sHtaYF8rx8861hBO80SraY5GT0XQibWZWJSid0avzHGkDIZLImux2S5mXO0Hfct2QCw==
version "6.10.3"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.3.tgz#d6cde1b2ffca87b5aa57889816c5f81535e22e8e"
integrity sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==
dependencies:
side-channel "^1.0.4"
@ -2977,17 +2998,16 @@ registry-url@^5.0.0:
rc "^1.2.8"
release-it@^14.11.8:
version "14.11.8"
resolved "https://registry.yarnpkg.com/release-it/-/release-it-14.11.8.tgz#6da25daa93286d832cae4f10008a3bf0c08c2725"
integrity sha512-951DJ0kwjwU7CwGU3BCvRBgLxuJsOPRrZkqx0AsugJdSyPpUdwY9nlU0RAoSKqgh+VTerzecXLIIwgsGIpNxlA==
version "14.12.4"
resolved "https://registry.yarnpkg.com/release-it/-/release-it-14.12.4.tgz#0fd13de85e382323c634a0697a601437e042123a"
integrity sha512-lqf9PMsj7ycCqFHGag8Uv7cE1hNsKa+yKUMe+Fkh9fdOfxu2F01On+YUefRCP0DuQthmr/WyLCYdrjThMEkWFQ==
dependencies:
"@iarna/toml" "2.2.5"
"@octokit/rest" "18.12.0"
async-retry "1.3.3"
chalk "4.1.2"
cosmiconfig "7.0.1"
debug "4.3.2"
deprecated-obj "2.0.0"
debug "4.3.3"
execa "5.1.1"
form-data "4.0.0"
git-url-parse "11.6.0"
@ -3004,7 +3024,7 @@ release-it@^14.11.8:
os-name "4.0.1"
parse-json "5.2.0"
semver "7.3.5"
shelljs "0.8.4"
shelljs "0.8.5"
update-notifier "5.1.0"
url-join "4.0.1"
uuid "8.3.2"
@ -3037,11 +3057,11 @@ resolve-from@^5.0.0:
integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==
resolve@^1.1.6:
version "1.21.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.21.0.tgz#b51adc97f3472e6a5cf4444d34bc9d6b9037591f"
integrity sha512-3wCbTpk5WJlyE4mSOtDLhqQmGFi0/TD9VPwmiolnk8U0wRgMEktqCXd3vy5buTO3tljvalNvKrjHEfrd2WpEKA==
version "1.22.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.0.tgz#5e0b8c67c15df57a89bdbabe603a002f21731198"
integrity sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==
dependencies:
is-core-module "^2.8.0"
is-core-module "^2.8.1"
path-parse "^1.0.7"
supports-preserve-symlinks-flag "^1.0.0"
@ -3112,9 +3132,9 @@ rxjs@^6.6.3:
tslib "^1.9.0"
rxjs@^7.2.0:
version "7.5.1"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.1.tgz#af73df343cbcab37628197f43ea0c8256f54b157"
integrity sha512-KExVEeZWxMZnZhUZtsJcFwz8IvPvgu4G2Z2QyqjZQzUGr32KDYuSxrEYO4w3tFFNbfLozcrKUTvTPi+E9ywJkQ==
version "7.5.2"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.2.tgz#11e4a3a1dfad85dbf7fb6e33cbba17668497490b"
integrity sha512-PwDt186XaL3QN5qXj/H9DGyHhP3/RYYgZZwqBv9Tv8rsAaiwFH1IsJJlcgD37J7UW5a6O67qX0KWKS3/pu0m4w==
dependencies:
tslib "^2.1.0"
@ -3184,10 +3204,10 @@ shebang-regex@^3.0.0:
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==
shelljs@0.8.4:
version "0.8.4"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.4.tgz#de7684feeb767f8716b326078a8a00875890e3c2"
integrity sha512-7gk3UZ9kOfPLIAbslLzyWeGiEqx9e3rxwZM0KE6EL8GlGwjym9Mrlx5/p33bWTu9YG6vcS4MBxYZDHYr5lr8BQ==
shelljs@0.8.5:
version "0.8.5"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c"
integrity sha512-TiwcRcrkhHvbrZbnRcFYMLl30Dfov3HKqzp5tO5b4pt6G/SezKcYhmDg15zXVBswHmctSAQKznqNW2LO5tTDow==
dependencies:
glob "^7.0.0"
interpret "^1.0.0"
@ -3488,9 +3508,9 @@ type-fest@^0.8.0:
integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==
type-fest@^2.8.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.9.0.tgz#7a2d430dd966f52b6bc723da2aaa2c9867530551"
integrity sha512-uC0hJKi7eAGXUJ/YKk53RhnKxMwzHWgzf4t92oz8Qez28EBgVTfpDTB59y9hMYLzc/Wl85cD7Tv1hLZZoEJtrg==
version "2.11.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.11.0.tgz#732ffaf73e4d17d1f762a539876a791b45ed273b"
integrity sha512-GwRKR1jZMAQP/hVR929DWB5Z2lwSIM/nNcHEfDj2E0vOMhcYbqFxGKE5JaSzMdzmEtWJiamEn6VwHs/YVXVhEQ==
typedarray-to-buffer@^3.1.5:
version "3.1.5"
@ -3500,9 +3520,9 @@ typedarray-to-buffer@^3.1.5:
is-typedarray "^1.0.0"
typescript@>=4.3, typescript@^4.5.4:
version "4.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.4.tgz#a17d3a0263bf5c8723b9c52f43c5084edf13c2e8"
integrity sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg==
version "4.5.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3"
integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==
undefsafe@^2.0.5:
version "2.0.5"
@ -3664,12 +3684,7 @@ write-file-atomic@^3.0.0:
signal-exit "^3.0.2"
typedarray-to-buffer "^3.1.5"
ws@^8.4.0:
version "8.4.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.4.0.tgz#f05e982a0a88c604080e8581576e2a063802bed6"
integrity sha512-IHVsKe2pjajSUIl4KYMQOdlyliovpEPquKkqbwswulszzI7r0SfQrxnXdWAEqOlDCLrVSJzo+O1hAwdog2sKSQ==
ws@^8.4.2:
ws@^8.4.0, ws@^8.4.2:
version "8.4.2"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.4.2.tgz#18e749868d8439f2268368829042894b6907aa0b"
integrity sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==
@ -3740,7 +3755,7 @@ youtube.ts@^0.2.5:
axios "^0.19.0"
ytdl-core "^4.9.1"
ytdl-core@^4.10.0:
ytdl-core@^4.10.0, ytdl-core@^4.9.1:
version "4.10.0"
resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.10.0.tgz#0835cb411677684539fac2bcc10553f6f58db3e1"
integrity sha512-RCCoSVTmMeBPH5NFR1fh3nkDU9okvWM0ZdN6plw6I5+vBBZVUEpOt8vjbSgprLRMmGUsmrQZJhvG1CHOat4mLA==
@ -3749,15 +3764,6 @@ ytdl-core@^4.10.0:
miniget "^4.0.0"
sax "^1.1.3"
ytdl-core@^4.9.1:
version "4.9.2"
resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.9.2.tgz#c2d1ec44ee3cabff35e5843c6831755e69ffacf0"
integrity sha512-aTlsvsN++03MuOtyVD4DRF9Z/9UAeeuiNbjs+LjQBAiw4Hrdp48T3U9vAmRPyvREzupraY8pqRoBfKGqpq+eHA==
dependencies:
m3u8stream "^0.8.4"
miniget "^4.0.0"
sax "^1.1.3"
ytsr@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/ytsr/-/ytsr-3.6.0.tgz#bc55e8957dcc293e49e18cc3b3e6d2890d15a15e"