@@ -13,7 +13,12 @@ export default {
1313 context : BotContext ,
1414 reactionWasRemoved : boolean ,
1515 ) {
16- const channel = reactionEvent . message . channel ;
16+ const message = await reactionEvent . message . fetch ( ) ;
17+ if ( message . guild === null ) {
18+ throw new Error ( "Message guild is null" ) ;
19+ }
20+
21+ const channel = message . channel ;
1722 if ( ! channel . isTextBased ( ) ) {
1823 throw new Error ( "Channel is not text based" ) ;
1924 }
@@ -22,29 +27,23 @@ export default {
2227 return ;
2328 }
2429
25- const message = await reactionEvent . message . fetch ( ) ;
26- const { guild } = message ;
27- if ( guild === null ) {
28- throw new Error ( "Guild is null" ) ;
29- }
30-
3130 const botUser = context . client . user ;
3231 if ( message . author . id !== botUser . id ) {
3332 return ;
3433 }
3534
36- const member = await guild . members . fetch ( invoker . id ) ;
3735 if ( reactionEvent . emoji . name !== "✅" ) {
3836 return ;
3937 }
4038
39+ const member = await message . guild . members . fetch ( invoker . id ) ;
4140 if ( ! member . id || member . id === botUser . id ) {
4241 return ;
4342 }
4443
4544 // Some roles, especially "C" are prefixed with a invisible whitespace to ensure they are not mentioned
4645 // by accident.
47- const role = guild . roles . cache . find (
46+ const role = message . guild . roles . cache . find (
4847 r => r . name . replace ( / [ \u200B - \u200D \uFEFF ] / g, "" ) === message . content ,
4948 ) ;
5049
0 commit comments