-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3baddc9
commit c7a3ad4
Showing
39 changed files
with
1,090 additions
and
652 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Discord from "discord.js" | ||
import {Bot} from "./bot"; | ||
import GuildState from "./guild/GuildState"; | ||
import Help from "./commands/Help"; | ||
import Leave from "./commands/Leave"; | ||
import NowPlaying from "./commands/NowPlaying"; | ||
import Play from "./commands/Play"; | ||
import Queue from "./commands/Queue"; | ||
import Skip from "./commands/Skip"; | ||
import Volume from "./commands/Volume"; | ||
import Command from "./commands/Command"; | ||
|
||
const commands = [ | ||
Help, | ||
Leave, | ||
NowPlaying, | ||
Play, | ||
Queue, | ||
Skip, | ||
Volume, | ||
] | ||
|
||
export default class CommandHandler { | ||
public commands: Command[] | ||
public commandMap: Map<string, Command> = new Map() | ||
constructor(private bot: Bot) { | ||
this.commands = commands.map(c => new c(bot, this)) | ||
|
||
for (const command of this.commands) { | ||
this.commandMap.set(command.info.command, command) | ||
command.info.alias.forEach(a => this.commandMap.set(a, command)) | ||
} | ||
} | ||
|
||
execute(commandName: string, msg: Discord.Message, args: string[], state: GuildState): Promise<void> { | ||
const command = this.commandMap.get(commandName) | ||
if (!command) return Promise.reject(new Error("No such command")) | ||
return command.execute(msg, args, state) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import {Bot} from "./bot"; | ||
import {MessageEmbed, MessageEmbedFooter, MessageEmbedOptions} from "discord.js"; | ||
import {DownloaderResult, MediaResult} from "./downloader/Downloader"; | ||
import {QueuedMedia} from "./guild/GuildState"; | ||
|
||
export default class EmbedFactory { | ||
readonly footer: MessageEmbedFooter; | ||
constructor (private bot: Bot) { | ||
this.footer = { | ||
iconURL: bot.profilePicUrl || undefined, | ||
text: `| ${bot.version} - Developed By CF12` | ||
} | ||
} | ||
|
||
info(content: string): MessageEmbed { | ||
return new MessageEmbed({ | ||
title: ':bulb: __❱❱ INFO ❱❱__', | ||
description: content, | ||
color: 5235199, // Light Blue | ||
footer: this.footer | ||
}) | ||
} | ||
|
||
|
||
error(content: string): MessageEmbed { | ||
return new MessageEmbed({ | ||
title: ':warning: __❱❱ ERROR ❱❱__', | ||
description: content, | ||
color: 16731983, // Light Red | ||
footer: this.footer | ||
}) | ||
} | ||
|
||
volInfo (volume: number): MessageEmbed { | ||
return new MessageEmbed({ | ||
title: ':loud_sound: __❱❱ VOLUME ❱❱__', | ||
description: `Volume has been set to: **${(volume).toFixed(0)}%**`, | ||
color: 5753896, // Light Green | ||
footer: this.footer | ||
}) | ||
} | ||
|
||
static formatDuration = function (duration: number | "live" | "unknown"): string { | ||
if (duration === "live") return "Live" | ||
else if (duration === "unknown") return "Unknown" | ||
|
||
const hours = Math.floor(duration / 3600); | ||
const minutes = Math.floor((duration - (hours * 3600)) / 60); | ||
const seconds = duration - (hours * 3600) - (minutes * 60); | ||
|
||
return (hours < 10 ? "0" + hours : hours.toString()) + | ||
(minutes < 10 ? "0" + minutes : minutes.toString()) + | ||
(seconds < 10 ? "0" + seconds : seconds.toString()) | ||
} | ||
|
||
mediaInfo (media: QueuedMedia): MessageEmbed { | ||
return new MessageEmbed({ | ||
title: media.title, | ||
description: media.description.length > 180 ? media.description.slice(0, 180) + "..." : media.description, | ||
color: 14038325, // Light Red | ||
author: { | ||
name: 'Now Playing', | ||
iconURL: this.bot.profilePicUrl || undefined | ||
}, | ||
thumbnail: { | ||
url: media.thumbnailURL | ||
}, | ||
fields: [ | ||
{ | ||
name: 'Uploaded By:', | ||
value: media.author, | ||
inline: true | ||
}, | ||
{ | ||
name: 'Duration', | ||
value: EmbedFactory.formatDuration(media.duration), | ||
inline: true | ||
}, | ||
{ | ||
name: 'Requested By:', | ||
value: media.requester | ||
}, | ||
{ | ||
name: 'Link', | ||
value: media.videoURL | ||
} | ||
], | ||
footer: this.footer | ||
}) | ||
} | ||
} |
Oops, something went wrong.