From 870a7f2d906d36dfdda105eda9cf11d98cbc1add Mon Sep 17 00:00:00 2001 From: chandler05 Date: Mon, 30 Nov 2020 20:04:29 -0600 Subject: [PATCH 01/15] Add request notifications --- config/default.yml | 5 +++ config/main.yml | 16 ++++++++++ config/template.yml | 14 +++++++++ src/BotConfig.ts | 9 ++++++ src/tasks/ResolveRequestMessageTask.ts | 43 ++++++++++++++++++++++++++ 5 files changed, 87 insertions(+) diff --git a/config/default.yml b/config/default.yml index 6e0662b6..9425a2eb 100644 --- a/config/default.yml +++ b/config/default.yml @@ -36,6 +36,11 @@ request: ignorePrependResponseMessageEmoji: ✅ ignoreResolutionEmoji: 💬 + fullNotificationsRole: 'All Request Notifications' + someNotificationsRole: 'Fewer Request Notifications' + oldNotificationsRole: 'Old Request Notifications' + oldNotificationsTimeDifference: 259200000 # 3 days + resolveDelay: 10000 prependResponseMessage: whenResolved prependResponseMessageInLog: false diff --git a/config/main.yml b/config/main.yml index 78485450..d534f79d 100644 --- a/config/main.yml +++ b/config/main.yml @@ -71,6 +71,22 @@ roleGroups: Other Pronoun (please indicate in your nickname) emoji: '🇴' + - prompt: |- + Select a reaction on this message if you want to be notified in DMs when your requests are resolved. + channel: '648479533246316555' + message: #TODO + radio: true + roles: + - id: #TODO + desc: Be notified of all of your resolved requests. + emoji: '🔔' + - id: #TODO + desc: Be notified of your resolved requests that are not resolved as ✅. + emoji: '🛎️' + - id: #TODO + desc: Be notified of your resolved requests that are resolved at least three days after they were created. + emoji: '⏰' + filterFeeds: - jql: project = MC AND resolved > -1m AND resolution = Fixed AND fixVersion in unreleasedVersions() diff --git a/config/template.yml b/config/template.yml index c4740d75..58a69ffc 100644 --- a/config/template.yml +++ b/config/template.yml @@ -84,6 +84,20 @@ request: # An emoji or emoji ID which, when used, doesn't trigger the response template message. ignorePrependResponseMessageEmoji: + # The name of the role that signifies users that get all notifications from their resolved requests. + fullNotificationsRole: + + # The name of the role that signifies users that get some of the notifications from their resolved requests. + # This does not include the ignorePrependResponseMessageEmoji resolution. + someNotificationsRole: + + # The name of the role that signifies users that get all notifications from their resolved requests from a certain time period before. + oldNotificationsRole: + + # The amount of time in milliseconds that needs to occur after creating a request before a user will get a notification for their report. + # Only applies to the oldNotificationsRole. + oldNotificationsTimeDifference: + # The amount of time in milliseconds between a volunteer reacts to the message and the bot deletes its message. resolveDelay: diff --git a/src/BotConfig.ts b/src/BotConfig.ts index 00cb6970..ee5063a9 100644 --- a/src/BotConfig.ts +++ b/src/BotConfig.ts @@ -25,6 +25,10 @@ export class RequestConfig { public suggestedEmoji: string[]; public ignorePrependResponseMessageEmoji: string; public ignoreResolutionEmoji: string; + public fullNotificationsRole: string; + public someNotificationsRole: string; + public oldNotificationsRole: string; + public oldNotificationsTimeDifference: number; public resolveDelay: number; public prependResponseMessage: PrependResponseMessageType; public prependResponseMessageInLog: boolean; @@ -46,6 +50,11 @@ export class RequestConfig { this.ignorePrependResponseMessageEmoji = config.get( 'request.ignorePrependResponseMessageEmoji' ); this.ignoreResolutionEmoji = config.get( 'request.ignoreResolutionEmoji' ); + this.fullNotificationsRole = config.get( 'request.fullNotificationsRole' ); + this.someNotificationsRole = config.get( 'request.someNotificationsRole' ); + this.oldNotificationsRole = config.get( 'request.oldNotificationsRole' ); + this.oldNotificationsTimeDifference = config.get( 'request.oldNotificationsTimeDifference' ); + this.resolveDelay = config.get( 'request.resolveDelay' ); this.prependResponseMessage = getOrDefault( 'request.prependResponseMessage', PrependResponseMessageType.Never ); this.prependResponseMessageInLog = getOrDefault( 'request.prependResponseMessageInLog', false ); diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index 59bee4cb..799a7597 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -41,6 +41,49 @@ export default class ResolveRequestMessageTask extends MessageTask { ResolveRequestMessageTask.logger.error( error ); } + if ( origin.author ) { + const response = BotConfig.request.prependResponseMessageInLog ? + RequestsUtil.getResponseMessage( origin ) : ''; + + const log = new MessageEmbed() + .setColor( 'GREEN' ) + .setAuthor( origin.author.tag, origin.author.avatarURL() ) + .setDescription( origin.content ) + .addField( 'Channel', origin.channel.toString(), true ) + .addField( 'Message', `[Here](${ origin.url })`, true ) + .setFooter( `${ this.user.tag } resolved as ${ this.emoji }`, this.user.avatarURL() ) + .setTimestamp( new Date() ); + + if ( origin.author.roles.find( r => r.name === BotConfig.request.fullNotificationsRole ) ) { + try { + await origin.author.send( response, log ); + } catch ( error ) { + ResolveRequestMessageTask.logger.error( error ); + } + } + + if ( origin.author.roles.find( r => r.name === BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { + try { + await origin.author.send( response, log ); + } catch ( error ) { + ResolveRequestMessageTask.logger.error( error ); + } + } + + if ( origin.author.roles.find( r => r.name === BotConfig.request.oldNotificationsRole ) ) { + const curTime = new Date(); + const createdTime = origin.createdAt(); + const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); + if ( timeDifference >= BotConfig.request.oldNotificationsTimeDifference ) { + try { + await origin.author.send( response, log ); + } catch ( error ) { + ResolveRequestMessageTask.logger.error( error ); + } + } + } + } + if ( BotConfig.request.logChannel ) { const logChannel = await DiscordUtil.getChannel( BotConfig.request.logChannel ); if ( logChannel && logChannel instanceof TextChannel ) { From 7621736c7b3747415c0a4152fa44131531604fc0 Mon Sep 17 00:00:00 2001 From: chandler05 Date: Mon, 30 Nov 2020 20:12:58 -0600 Subject: [PATCH 02/15] Fix retrieving roles --- src/tasks/ResolveRequestMessageTask.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index 799a7597..cd9b62ff 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -54,7 +54,7 @@ export default class ResolveRequestMessageTask extends MessageTask { .setFooter( `${ this.user.tag } resolved as ${ this.emoji }`, this.user.avatarURL() ) .setTimestamp( new Date() ); - if ( origin.author.roles.find( r => r.name === BotConfig.request.fullNotificationsRole ) ) { + if ( origin.member.roles.has( r => r.name === BotConfig.request.fullNotificationsRole ) ) { try { await origin.author.send( response, log ); } catch ( error ) { @@ -62,7 +62,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } - if ( origin.author.roles.find( r => r.name === BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { + if ( origin.member.roles.has( r => r.name === BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { try { await origin.author.send( response, log ); } catch ( error ) { @@ -70,7 +70,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } - if ( origin.author.roles.find( r => r.name === BotConfig.request.oldNotificationsRole ) ) { + if ( origin.member.roles.has( r => r.name === BotConfig.request.oldNotificationsRole ) ) { const curTime = new Date(); const createdTime = origin.createdAt(); const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); From 1eaee7610876b171e864acce7086900ec57afa36 Mon Sep 17 00:00:00 2001 From: chandler05 Date: Mon, 30 Nov 2020 20:15:30 -0600 Subject: [PATCH 03/15] fix 2.0 --- src/tasks/ResolveRequestMessageTask.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index cd9b62ff..769b3277 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -54,7 +54,7 @@ export default class ResolveRequestMessageTask extends MessageTask { .setFooter( `${ this.user.tag } resolved as ${ this.emoji }`, this.user.avatarURL() ) .setTimestamp( new Date() ); - if ( origin.member.roles.has( r => r.name === BotConfig.request.fullNotificationsRole ) ) { + if ( origin.member.roles.find( r => r.name === BotConfig.request.fullNotificationsRole ) ) { try { await origin.author.send( response, log ); } catch ( error ) { @@ -62,7 +62,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } - if ( origin.member.roles.has( r => r.name === BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { + if ( origin.member.roles.find( r => r.name === BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { try { await origin.author.send( response, log ); } catch ( error ) { @@ -70,7 +70,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } - if ( origin.member.roles.has( r => r.name === BotConfig.request.oldNotificationsRole ) ) { + if ( origin.member.roles.find( r => r.name === BotConfig.request.oldNotificationsRole ) ) { const curTime = new Date(); const createdTime = origin.createdAt(); const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); From a8c2039617f1f8efac76ea52cbe5b974ece5cad5 Mon Sep 17 00:00:00 2001 From: chandler05 Date: Mon, 30 Nov 2020 20:26:17 -0600 Subject: [PATCH 04/15] fix 3.0 --- src/tasks/ResolveRequestMessageTask.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index 769b3277..a0a43f54 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -54,7 +54,7 @@ export default class ResolveRequestMessageTask extends MessageTask { .setFooter( `${ this.user.tag } resolved as ${ this.emoji }`, this.user.avatarURL() ) .setTimestamp( new Date() ); - if ( origin.member.roles.find( r => r.name === BotConfig.request.fullNotificationsRole ) ) { + if ( origin.member.roles.cache.has( r => r.name === BotConfig.request.fullNotificationsRole ) ) { try { await origin.author.send( response, log ); } catch ( error ) { @@ -62,7 +62,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } - if ( origin.member.roles.find( r => r.name === BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { + if ( origin.member.roles.cache.has( r => r.name === BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { try { await origin.author.send( response, log ); } catch ( error ) { @@ -70,7 +70,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } - if ( origin.member.roles.find( r => r.name === BotConfig.request.oldNotificationsRole ) ) { + if ( origin.member.roles.cache.has( r => r.name === BotConfig.request.oldNotificationsRole ) ) { const curTime = new Date(); const createdTime = origin.createdAt(); const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); From dafeb5a97c1c6162f48a9502b909f79a7aed4f1e Mon Sep 17 00:00:00 2001 From: chandler05 Date: Mon, 30 Nov 2020 20:29:41 -0600 Subject: [PATCH 05/15] fix 4.0 :( --- src/tasks/ResolveRequestMessageTask.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index a0a43f54..94eac289 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -54,7 +54,7 @@ export default class ResolveRequestMessageTask extends MessageTask { .setFooter( `${ this.user.tag } resolved as ${ this.emoji }`, this.user.avatarURL() ) .setTimestamp( new Date() ); - if ( origin.member.roles.cache.has( r => r.name === BotConfig.request.fullNotificationsRole ) ) { + if ( origin.member.roles.cache.has( BotConfig.request.fullNotificationsRole ) ) { try { await origin.author.send( response, log ); } catch ( error ) { @@ -62,7 +62,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } - if ( origin.member.roles.cache.has( r => r.name === BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { + if ( origin.member.roles.cache.has( BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { try { await origin.author.send( response, log ); } catch ( error ) { @@ -70,7 +70,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } - if ( origin.member.roles.cache.has( r => r.name === BotConfig.request.oldNotificationsRole ) ) { + if ( origin.member.roles.cache.has( BotConfig.request.oldNotificationsRole ) ) { const curTime = new Date(); const createdTime = origin.createdAt(); const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); From 070f59f47f68df506cd02c6af0ddf095feb6fa80 Mon Sep 17 00:00:00 2001 From: chandler05 Date: Mon, 30 Nov 2020 20:37:30 -0600 Subject: [PATCH 06/15] Fix date grabbing --- src/tasks/ResolveRequestMessageTask.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index 94eac289..d9d05b74 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -72,7 +72,7 @@ export default class ResolveRequestMessageTask extends MessageTask { if ( origin.member.roles.cache.has( BotConfig.request.oldNotificationsRole ) ) { const curTime = new Date(); - const createdTime = origin.createdAt(); + const createdTime = origin.createdAt; const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); if ( timeDifference >= BotConfig.request.oldNotificationsTimeDifference ) { try { From a7923d6b7a56934580ea0cd29704a11367228985 Mon Sep 17 00:00:00 2001 From: chandler05 Date: Mon, 30 Nov 2020 21:27:19 -0600 Subject: [PATCH 07/15] Change reactions --- config/default.yml | 8 +-- config/main.yml | 27 +++++++--- config/template.yml | 12 ++++- src/BotConfig.ts | 8 ++- src/tasks/ResolveRequestMessageTask.ts | 72 +++++++++++++++++++------- 5 files changed, 94 insertions(+), 33 deletions(-) diff --git a/config/default.yml b/config/default.yml index 9425a2eb..2b3b6e2a 100644 --- a/config/default.yml +++ b/config/default.yml @@ -36,10 +36,12 @@ request: ignorePrependResponseMessageEmoji: ✅ ignoreResolutionEmoji: 💬 - fullNotificationsRole: 'All Request Notifications' - someNotificationsRole: 'Fewer Request Notifications' - oldNotificationsRole: 'Old Request Notifications' + normalNotificationsRole: 'Normal Request Notifications' + someNotificationsRole: 'Special Request Notifications' + oldNotificationsRole: 'Three Day Old Request Notifications' oldNotificationsTimeDifference: 259200000 # 3 days + longNotificationsRole: 'One Week Old Request Notifications' + longNotificationsTimeDifference: 259200000 # 1 week resolveDelay: 10000 prependResponseMessage: whenResolved diff --git a/config/main.yml b/config/main.yml index d534f79d..8b205605 100644 --- a/config/main.yml +++ b/config/main.yml @@ -72,20 +72,33 @@ roleGroups: (please indicate in your nickname) emoji: '🇴' - prompt: |- - Select a reaction on this message if you want to be notified in DMs when your requests are resolved. + Request Notifications (1/2) + Select reaction(s) on this message to be notified in DMs when specific requests are resolved. channel: '648479533246316555' message: #TODO - radio: true + radio: false roles: - id: #TODO - desc: Be notified of all of your resolved requests. - emoji: '🔔' + desc: Be notified of your resolved requests that are resolved as ✅. + emoji: '✅' - id: #TODO desc: Be notified of your resolved requests that are not resolved as ✅. - emoji: '🛎️' + emoji: '☑️' + - prompt: |- + Request Notifications (2/2) + Select a reaction on this message if you want to be notified in DMs when requests are resolved after a certain amount of time. + Default is no time requirement. + channel: '648479533246316555' + message: #TODO + radio: true + roles: + - id: #TODO + desc: Be notified of your resolved requests that are resolved at least three days after creation. + emoji: ':three:' - id: #TODO - desc: Be notified of your resolved requests that are resolved at least three days after they were created. - emoji: '⏰' + desc: Be notified of your resolved requests that are resolved at least one week after creation. + emoji: ':seven:' + filterFeeds: diff --git a/config/template.yml b/config/template.yml index 58a69ffc..79e85f64 100644 --- a/config/template.yml +++ b/config/template.yml @@ -84,8 +84,9 @@ request: # An emoji or emoji ID which, when used, doesn't trigger the response template message. ignorePrependResponseMessageEmoji: - # The name of the role that signifies users that get all notifications from their resolved requests. - fullNotificationsRole: + # The name of the role that signifies users that get notifications from some of their resolved requests. + # This includes only the ignorePrependResponseMessageEmoji resolution. + normalNotificationsRole: # The name of the role that signifies users that get some of the notifications from their resolved requests. # This does not include the ignorePrependResponseMessageEmoji resolution. @@ -98,6 +99,13 @@ request: # Only applies to the oldNotificationsRole. oldNotificationsTimeDifference: + # The name of the role that signifies users that get all notifications from their resolved requests regardless of the time it took to resolve. + longNotificationsRole: + + # The amount of time in milliseconds that needs to occur after creating a request before a user will get a notification for their report. + # Only applies to the longNotificationsRole. + longNotificationsTimeDifference: + # The amount of time in milliseconds between a volunteer reacts to the message and the bot deletes its message. resolveDelay: diff --git a/src/BotConfig.ts b/src/BotConfig.ts index ee5063a9..7b0875cc 100644 --- a/src/BotConfig.ts +++ b/src/BotConfig.ts @@ -25,10 +25,12 @@ export class RequestConfig { public suggestedEmoji: string[]; public ignorePrependResponseMessageEmoji: string; public ignoreResolutionEmoji: string; - public fullNotificationsRole: string; + public normalNotificationsRole: string; public someNotificationsRole: string; public oldNotificationsRole: string; public oldNotificationsTimeDifference: number; + public longNotificationsRole: string; + public longNotificationsTimeDifference: number; public resolveDelay: number; public prependResponseMessage: PrependResponseMessageType; public prependResponseMessageInLog: boolean; @@ -50,10 +52,12 @@ export class RequestConfig { this.ignorePrependResponseMessageEmoji = config.get( 'request.ignorePrependResponseMessageEmoji' ); this.ignoreResolutionEmoji = config.get( 'request.ignoreResolutionEmoji' ); - this.fullNotificationsRole = config.get( 'request.fullNotificationsRole' ); + this.normalNotificationsRole = config.get( 'request.normalNotificationsRole' ); this.someNotificationsRole = config.get( 'request.someNotificationsRole' ); this.oldNotificationsRole = config.get( 'request.oldNotificationsRole' ); this.oldNotificationsTimeDifference = config.get( 'request.oldNotificationsTimeDifference' ); + this.longNotificationsRole = config.get( 'request.longNotificationsRole' ); + this.longNotificationsTimeDifference = config.get( 'request.longNotificationsTimeDifference' ); this.resolveDelay = config.get( 'request.resolveDelay' ); this.prependResponseMessage = getOrDefault( 'request.prependResponseMessage', PrependResponseMessageType.Never ); diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index d9d05b74..6b2eb51e 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -54,27 +54,62 @@ export default class ResolveRequestMessageTask extends MessageTask { .setFooter( `${ this.user.tag } resolved as ${ this.emoji }`, this.user.avatarURL() ) .setTimestamp( new Date() ); - if ( origin.member.roles.cache.has( BotConfig.request.fullNotificationsRole ) ) { - try { - await origin.author.send( response, log ); - } catch ( error ) { - ResolveRequestMessageTask.logger.error( error ); - } - } - - if ( origin.member.roles.cache.has( BotConfig.request.someNotificationsRole ) && this.emoji != BotConfig.request.ignorePrependResponseMessageEmoji ) { - try { - await origin.author.send( response, log ); - } catch ( error ) { - ResolveRequestMessageTask.logger.error( error ); + if ( origin.member.roles.cache.has( BotConfig.request.normalNotificationsRole ) && this.emoji === BotConfig.request.ignorePrependResponseMessageEmoji ) { + if ( origin.member.roles.cache.has( BotConfig.request.oldNotificationsRole ) ) { + const curTime = new Date(); + const createdTime = origin.createdAt; + const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); + if ( timeDifference >= BotConfig.request.oldNotificationsTimeDifference ) { + try { + await origin.author.send( response, log ); + } catch ( error ) { + ResolveRequestMessageTask.logger.error( error ); + } + } + } else if ( origin.member.roles.cache.has( BotConfig.request.longNotificationsRole ) ) { + const curTime = new Date(); + const createdTime = origin.createdAt; + const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); + if ( timeDifference >= BotConfig.request.longNotificationsTimeDifference ) { + try { + await origin.author.send( response, log ); + } catch ( error ) { + ResolveRequestMessageTask.logger.error( error ); + } + } + } else { + try { + await origin.author.send( response, log ); + } catch ( error ) { + ResolveRequestMessageTask.logger.error( error ); + } } } - if ( origin.member.roles.cache.has( BotConfig.request.oldNotificationsRole ) ) { - const curTime = new Date(); - const createdTime = origin.createdAt; - const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); - if ( timeDifference >= BotConfig.request.oldNotificationsTimeDifference ) { + if ( origin.member.roles.cache.has( BotConfig.request.someNotificationsRole ) && this.emoji !== BotConfig.request.ignorePrependResponseMessageEmoji ) { + if ( origin.member.roles.cache.has( BotConfig.request.oldNotificationsRole ) ) { + const curTime = new Date(); + const createdTime = origin.createdAt; + const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); + if ( timeDifference >= BotConfig.request.oldNotificationsTimeDifference ) { + try { + await origin.author.send( response, log ); + } catch ( error ) { + ResolveRequestMessageTask.logger.error( error ); + } + } + } else if ( origin.member.roles.cache.has( BotConfig.request.longNotificationsRole ) ) { + const curTime = new Date(); + const createdTime = origin.createdAt; + const timeDifference = Math.abs( curTime.getTime() - createdTime.getTime() ); + if ( timeDifference >= BotConfig.request.longNotificationsTimeDifference ) { + try { + await origin.author.send( response, log ); + } catch ( error ) { + ResolveRequestMessageTask.logger.error( error ); + } + } + } else { try { await origin.author.send( response, log ); } catch ( error ) { @@ -82,7 +117,6 @@ export default class ResolveRequestMessageTask extends MessageTask { } } } - } if ( BotConfig.request.logChannel ) { const logChannel = await DiscordUtil.getChannel( BotConfig.request.logChannel ); From 22275e551190a166c36c0377e9042daa1b643b9c Mon Sep 17 00:00:00 2001 From: chandler05 Date: Mon, 30 Nov 2020 21:32:23 -0600 Subject: [PATCH 08/15] Fix error thing --- config/default.yml | 2 +- src/tasks/ResolveRequestMessageTask.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/default.yml b/config/default.yml index 2b3b6e2a..48dcdefc 100644 --- a/config/default.yml +++ b/config/default.yml @@ -41,7 +41,7 @@ request: oldNotificationsRole: 'Three Day Old Request Notifications' oldNotificationsTimeDifference: 259200000 # 3 days longNotificationsRole: 'One Week Old Request Notifications' - longNotificationsTimeDifference: 259200000 # 1 week + longNotificationsTimeDifference: 604800000 # 1 week resolveDelay: 10000 prependResponseMessage: whenResolved diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index 6b2eb51e..936ec76a 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -117,6 +117,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } } + } if ( BotConfig.request.logChannel ) { const logChannel = await DiscordUtil.getChannel( BotConfig.request.logChannel ); From eef961e48af68c6f3c2d16d7fc22c12ac93861bc Mon Sep 17 00:00:00 2001 From: chandler05 <66492208+chandler05@users.noreply.github.com> Date: Tue, 1 Dec 2020 05:55:29 -0600 Subject: [PATCH 09/15] Update main.yml --- config/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/main.yml b/config/main.yml index 8b205605..ff703b93 100644 --- a/config/main.yml +++ b/config/main.yml @@ -87,17 +87,17 @@ roleGroups: - prompt: |- Request Notifications (2/2) Select a reaction on this message if you want to be notified in DMs when requests are resolved after a certain amount of time. - Default is no time requirement. + No reaction means no time requirement. channel: '648479533246316555' message: #TODO radio: true roles: - id: #TODO desc: Be notified of your resolved requests that are resolved at least three days after creation. - emoji: ':three:' + emoji: '3️⃣' - id: #TODO desc: Be notified of your resolved requests that are resolved at least one week after creation. - emoji: ':seven:' + emoji: '7️⃣' From 04f2a9950aad9cc8c481387134a6804b5cd0ccb4 Mon Sep 17 00:00:00 2001 From: chandler05 <66492208+chandler05@users.noreply.github.com> Date: Tue, 1 Dec 2020 06:15:06 -0600 Subject: [PATCH 10/15] Update default.yml --- config/default.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/default.yml b/config/default.yml index 48dcdefc..87397e7d 100644 --- a/config/default.yml +++ b/config/default.yml @@ -36,11 +36,11 @@ request: ignorePrependResponseMessageEmoji: ✅ ignoreResolutionEmoji: 💬 - normalNotificationsRole: 'Normal Request Notifications' - someNotificationsRole: 'Special Request Notifications' - oldNotificationsRole: 'Three Day Old Request Notifications' + normalNotificationsRole: #TODO + someNotificationsRole: #TODO + oldNotificationsRole: #TODO oldNotificationsTimeDifference: 259200000 # 3 days - longNotificationsRole: 'One Week Old Request Notifications' + longNotificationsRole: #TODO longNotificationsTimeDifference: 604800000 # 1 week resolveDelay: 10000 From 11a8b00bb7f14c9b12c86c2c1eba8b1713ba1b93 Mon Sep 17 00:00:00 2001 From: chandler05 <66492208+chandler05@users.noreply.github.com> Date: Tue, 1 Dec 2020 06:16:02 -0600 Subject: [PATCH 11/15] Update template.yml --- config/template.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/template.yml b/config/template.yml index 79e85f64..a0c5661d 100644 --- a/config/template.yml +++ b/config/template.yml @@ -84,22 +84,22 @@ request: # An emoji or emoji ID which, when used, doesn't trigger the response template message. ignorePrependResponseMessageEmoji: - # The name of the role that signifies users that get notifications from some of their resolved requests. + # The ID of the role that signifies users that get notifications from some of their resolved requests. # This includes only the ignorePrependResponseMessageEmoji resolution. normalNotificationsRole: - # The name of the role that signifies users that get some of the notifications from their resolved requests. + # The ID of the role that signifies users that get some of the notifications from their resolved requests. # This does not include the ignorePrependResponseMessageEmoji resolution. someNotificationsRole: - # The name of the role that signifies users that get all notifications from their resolved requests from a certain time period before. + # The ID of the role that signifies users that get all notifications from their resolved requests from a certain time period before. oldNotificationsRole: # The amount of time in milliseconds that needs to occur after creating a request before a user will get a notification for their report. # Only applies to the oldNotificationsRole. oldNotificationsTimeDifference: - # The name of the role that signifies users that get all notifications from their resolved requests regardless of the time it took to resolve. + # The ID of the role that signifies users that get all notifications from their resolved requests regardless of the time it took to resolve. longNotificationsRole: # The amount of time in milliseconds that needs to occur after creating a request before a user will get a notification for their report. From bd75a3e6ef213b372e3761183c1a4f8a360ad3bd Mon Sep 17 00:00:00 2001 From: chandler05 Date: Tue, 1 Dec 2020 08:31:56 -0600 Subject: [PATCH 12/15] Rename "some" to "special" --- config/default.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.yml b/config/default.yml index 87397e7d..b3131d62 100644 --- a/config/default.yml +++ b/config/default.yml @@ -37,7 +37,7 @@ request: ignoreResolutionEmoji: 💬 normalNotificationsRole: #TODO - someNotificationsRole: #TODO + speicalNotificationsRole: #TODO oldNotificationsRole: #TODO oldNotificationsTimeDifference: 259200000 # 3 days longNotificationsRole: #TODO From be3363cf958a50cdf1c393cf82a06baae34bb756 Mon Sep 17 00:00:00 2001 From: chandler05 Date: Tue, 1 Dec 2020 08:41:10 -0600 Subject: [PATCH 13/15] Rename "some" to "special" again --- config/template.yml | 2 +- src/BotConfig.ts | 4 ++-- src/tasks/ResolveRequestMessageTask.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/template.yml b/config/template.yml index a0c5661d..50e0926c 100644 --- a/config/template.yml +++ b/config/template.yml @@ -90,7 +90,7 @@ request: # The ID of the role that signifies users that get some of the notifications from their resolved requests. # This does not include the ignorePrependResponseMessageEmoji resolution. - someNotificationsRole: + specialNotificationsRole: # The ID of the role that signifies users that get all notifications from their resolved requests from a certain time period before. oldNotificationsRole: diff --git a/src/BotConfig.ts b/src/BotConfig.ts index 7b0875cc..721c1fe4 100644 --- a/src/BotConfig.ts +++ b/src/BotConfig.ts @@ -26,7 +26,7 @@ export class RequestConfig { public ignorePrependResponseMessageEmoji: string; public ignoreResolutionEmoji: string; public normalNotificationsRole: string; - public someNotificationsRole: string; + public specialNotificationsRole: string; public oldNotificationsRole: string; public oldNotificationsTimeDifference: number; public longNotificationsRole: string; @@ -53,7 +53,7 @@ export class RequestConfig { this.ignoreResolutionEmoji = config.get( 'request.ignoreResolutionEmoji' ); this.normalNotificationsRole = config.get( 'request.normalNotificationsRole' ); - this.someNotificationsRole = config.get( 'request.someNotificationsRole' ); + this.specialNotificationsRole = config.get( 'request.specialNotificationsRole' ); this.oldNotificationsRole = config.get( 'request.oldNotificationsRole' ); this.oldNotificationsTimeDifference = config.get( 'request.oldNotificationsTimeDifference' ); this.longNotificationsRole = config.get( 'request.longNotificationsRole' ); diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index 936ec76a..b82a0200 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -86,7 +86,7 @@ export default class ResolveRequestMessageTask extends MessageTask { } } - if ( origin.member.roles.cache.has( BotConfig.request.someNotificationsRole ) && this.emoji !== BotConfig.request.ignorePrependResponseMessageEmoji ) { + if ( origin.member.roles.cache.has( BotConfig.request.specialNotificationsRole ) && this.emoji !== BotConfig.request.ignorePrependResponseMessageEmoji ) { if ( origin.member.roles.cache.has( BotConfig.request.oldNotificationsRole ) ) { const curTime = new Date(); const createdTime = origin.createdAt; From 2c54b8e3fe31c6a779c9c8c3ecc06852db146aa1 Mon Sep 17 00:00:00 2001 From: chandler05 Date: Tue, 1 Dec 2020 18:24:33 -0600 Subject: [PATCH 14/15] Fix indentation --- src/tasks/ResolveRequestMessageTask.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/tasks/ResolveRequestMessageTask.ts b/src/tasks/ResolveRequestMessageTask.ts index b82a0200..78e4faec 100644 --- a/src/tasks/ResolveRequestMessageTask.ts +++ b/src/tasks/ResolveRequestMessageTask.ts @@ -43,16 +43,16 @@ export default class ResolveRequestMessageTask extends MessageTask { if ( origin.author ) { const response = BotConfig.request.prependResponseMessageInLog ? - RequestsUtil.getResponseMessage( origin ) : ''; + RequestsUtil.getResponseMessage( origin ) : ''; const log = new MessageEmbed() - .setColor( 'GREEN' ) - .setAuthor( origin.author.tag, origin.author.avatarURL() ) - .setDescription( origin.content ) - .addField( 'Channel', origin.channel.toString(), true ) - .addField( 'Message', `[Here](${ origin.url })`, true ) - .setFooter( `${ this.user.tag } resolved as ${ this.emoji }`, this.user.avatarURL() ) - .setTimestamp( new Date() ); + .setColor( 'GREEN' ) + .setAuthor( origin.author.tag, origin.author.avatarURL() ) + .setDescription( origin.content ) + .addField( 'Channel', origin.channel.toString(), true ) + .addField( 'Message', `[Here](${ origin.url })`, true ) + .setFooter( `${ this.user.tag } resolved as ${ this.emoji }`, this.user.avatarURL() ) + .setTimestamp( new Date() ); if ( origin.member.roles.cache.has( BotConfig.request.normalNotificationsRole ) && this.emoji === BotConfig.request.ignorePrependResponseMessageEmoji ) { if ( origin.member.roles.cache.has( BotConfig.request.oldNotificationsRole ) ) { From fc9334686b778bd7f4abb012f5014e0d0d178de1 Mon Sep 17 00:00:00 2001 From: chandler05 <66492208+chandler05@users.noreply.github.com> Date: Fri, 4 Dec 2020 08:06:09 -0600 Subject: [PATCH 15/15] Update template.yml --- config/template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/template.yml b/config/template.yml index 50e0926c..40feac7a 100644 --- a/config/template.yml +++ b/config/template.yml @@ -99,7 +99,7 @@ request: # Only applies to the oldNotificationsRole. oldNotificationsTimeDifference: - # The ID of the role that signifies users that get all notifications from their resolved requests regardless of the time it took to resolve. + # The ID of the role that signifies users that get all notifications from their resolved requests from a certain, longer, time period before. longNotificationsRole: # The amount of time in milliseconds that needs to occur after creating a request before a user will get a notification for their report.