@@ -189,7 +189,7 @@ export class ApiBotManagerService implements OnModuleInit {
189
189
throw new Error ( `Server ${ serverId } not found for bot ${ botId } ` )
190
190
}
191
191
192
- const { dryRun, commandChannel, mentionRoles, mentionUsers } = botServer
192
+ const { dryRun, commandChannel, mentionRoles, mentionUsers, verbose } = botServer
193
193
194
194
async function sendCommandChannel ( message : string ) {
195
195
if ( ! commandChannel ) {
@@ -204,7 +204,13 @@ export class ApiBotManagerService implements OnModuleInit {
204
204
const roles = await this . getBotRoles ( botId , serverId ) . then ( ( roles ) =>
205
205
roles . filter ( ( role ) => communityRoleIds . includes ( role . id ) ) ,
206
206
)
207
-
207
+ if ( ! roles . length ) {
208
+ this . logger . warn ( `No roles found for bot ${ botId } in server ${ serverId } ` )
209
+ return false
210
+ }
211
+ if ( verbose ) {
212
+ await sendCommandChannel ( `Syncing ${ roles . length } roles for ${ communityMembers . length } members` )
213
+ }
208
214
const roleMap : Record < string , string > = roles
209
215
. map ( ( role ) => ( { [ role . id ] : role . name } ) )
210
216
. reduce ( ( acc , role ) => ( { ...acc , ...role } ) , { } )
@@ -270,12 +276,15 @@ export class ApiBotManagerService implements OnModuleInit {
270
276
this . logger . warn ( `Accounts not in Discord server: ${ notFound . length } ` )
271
277
}
272
278
273
- this . logger . verbose ( `Synced ${ communityMembers . length } members in ${ serverId } for bot ${ botId } ` )
279
+ if ( verbose ) {
280
+ await sendCommandChannel ( `Synced ${ roles . length } roles ${ communityMembers . length } members` )
281
+ this . logger . verbose ( `Synced ${ communityMembers . length } members in ${ serverId } for bot ${ botId } ` )
282
+ }
274
283
275
284
return true
276
285
}
277
286
278
- async testBotServerConfig ( botId : string , serverId : string ) {
287
+ async testBotServerConfig ( userId : string , botId : string , serverId : string ) {
279
288
const bot = await this . core . data . bot . findUnique ( { where : { id : botId } , include : { community : true } } )
280
289
if ( ! bot ) {
281
290
throw new Error ( `Bot ${ botId } not found` )
@@ -298,14 +307,21 @@ export class ApiBotManagerService implements OnModuleInit {
298
307
if ( ! botServer . commandChannel ) {
299
308
throw new Error ( `This bot does not have a command channel set` )
300
309
}
301
-
310
+ const identity = await this . core . data . identity . findFirst ( {
311
+ where : { ownerId : userId , provider : IdentityProvider . Discord } ,
312
+ } )
313
+ if ( ! identity ) {
314
+ throw new Error ( `Discord Identity for user ${ userId } not found` )
315
+ }
302
316
const summary = await this . getCommunityRoleSummary ( bot . communityId )
303
317
304
318
await discordBot . sendChannel ( botServer . commandChannel , {
305
319
embeds : [
306
320
{
307
321
title : `Configuration for ${ discordBot . client ?. user ?. username } in ${ bot . community . name } (${ bot . community . cluster } )` ,
308
322
fields : [
323
+ { name : 'Requester' , value : `<@${ identity . providerId } >` } ,
324
+ { name : `Bot` , value : `<@${ discordBot . client ?. user ?. id } >` } ,
309
325
{ name : `Admin Role` , value : botServer . adminRole ? `<@&${ botServer . adminRole } >` : 'Not set' } ,
310
326
{ name : `Command Channel` , value : `<#${ botServer . commandChannel } >` } ,
311
327
{ name : `Dry Run` , value : botServer . dryRun ? 'Enabled' : 'Disabled' } ,
0 commit comments