Skip to content

Commit

Permalink
added jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
EvolutionX-10 committed Feb 14, 2022
1 parent 9a3e9ed commit a47f6a1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/handler/utilities/messageHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
import type { Message } from 'discord.js';
/**
* Checks if the author of message is a bot or not
* ```typescript
* @param message The message to check
* @returns `true` if the author of the message is a bot, `false` otherwise
* @example
* isBot(message) ? 'yes it is a bot' : 'no it is not a bot';
* ```
*/
export function isBot(message: Message) {
return message.author.bot;
}
/**
* Checks if the message **starts** with the prefix
* ```typescript
* @param message The message to check
* @param prefix The prefix to check for
* @returns `true` if the message starts with the prefix, `false` otherwise
* @example
* hasPrefix(message, '!') ? 'yes it does' : 'no it does not';
* ```
*/
export function hasPrefix(message: Message, prefix: string) {
return message.content.slice(0, prefix.length).toLowerCase().trim() === prefix;
}
/**
* Removes the first character(s) _[depending on prefix length]_ of the message
* ```typescript
* @param message The message to remove the prefix from
* @param prefix The prefix to remove
* @returns The message without the prefix
* @example
* message.content = '!ping';
* console.log(fmt(message, '!'));
* // [ 'ping' ]
* ```
*/
export function fmt(msg: Message, prefix: string): string[] {
return msg.content.slice(prefix.length).trim().split(/\s+/g);
Expand Down

0 comments on commit a47f6a1

Please sign in to comment.