From 59d3105b31d5ff3b758766cbf0fa6e01577e5891 Mon Sep 17 00:00:00 2001 From: Struck713 Date: Sat, 22 Jul 2023 00:32:55 -0400 Subject: [PATCH] Added actions workflow --- .github/workflows/main.yml | 37 +++++++++++++++++++++++++++++++++++++ Dockerfile | 11 +++++++++++ src/app.ts | 6 +++--- src/commands/voice/queue.ts | 2 +- src/lib/voice.ts | 3 ++- src/listeners/bruh.ts | 9 +++++++++ 6 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile create mode 100644 src/listeners/bruh.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..68c62b6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: ci + +on: + push: + branches: ['release'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9684598 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:18 + +WORKDIR /app +COPY package*.json ./ +COPY tsconfig.json ./ +COPY src /app/src + +RUN npm install +RUN npm run build + +CMD [ "node", "dist/src/app.js" ] \ No newline at end of file diff --git a/src/app.ts b/src/app.ts index 24db619..6f7bae5 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,9 +1,9 @@ -import { Client, Events, GatewayIntentBits, REST, Routes } from "discord.js"; +import { Client, Events, GatewayIntentBits } from "discord.js"; import { TOKEN } from '../config.json'; -import { Commands, deploy } from "./lib/command"; +import { Commands } from "./lib/command"; import { VoiceManager } from "./lib/voice"; -const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates ] }); +export const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.MessageContent ] }); export const voiceManager = new VoiceManager(); client.once(Events.ClientReady, async client => { diff --git a/src/commands/voice/queue.ts b/src/commands/voice/queue.ts index bb175f6..f15ace3 100644 --- a/src/commands/voice/queue.ts +++ b/src/commands/voice/queue.ts @@ -35,7 +35,7 @@ export const Queue: Command = { .setDescription(`by ${playing.getAuthor()}`) .setThumbnail(playing.getThumbnailUrl()) .addFields({ name: '\u200B', value: 'Next in the queue:' }) - if (queue.length > 0) embed.addFields(queue.slice(0, Math.min(8, queue.length)).map((metadata, index) => ({ name: `${index + 2}. ${metadata.getTitle()}}`, value: `by ${metadata.getAuthor()}` }))); + if (queue.length > 0) embed.addFields(queue.slice(0, Math.min(8, queue.length)).map((metadata, index) => ({ name: `${index + 2}. ${metadata.getTitle()}`, value: `by ${metadata.getAuthor()}` }))); else embed.addFields({ name: 'There is nothing next in the queue.', value: '\u200B' }) await Embeds.send(interaction, () => embed); return; diff --git a/src/lib/voice.ts b/src/lib/voice.ts index aadd09d..7d0e246 100644 --- a/src/lib/voice.ts +++ b/src/lib/voice.ts @@ -79,7 +79,8 @@ export class VoiceConnection { let voiceConnection = this.get(); if (!voiceConnection) return false; - const stream = ytdl(url, { filter: "audioonly" }); + const stream = ytdl(url, { filter: "audioonly" }) + .on("error", _ => this.next()); this.resource = createAudioResource(stream); this.audioPlayer.play(this.resource); diff --git a/src/listeners/bruh.ts b/src/listeners/bruh.ts new file mode 100644 index 0000000..88804e0 --- /dev/null +++ b/src/listeners/bruh.ts @@ -0,0 +1,9 @@ +import { Events } from "discord.js"; +import { client } from "../app"; + +client.on(Events.MessageCreate, async message => { + if (message.author.bot) return; + if (message.content.toLowerCase().includes("bruh")) { + await message.channel.send("bruh"); + } +}); \ No newline at end of file