@@ -27,14 +27,11 @@ public class DiscordService : IDiscordService, IHostedService
27
27
private readonly InteractionService _interactionService ;
28
28
private readonly IHttpClientFactory _httpClientFactory ;
29
29
30
- private ulong _updateMessageId = 1 ;
31
- private int _currentUpdateEmbedHash = 0 ;
32
-
33
30
public bool DiscordReady { get ; private set ; }
34
31
35
- private string prevthread = "" ;
36
- private ulong ? prevplauserid = 0 ;
37
- private string prevplugin = "" ;
32
+ private string _prevThread = "" ;
33
+ private ulong ? _prevPlaUserId = 0 ;
34
+ private string _prevPlugin = "" ;
38
35
39
36
public DiscordService ( BotConfig botConfig ,
40
37
DiscordSocketClient discordSocketClient ,
@@ -105,7 +102,7 @@ private async Task ThreadCreated(SocketThreadChannel thread) {
105
102
}
106
103
107
104
foreach ( var extension in extensions ) {
108
- if ( prevthread == thread . Name )
105
+ if ( _prevThread == thread . Name )
109
106
{
110
107
return ;
111
108
}
@@ -122,9 +119,9 @@ private async Task ThreadCreated(SocketThreadChannel thread) {
122
119
123
120
embed . AddField ( "Name" , $ "{ extension . Name } ({ extension . PackageId } )", true ) ;
124
121
embed . AddField ( "Author" , extension . DSupportUserId is not null ? $ "<@{ extension . DSupportUserId } >" : extension . Author , true ) ;
125
- prevthread = thread . Name ;
126
- prevplauserid = extension . DSupportUserId is not null ? ulong . Parse ( extension . DSupportUserId ) : null ;
127
- prevplugin = extension . PackageId ! ;
122
+ _prevThread = thread . Name ;
123
+ _prevPlaUserId = extension . DSupportUserId is not null ? ulong . Parse ( extension . DSupportUserId ) : null ;
124
+ _prevPlugin = extension . PackageId ! ;
128
125
129
126
var components = new ComponentBuilder ( )
130
127
. WithButton ( "Yes" , "plugin-problem-yes" , ButtonStyle . Success )
@@ -143,8 +140,8 @@ private async Task DiscordSocketClientOnButtonExecuted(SocketMessageComponent co
143
140
{
144
141
case "plugin-problem-yes" :
145
142
await component . Message . DeleteAsync ( ) ;
146
- await component . Channel . SendMessageAsync ( $ "<@{ prevplauserid } >, { component . User . Mention } has a problem on your plugin.") ;
147
- await ( component . Channel as SocketThreadChannel ) ! . ModifyAsync ( msg => msg . Name = @$ "{ component . Channel . Name } (Plugin Problem - { prevplugin } )") ;
143
+ await component . Channel . SendMessageAsync ( $ "<@{ _prevPlaUserId } >, { component . User . Mention } has a problem on your plugin.") ;
144
+ await ( component . Channel as SocketThreadChannel ) ! . ModifyAsync ( msg => msg . Name = @$ "{ component . Channel . Name } (Plugin Problem - { _prevPlugin } )") ;
148
145
await ( component . Channel as SocketThreadChannel ) ! . LeaveAsync ( ) ;
149
146
break ;
150
147
case "plugin-problem-no" :
@@ -270,7 +267,7 @@ private async Task MemberMovement(IGuildUser member, bool joined)
270
267
{
271
268
return ;
272
269
}
273
- _logger . Information ( "{User}#{Discriminator} {Action} the server" ,
270
+ _logger . Verbose ( "{User}#{Discriminator} {Action} the server" ,
274
271
member . Username ,
275
272
member . Discriminator ,
276
273
joined
@@ -330,7 +327,7 @@ public async Task BroadcastWebhookAsync(WebhookItem webhook, WebhookRequest webh
330
327
{
331
328
return ;
332
329
}
333
- _logger . Information ( "Executing Webhook {WebhookId}" , webhook . Id ) ;
330
+ _logger . Verbose ( "Executing Webhook {WebhookId}" , webhook . Id ) ;
334
331
if ( _discordSocketClient . GetGuild ( _botConfig . GuildId )
335
332
. GetChannel ( webhook . ChannelId ) is not ITextChannel channel )
336
333
{
@@ -340,7 +337,7 @@ public async Task BroadcastWebhookAsync(WebhookItem webhook, WebhookRequest webh
340
337
341
338
var text = ( webhookRequest . ToEveryone . HasValue && webhookRequest . ToEveryone . Value
342
339
? "@everyone"
343
- : ". " )
340
+ : "" )
344
341
+ "\r \n "
345
342
+ ( ! string . IsNullOrWhiteSpace ( webhookRequest . Title ) ? $ "**{ webhookRequest . Title } **\r \n " : "" )
346
343
+ webhookRequest . Text ;
@@ -357,6 +354,11 @@ public async Task BroadcastWebhookAsync(WebhookItem webhook, WebhookRequest webh
357
354
var color = webhookRequestEmbed . Color ;
358
355
embed . WithColor ( new Color ( color . R , color . G , color . B ) ) ;
359
356
}
357
+
358
+ if ( ! string . IsNullOrWhiteSpace ( webhookRequestEmbed . Title ) )
359
+ {
360
+ embed . Title = webhookRequestEmbed . Title ;
361
+ }
360
362
361
363
if ( ! string . IsNullOrWhiteSpace ( webhookRequestEmbed . Description ) )
362
364
{
0 commit comments