Change requiredAccountAge to use hours instead of days

master
Dragory 2018-07-27 20:35:20 +03:00
parent d2e6dca287
commit c7c0ee4e9a
4 changed files with 6 additions and 3 deletions

View File

@ -1,5 +1,8 @@
# Changelog
## v2.14.0
* Changed `requiredAccountAge` to be in hours instead of days
## v2.13.0
* Added `requiredAccountAge` and `accountAgeDeniedMessage` options for restricting how new accounts can message modmail

View File

@ -85,5 +85,5 @@ These go in `config.json`. See also `config.example.json`.
|typingProxyReverse|false|If enabled, any time a moderator is typing in a modmail thread, the user will see the bot "typing" in their DMs|
|mentionRole|"here"|Role that is mentioned when new threads are created or the bot is mentioned. Accepted values are "here", "everyone", or a role id as a string. Set to null to disable these pings entirely.|
|pingOnBotMention|true|If enabled, the bot will mention staff (see mentionRole above) on the inbox server when the bot is mentioned on the main server.|
|requiredAccountAge|null|Required account age for contacting modmail (in days). If the account is not old enough, a new thread will not be created and the bot will reply with `accountAgeDeniedMessage` (if set) instead.|
|requiredAccountAge|None|Required account age for contacting modmail (in hours). If the account is not old enough, a new thread will not be created and the bot will reply with `accountAgeDeniedMessage` (if set) instead.|
|accountAgeDeniedMessage|"Your Discord account is not old enough to contact modmail."|See `requiredAccountAge` above|

View File

@ -65,7 +65,7 @@ const defaultConfig = {
"greetingMessage": null,
"greetingAttachment": null,
"requiredAccountAge": null, // Amount of days
"requiredAccountAge": null, // In hours
"accountAgeDeniedMessage": "Your Discord account is not old enough to contact modmail.",
"relaySmallAttachmentsAsAttachments": false,

View File

@ -59,7 +59,7 @@ async function createNewThreadForUser(user, quiet = false) {
// Check the config for a requirement of account age to contact modmail,
// if the account is too young, return an optional message without making a new thread
if (config.requiredAccountAge) {
if (user.createdAt > moment() - config.requiredAccountAge * 86400000){
if (user.createdAt > moment() - config.requiredAccountAge * 3600000){
if (config.accountAgeDeniedMessage) {
const privateChannel = await user.getDMChannel();
await privateChannel.createMessage(config.accountAgeDeniedMessage);