@@ -132,25 +132,78 @@ async function sendUnfollowedUserDiscordEmbed(user) {
132
132
embeds : [
133
133
{
134
134
title : `Successfully unfollowed ${ user . login } (${ user . id } )` ,
135
+ url : user . html_url ,
136
+ description : `Reason: ${ user . unfollow_reason } ` ,
135
137
thumbnail : {
136
138
url : user . avatar_url , // Set the user's avatar as the embed thumbnail
137
139
} ,
138
140
fields : [
139
141
{
140
- name : "Profile URL " ,
141
- value : `[ ${ user . login } ]( ${ user . html_url } )` , // Embed the link to the user's profile
142
- inline : true , // Single line for link
142
+ name : "Followed On " ,
143
+ value : new Date ( user . followed_on ) . toLocaleString ( ) , // Format the followed_on date
144
+ inline : true , // Single line for followed date
143
145
} ,
146
+ {
147
+ name : "Unfollowed On" ,
148
+ value : new Date ( ) . toLocaleString ( ) , // Display current time and date
149
+ inline : true , // Single line for unfollowed date
150
+ } ,
151
+ {
152
+ name : "Reason" ,
153
+ value : user . unfollow_reason , // Display current time and date
154
+ inline : true , // Single line for unfollowed date
155
+ } ,
156
+ ] ,
157
+ color : colorDecimal , // Use the custom color
158
+ footer : {
159
+ text : "Built by www.kevintrinh.dev" , // Add footer text
160
+ } ,
161
+ timestamp : new Date ( ) . toISOString ( ) ,
162
+ } ,
163
+ ] ,
164
+ } ) ;
165
+ //console.log(`Embed notification sent to Discord for unfollowed user ${user.login}!`);
166
+ } catch ( error ) {
167
+ console . error ( "Error sending Discord embed notification:" , error ) ;
168
+ }
169
+ }
170
+
171
+ // Function to send an embed for an unfollowed user object
172
+ async function sendMovedUserToUnfollowQueueDiscordEmbed ( user ) {
173
+ if ( ! isDiscordEnabled ) {
174
+ console . log (
175
+ "Discord integration is disabled. Skipping unfollowed user embed notification."
176
+ ) ;
177
+ return ;
178
+ }
179
+
180
+ const colorDecimal = hexToDecimal ( "#FFFF55" ) ; // Custom color in decimal
181
+
182
+ try {
183
+ await axios . post ( webhookURL , {
184
+ embeds : [
185
+ {
186
+ title : `Added user to unfollow queue: ${ user . login } (${ user . id } )` ,
187
+ url : user . html_url ,
188
+ thumbnail : {
189
+ url : user . avatar_url , // Set the user's avatar as the embed thumbnail
190
+ } ,
191
+ fields : [
144
192
{
145
193
name : "Followed On" ,
146
194
value : new Date ( user . followed_on ) . toLocaleString ( ) , // Format the followed_on date
147
195
inline : true , // Single line for followed date
148
196
} ,
149
197
{
150
- name : "Unfollowed On " ,
198
+ name : "Queue Timestamp " ,
151
199
value : new Date ( ) . toLocaleString ( ) , // Display current time and date
152
200
inline : true , // Single line for unfollowed date
153
201
} ,
202
+ {
203
+ name : "Reason" ,
204
+ value : user . unfollow_reason , // Display current time and date
205
+ inline : true , // Single line for unfollowed date
206
+ } ,
154
207
] ,
155
208
color : colorDecimal , // Use the custom color
156
209
footer : {
@@ -171,4 +224,5 @@ module.exports = {
171
224
sendDiscordEmbed,
172
225
sendFollowedUserDiscordEmbed,
173
226
sendUnfollowedUserDiscordEmbed,
227
+ sendMovedUserToUnfollowQueueDiscordEmbed,
174
228
} ;
0 commit comments