Skip to content

Commit

Permalink
Make thank feature togglable (#191)
Browse files Browse the repository at this point in the history
- make thank feature togglable
  • Loading branch information
Nicholas Carrigan committed Oct 2, 2020
1 parent da3e641 commit 8b6bb03
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/commands/bootstrap-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,6 @@ export const bootstrapCommands = ({
}
}
}
thanks(message);
thanks(message, config);
});
};
9 changes: 8 additions & 1 deletion src/commands/thanks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Message } from 'discord.js';
import { Config } from '../config/get-config';

/**
* Thanks handler that will show a nice message
Expand All @@ -7,7 +8,13 @@ import { Message } from 'discord.js';
* TODO: maybe rename to be more clear what this does?
* @param message the message we are to check against.
*/
export async function thanks(message: Message): Promise<Message | void> {
export async function thanks(
message: Message,
config: Config
): Promise<Message | void> {
if (!config.THANK_OPTION) {
return;
}
if (!shouldThank(message)) {
return;
}
Expand Down
7 changes: 6 additions & 1 deletion src/config/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export interface Config {
* on the message you want to use for reactions and selecting "Copy ID".
*/
STREAM_MSG_ID: string;
/**
* Option to enable/disable the thanks feature.
*/
THANK_OPTION: boolean;
}
/**
* @name getConfig
Expand All @@ -115,6 +119,7 @@ export function getConfig(): Config {
AUTO_LINK_LIMIT: Number(process.env.AUTO_LINK_LIMIT) || 5,
AUTO_LINK_CHANNEL: process.env.AUTO_LINK_CHANNEL || false,
STREAM_NOTIFY_ROLE: process.env.STREAM_NOTIFY_ROLE || '',
STREAM_MSG_ID: process.env.STREAM_MSG_ID || ''
STREAM_MSG_ID: process.env.STREAM_MSG_ID || '',
THANK_OPTION: !!process.env.THANK_OPTION || false
};
}

0 comments on commit 8b6bb03

Please sign in to comment.