aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2022-01-26 22:34:51 -0500
committerMax Isom <[email protected]>2022-01-26 22:34:51 -0500
commit1f59994dc4bde748092f0286a8f303972be19785 (patch)
tree6d37f762137e7705031fe8b3f603cea6b6ea4be1
parent2e5e509b3233b1eb6c2b5834308d0cecfbb58634 (diff)
downloadmuse-1f59994dc4bde748092f0286a8f303972be19785.tar.xz
muse-1f59994dc4bde748092f0286a8f303972be19785.zip
Remove natural langauge handlers
-rw-r--r--src/inversify.config.ts2
-rw-r--r--src/services/natural-language-commands.ts131
2 files changed, 0 insertions, 133 deletions
diff --git a/src/inversify.config.ts b/src/inversify.config.ts
index b2a18fb..a1187a9 100644
--- a/src/inversify.config.ts
+++ b/src/inversify.config.ts
@@ -10,7 +10,6 @@ import PlayerManager from './managers/player.js';
// Helpers
import GetSongs from './services/get-songs.js';
-import NaturalLanguage from './services/natural-language-commands.js';
// Comands
import Command from './commands';
@@ -48,7 +47,6 @@ container.bind<PlayerManager>(TYPES.Managers.Player).to(PlayerManager).inSinglet
// Helpers
container.bind<GetSongs>(TYPES.Services.GetSongs).to(GetSongs).inSingletonScope();
-container.bind<NaturalLanguage>(TYPES.Services.NaturalLanguage).to(NaturalLanguage).inSingletonScope();
// Commands
[
diff --git a/src/services/natural-language-commands.ts b/src/services/natural-language-commands.ts
deleted file mode 100644
index 4ce8ea3..0000000
--- a/src/services/natural-language-commands.ts
+++ /dev/null
@@ -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);
- }
- });
- }
-}