@@ -12,7 +12,7 @@ class Threading {
12
12
if ( ! recipientThread ) return ;
13
13
14
14
this . dm ( client , message , recipientThread ) ;
15
- } else if ( message . chanenl . type === "text" ) {
15
+ } else if ( message . channel . type === "text" ) {
16
16
const recipientThread = await Thread . findOne ( { channel : message . channel . id , closed : false } ) ;
17
17
if ( ! recipientThread ) return ;
18
18
@@ -22,7 +22,7 @@ class Threading {
22
22
23
23
static async dm ( client , message , thread ) {
24
24
const channel = client . channels . get ( thread . channel ) ;
25
- if ( ! channel ) console . log ( `Channel for thread ${ thread . id } can not be found.` ) ;
25
+ if ( ! channel ) message . channel . send ( `Channel for thread ${ thread . id } can not be found.` ) ;
26
26
27
27
const contentEmbed = new Discord . MessageEmbed ( )
28
28
. setAuthor ( message . author . tag , message . author . displayAvatarURL ( ) )
@@ -52,10 +52,56 @@ class Threading {
52
52
attachments : message . attachments . map ( a => a . proxyURL ) ,
53
53
timestamp : Date . now ( )
54
54
} ) . save ( ) ) ;
55
+
56
+ await message . react ( client . config . emojis . greenTick ) ;
55
57
}
56
58
57
59
static async channel ( client , message , thread , isAnonymous ) {
58
- // In case dm appears to come from a channel thread. (Support)
60
+ const user = client . users . get ( thread . recipient ) ;
61
+ const channel = client . channels . get ( thread . channel ) ;
62
+ if ( ! user ) message . chamnel . send ( `Recipient for thread ${ thread . id } can not be found.` ) ;
63
+
64
+ let contentEmbed = new Discord . MessageEmbed ( )
65
+ . setColor ( "YELLOW" )
66
+ . setTimestamp ( )
67
+ . setFooter ( "Support Assistant" ) ;
68
+
69
+ if ( isAnonymous ) {
70
+ contentEmbed . setDescription ( message . content . slice ( 2 ) ) ;
71
+ } else {
72
+ contentEmbed . setAuthor ( message . author . tag , message . author . displayAvatarURL ( ) ) ;
73
+ contentEmbed . setDescription ( message . content ) ;
74
+ }
75
+
76
+ user . send ( contentEmbed ) . catch ( e => { } ) ;
77
+ channel . send ( contentEmbed ) . catch ( e => { } ) ;
78
+ message . attachments . forEach ( attachment => {
79
+ let embed = new Discord . MessageEmbed ( )
80
+ . setColor ( "ORANGE" )
81
+ . setImage ( attachment . proxyURL )
82
+ . setFooter ( "Support Assistant" ) ;
83
+ if ( ! isAnonymous ) {
84
+ embed . setAuthor ( message . author . tag , message . author . displayAvatarURL ( ) ) ;
85
+ }
86
+ user . send ( embed ) . catch ( e => { } ) ;
87
+ channel . send ( embed ) . catch ( e => { } ) ;
88
+ } ) ;
89
+
90
+ const messageID = ( await Message . countDocuments ( { thread : thread . id } ) ) + 1 ;
91
+
92
+ await ( new Message ( {
93
+ thread : thread . id ,
94
+ message : messageID ,
95
+ recipient : thread . recipient ,
96
+ channel : message . channel . id ,
97
+ content : message . content ,
98
+ author : message . author . id ,
99
+ attachments : message . attachments . map ( a => a . proxyURL ) ,
100
+ anonymous : isAnonymous ,
101
+ timestamp : Date . now ( )
102
+ } ) . save ( ) ) ;
103
+
104
+ await message . react ( client . config . emojis . greenTick ) ;
59
105
}
60
106
}
61
107
0 commit comments