-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
104 additions
and
22 deletions.
There are no files selected for viewing
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 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,42 @@ | ||
import { Message, Permissions } from 'discord.js'; | ||
|
||
import ICommand from '../base/ICommand'; | ||
|
||
import DatabaseAdapter from '../../db/DatabaseAdapter'; | ||
import SoundUtil from '../../util/SoundUtil'; | ||
|
||
export default class TagCommand implements ICommand { | ||
public readonly TRIGGERS = ['tag', 'tags']; | ||
public readonly USAGE = 'Usage: !tag <sound> [<tag> ... <tagN> | clear]'; | ||
private readonly db: DatabaseAdapter; | ||
|
||
constructor(db: DatabaseAdapter) { | ||
this.db = db; | ||
} | ||
|
||
public run(message: Message, params: Array<string>) { | ||
if (params.length < 1) { | ||
message.channel.send(this.USAGE); | ||
return; | ||
} | ||
|
||
const sound = params.shift()!; | ||
if (!SoundUtil.getSounds().includes(sound)) { | ||
message.channel.send(`${sound} not found!`); | ||
return; | ||
} | ||
|
||
if (!params.length) { | ||
message.channel.send(`Tags for ${sound}: [${this.db.listTags(sound)}]`); | ||
return; | ||
} | ||
|
||
if (params[0] === 'clear') { | ||
if (!message.member.hasPermission(Permissions.FLAGS.ADMINISTRATOR!)) return; | ||
this.db.removeTags(sound); | ||
return; | ||
} | ||
|
||
this.db.addTags(sound, params); | ||
} | ||
} |
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