Skip to content

Commit

Permalink
fix: discord-player v6 migration (#309)
Browse files Browse the repository at this point in the history
Don't forget to test before merging

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: mcpsbot <[email protected]>
  • Loading branch information
3 people authored Jul 14, 2023
1 parent 919a71b commit b2d9a71
Show file tree
Hide file tree
Showing 31 changed files with 4,254 additions and 4,123 deletions.
4 changes: 2 additions & 2 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"groupName": "Discord.JS Dependencies"
},
{
"matchPackageNames": ["discord-player"],
"groupName": "Discord Player Dependency"
"matchPakagePatterns": ["@discord-player", "discord-player"],
"groupName": "Discord Player Dependencies"
},
{
"matchDepTypes": ["engines"],
Expand Down
101 changes: 50 additions & 51 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,65 +12,64 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '21 16 * * 5'
push:
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["main"]
schedule:
- cron: "21 16 * * 5"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
strategy:
fail-fast: false
matrix:
language: ["javascript"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@46ed16ded91731b2df79a2893d3aea8e9f03b5c4 # v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@46ed16ded91731b2df79a2893d3aea8e9f03b5c4 # v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@46ed16ded91731b2df79a2893d3aea8e9f03b5c4 # v2

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@46ed16ded91731b2df79a2893d3aea8e9f03b5c4 # v2
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@46ed16ded91731b2df79a2893d3aea8e9f03b5c4 # v2
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@46ed16ded91731b2df79a2893d3aea8e9f03b5c4 # v2
with:
category: "/language:${{matrix.language}}"
82 changes: 41 additions & 41 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
name: Continuous Integration

on:
push:
branches:
- main
pull_request:
merge_group:
push:
branches:
- main
pull_request:
merge_group:

jobs:
Linting:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/eslint.json"
- name: Use Node.js v16
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
with:
node-version: 16
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Run ESLint
run: yarn lint --fix=false
Linting:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/eslint.json"
- name: Use Node.js v16
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
with:
node-version: 16
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Run ESLint
run: yarn lint --fix=false

Building:
name: Compile source code
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js v16
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
with:
node-version: 16
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Build Code
run: yarn build
Building:
name: Compile source code
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js v16
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
with:
node-version: 16
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Build Code
run: yarn build
18 changes: 9 additions & 9 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
#
# Source repository: https://github.com/actions/dependency-review-action
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
name: 'Dependency Review'
name: "Dependency Review"
on: [pull_request]

permissions:
contents: read
contents: read

jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: 'Dependency Review'
uses: actions/dependency-review-action@1360a344ccb0ab6e9475edef90ad2f46bf8003b1 # v3
dependency-review:
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: "Dependency Review"
uses: actions/dependency-review-action@1360a344ccb0ab6e9475edef90ad2f46bf8003b1 # v3
32 changes: 16 additions & 16 deletions .github/workflows/labelsync.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: Automatic Label Sync

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
label_sync:
name: Automatic Label Synchronization
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
repository: "PixelPizza/.github"
- name: Run Label Sync
uses: crazy-max/ghaction-github-labeler@3de87da19416edc45c90cd89e7a4ea922a3aae5a # tag=v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
label_sync:
name: Automatic Label Synchronization
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
with:
repository: "PixelPizza/.github"
- name: Run Label Sync
uses: crazy-max/ghaction-github-labeler@3de87da19416edc45c90cd89e7a4ea922a3aae5a # tag=v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"homepage": "https://github.com/PixelPizza/OurTube#readme",
"dependencies": {
"@discord-player/extractor": "^4.4.0",
"@discordjs/opus": "^0.9.0",
"@kaname-png/plugin-statcord": "^2.1.12",
"@prisma/client": "^4.16.2",
Expand Down
17 changes: 15 additions & 2 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,21 @@ const client = new SapphireClient({
debug: true
}
});
container.player = new Player(client);
container.player = Player.singleton(client, {
ytdlOptions: {
quality: "highest",
filter: "audioonly",
highWaterMark: 1 << 25,
dlChunkSize: 0
}
});
container.logger = new Logger(container, {level: LogLevel.Debug});
container.prisma = new PrismaClient();

void client.login(process.env.TOKEN).finally(() => container.prisma.$disconnect());
async function main() {
await container.player.extractors.loadDefault();

await client.login(process.env.TOKEN).finally(() => container.prisma.$disconnect());
}

void main();
2 changes: 1 addition & 1 deletion src/commands/clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ClearCommand extends Command {

public async chatInputRun(interaction: Command.ChatInputInteraction): Promise<any> {
await interaction.deferReply();
this.container.player.getQueue(interaction.guild!)!.clear();
this.container.player.nodes.get(interaction.guild!)!.clear();
return interaction.editReply({
embeds: [
new EmbedBuilder()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/disconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class DisconnectCommand extends Command {
const {guild} = interaction;
const {channel} = guild!.members.me!.voice;

this.container.player.deleteQueue(guild!);
this.container.player.queues.delete(guild!);

return interaction.editReply({
embeds: [
Expand Down
10 changes: 2 additions & 8 deletions src/commands/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,16 @@ export class JoinCommand extends Command {
const {player} = this.container;
const {voice} = member as GuildMember;

const queue = player.createQueue(guild!, {
const queue = player.nodes.create(guild!, {
leaveOnEmpty: false,
leaveOnEnd: false,
ytdlOptions: {
quality: "highest",
filter: "audioonly",
highWaterMark: 1 << 25,
dlChunkSize: 0
},
metadata: interaction
});

try {
if (!queue.connection) await queue.connect(voice.channel!);
} catch {
player.deleteQueue(guild!);
player.queues.delete(guild!);
return void interaction.editReply({
embeds: [
new EmbedBuilder()
Expand Down
8 changes: 4 additions & 4 deletions src/commands/nowplaying.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export class NowPlayingCommand extends Command {
public async chatInputRun(interaction: Command.ChatInputInteraction): Promise<any> {
await interaction.deferReply({ephemeral: true});

const queue = this.container.player.getQueue(interaction.guild!);
const nowPlaying = queue?.nowPlaying();
const queue = this.container.player.queues.get(interaction.guild!);
const nowPlaying = queue?.currentTrack;

if (!nowPlaying)
return interaction.editReply({
Expand All @@ -36,10 +36,10 @@ export class NowPlayingCommand extends Command {
.setDescription(
stripIndents`
[${nowPlaying.title}](${nowPlaying.url})
${queue!.createProgressBar()}
${queue!.node.createProgressBar()}
${await this.resolveCommandKey(interaction, "success.requestedBy", {
replace: {user: nowPlaying.requestedBy.toString()}
replace: {user: nowPlaying.requestedBy?.toString()}
})}
`
)
Expand Down
4 changes: 2 additions & 2 deletions src/commands/pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export class PauseCommand extends Command {
public async chatInputRun(interaction: Command.ChatInputInteraction): Promise<any> {
await interaction.deferReply({ephemeral: true});

const queue = this.container.player.getQueue(interaction.guild!);
const queue = this.container.player.queues.get(interaction.guild!);

queue!.setPaused(true);
queue!.node.setPaused(true);

return interaction.editReply({
embeds: [
Expand Down
Loading

0 comments on commit b2d9a71

Please sign in to comment.