mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-10 12:11:35 +02:00
Add better responses
This commit is contained in:
parent
1a1bdfd674
commit
15d4e251f2
17 changed files with 103 additions and 63 deletions
|
@ -20,6 +20,6 @@ export default class implements Command {
|
|||
public async execute(msg: Message, _: string []): Promise<void> {
|
||||
this.queueManager.get(msg.guild!.id).clear();
|
||||
|
||||
await msg.channel.send('cleared');
|
||||
await msg.channel.send('clearer than a field after a fresh harvest');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import {TextChannel, Message} from 'discord.js';
|
||||
import {injectable} from 'inversify';
|
||||
import {Settings} from '../models';
|
||||
import errorMsg from '../utils/error-msg';
|
||||
import Command from '.';
|
||||
|
||||
@injectable()
|
||||
|
@ -29,12 +30,12 @@ export default class implements Command {
|
|||
const setting = args[0];
|
||||
|
||||
if (args.length !== 2) {
|
||||
await msg.channel.send('🚫 incorrect number of arguments');
|
||||
await msg.channel.send(errorMsg('incorrect number of arguments'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.author.id !== msg.guild!.owner!.id) {
|
||||
await msg.channel.send('not authorized');
|
||||
await msg.channel.send(errorMsg('not authorized'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -59,14 +60,14 @@ export default class implements Command {
|
|||
msg.react('👍')
|
||||
]);
|
||||
} else {
|
||||
await msg.channel.send('🚫 either that channel doesn\'t exist or you want me to become sentient and listen to a voice channel');
|
||||
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;
|
||||
}
|
||||
|
||||
default:
|
||||
await msg.channel.send('🚫 I\'ve never met this setting in my life');
|
||||
await msg.channel.send(errorMsg('I\'ve never met this setting in my life'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import {inject, injectable} from 'inversify';
|
|||
import PlayerManager from '../managers/player';
|
||||
import QueueManager from '../managers/queue';
|
||||
import LoadingMessage from '../utils/loading-message';
|
||||
import errorMsg from '../utils/error-msg';
|
||||
import Command from '.';
|
||||
|
||||
@injectable()
|
||||
|
@ -25,27 +26,27 @@ export default class implements Command {
|
|||
const queue = this.queueManager.get(msg.guild!.id);
|
||||
|
||||
if (queue.get().length === 0) {
|
||||
await msg.channel.send('nothing is playing');
|
||||
await msg.channel.send(errorMsg('nothing is playing'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (queue.get()[0].isLive) {
|
||||
await msg.channel.send('can\'t seek in a livestream');
|
||||
await msg.channel.send(errorMsg('can\'t seek in a livestream'));
|
||||
return;
|
||||
}
|
||||
|
||||
const seekTime = parseInt(args[0], 10);
|
||||
|
||||
const loading = new LoadingMessage(msg.channel as TextChannel, 'hold on a sec');
|
||||
const loading = new LoadingMessage(msg.channel as TextChannel);
|
||||
|
||||
await loading.start();
|
||||
|
||||
try {
|
||||
await this.playerManager.get(msg.guild!.id).forwardSeek(seekTime);
|
||||
|
||||
await loading.stop('seeked');
|
||||
} catch (_) {
|
||||
await loading.stop('error somewhere');
|
||||
await loading.stop();
|
||||
} catch (error) {
|
||||
await loading.stop(errorMsg(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import {TYPES} from '../types';
|
|||
import {inject, injectable} from 'inversify';
|
||||
import PlayerManager from '../managers/player';
|
||||
import {STATUS} from '../services/player';
|
||||
import errorMsg from '../utils/error-msg';
|
||||
import Command from '.';
|
||||
|
||||
@injectable()
|
||||
|
@ -22,11 +23,11 @@ export default class implements Command {
|
|||
const player = this.playerManager.get(msg.guild!.id);
|
||||
|
||||
if (player.status !== STATUS.PLAYING) {
|
||||
await msg.channel.send('error: not currently playing');
|
||||
await msg.channel.send(errorMsg('not currently playing'));
|
||||
return;
|
||||
}
|
||||
|
||||
player.pause();
|
||||
await msg.channel.send('paused');
|
||||
await msg.channel.send('the stop-and-go light is now red');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import QueueManager from '../managers/queue';
|
|||
import PlayerManager from '../managers/player';
|
||||
import {getMostPopularVoiceChannel} from '../utils/channels';
|
||||
import LoadingMessage from '../utils/loading-message';
|
||||
import errorMsg from '../utils/error-msg';
|
||||
import Command from '.';
|
||||
|
||||
@injectable()
|
||||
|
@ -47,8 +48,11 @@ export default class implements Command {
|
|||
public async execute(msg: Message, args: string []): Promise<void> {
|
||||
const [targetVoiceChannel, nInChannel] = getMostPopularVoiceChannel(msg.guild!);
|
||||
|
||||
const res = new LoadingMessage(msg.channel as TextChannel);
|
||||
await res.start();
|
||||
|
||||
if (nInChannel === 0) {
|
||||
await msg.channel.send('error: all voice channels are empty');
|
||||
await res.stop(errorMsg('all voice channels are empty'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -56,28 +60,25 @@ export default class implements Command {
|
|||
|
||||
if (args.length === 0) {
|
||||
if (this.playerManager.get(msg.guild!.id).status === STATUS.PLAYING) {
|
||||
await msg.channel.send('error: already playing, give me a song name');
|
||||
await res.stop(errorMsg('already playing, give me a song name'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Must be resuming play
|
||||
if (queue.get().length === 0) {
|
||||
await msg.channel.send('error: nothing to play');
|
||||
await res.stop(errorMsg('nothing to play'));
|
||||
return;
|
||||
}
|
||||
|
||||
await this.playerManager.get(msg.guild!.id).connect(targetVoiceChannel);
|
||||
await this.playerManager.get(msg.guild!.id).play();
|
||||
|
||||
await msg.channel.send('play resuming');
|
||||
await res.stop('play resuming');
|
||||
return;
|
||||
}
|
||||
|
||||
const newSongs: QueuedSong[] = [];
|
||||
|
||||
const res = new LoadingMessage(msg.channel as TextChannel, 'hold on a sec');
|
||||
await res.start();
|
||||
|
||||
const addSingleSong = async (source: string): Promise<void> => {
|
||||
const videoDetails = await this.youtube.videos.get(source);
|
||||
|
||||
|
@ -265,7 +266,7 @@ export default class implements Command {
|
|||
// TODO: better response
|
||||
await res.stop('song(s) queued');
|
||||
|
||||
if (this.playerManager.get(msg.guild!.id).status === STATUS.DISCONNECTED) {
|
||||
if (this.playerManager.get(msg.guild!.id).voiceConnection === null) {
|
||||
await this.playerManager.get(msg.guild!.id).connect(targetVoiceChannel);
|
||||
|
||||
await this.playerManager.get(msg.guild!.id).play();
|
||||
|
|
|
@ -4,6 +4,7 @@ import {inject, injectable} from 'inversify';
|
|||
import PlayerManager from '../managers/player';
|
||||
import QueueManager from '../managers/queue';
|
||||
import LoadingMessage from '../utils/loading-message';
|
||||
import errorMsg from '../utils/error-msg';
|
||||
import Command from '.';
|
||||
|
||||
@injectable()
|
||||
|
@ -26,12 +27,12 @@ export default class implements Command {
|
|||
const queue = this.queueManager.get(msg.guild!.id);
|
||||
|
||||
if (queue.get().length === 0) {
|
||||
await msg.channel.send('nothing is playing');
|
||||
await msg.channel.send(errorMsg('nothing is playing'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (queue.get()[0].isLive) {
|
||||
await msg.channel.send('can\'t seek in a livestream');
|
||||
await msg.channel.send(errorMsg('can\'t seek in a livestream'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -45,16 +46,16 @@ export default class implements Command {
|
|||
seekTime = parseInt(time, 10);
|
||||
}
|
||||
|
||||
const loading = new LoadingMessage(msg.channel as TextChannel, 'hold on a sec');
|
||||
const loading = new LoadingMessage(msg.channel as TextChannel);
|
||||
|
||||
await loading.start();
|
||||
|
||||
try {
|
||||
await this.playerManager.get(msg.guild!.id).seek(seekTime);
|
||||
|
||||
await loading.stop('seeked');
|
||||
} catch (_) {
|
||||
await loading.stop('error somewhere');
|
||||
await loading.stop();
|
||||
} catch (error) {
|
||||
await loading.stop(errorMsg(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import {Message} from 'discord.js';
|
||||
import {injectable} from 'inversify';
|
||||
import {Shortcut, Settings} from '../models';
|
||||
import errorMsg from '../utils/error-msg';
|
||||
import Command from '.';
|
||||
|
||||
@injectable()
|
||||
export default class implements Command {
|
||||
public name = 'shortcuts';
|
||||
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']
|
||||
|
@ -53,7 +55,7 @@ export default class implements Command {
|
|||
|
||||
if (shortcut) {
|
||||
if (shortcut.authorId !== msg.author.id && msg.author.id !== msg.guild!.owner!.id) {
|
||||
await msg.channel.send('error: you do not have permission to do that');
|
||||
await msg.channel.send(errorMsg('you do\'nt have permission to do that'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -72,13 +74,13 @@ export default class implements Command {
|
|||
const shortcut = await Shortcut.findOne({where: {guildId: msg.guild!.id, shortcut: shortcutName}});
|
||||
|
||||
if (!shortcut) {
|
||||
await msg.channel.send('error: shortcut does not exist');
|
||||
await msg.channel.send(errorMsg('shortcut doesn\'t exist'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check permissions
|
||||
if (shortcut.authorId !== msg.author.id && msg.author.id !== msg.guild!.owner!.id) {
|
||||
await msg.channel.send('error: you do not have permission to do that');
|
||||
await msg.channel.send(errorMsg('you don\'t have permission to do that'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -90,7 +92,7 @@ export default class implements Command {
|
|||
}
|
||||
|
||||
default: {
|
||||
await msg.channel.send('error: unknown command');
|
||||
await msg.channel.send(errorMsg('unknown command'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import {Message} from 'discord.js';
|
|||
import {TYPES} from '../types';
|
||||
import {inject, injectable} from 'inversify';
|
||||
import QueueManager from '../managers/queue';
|
||||
import errorMsg from '../utils/error-msg';
|
||||
import Command from '.';
|
||||
|
||||
@injectable()
|
||||
|
@ -21,12 +22,13 @@ export default class implements Command {
|
|||
const queue = this.queueManager.get(msg.guild!.id).get();
|
||||
|
||||
if (queue.length <= 2) {
|
||||
await msg.channel.send('error: not enough songs to shuffle');
|
||||
await msg.channel.send(errorMsg('not enough songs to shuffle'));
|
||||
return;
|
||||
}
|
||||
|
||||
this.queueManager.get(msg.guild!.id).shuffle();
|
||||
|
||||
await msg.channel.send('`' + JSON.stringify(this.queueManager.get(msg.guild!.id).get().slice(0, 10)) + '`');
|
||||
// TODO: better response
|
||||
await msg.channel.send('shuffled');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,8 @@ export default class implements Command {
|
|||
await this.playerManager.get(msg.guild!.id).play();
|
||||
}
|
||||
|
||||
await msg.channel.send('keepin\' \'er movin\'');
|
||||
await msg.channel.send('keep \'er movin\'');
|
||||
} catch (_) {
|
||||
console.log(_);
|
||||
await msg.channel.send('no song to skip to');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import {TYPES} from '../types';
|
|||
import {inject, injectable} from 'inversify';
|
||||
import PlayerManager from '../managers/player';
|
||||
import QueueManager from '../managers/queue';
|
||||
import errorMsg from '../utils/error-msg';
|
||||
import Command from '.';
|
||||
|
||||
@injectable()
|
||||
|
@ -30,7 +31,7 @@ export default class implements Command {
|
|||
|
||||
await msg.channel.send('back \'er up\'');
|
||||
} catch (_) {
|
||||
await msg.channel.send('no song to go back to');
|
||||
await msg.channel.send(errorMsg('no song to go back to'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue