Skip to content

Commit 89e94ff

Browse files
committed
Refactor EmitUserCreatedOrUpdatedEvent to use consistent user parameter naming
1 parent bbfddf7 commit 89e94ff

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

LDTTeam.Authentication.DiscordBot/Commands/ContextCommands.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@ public class ContextCommands(
3434
[CommandType(ApplicationCommandType.User)]
3535
[UsedImplicitly]
3636
public async Task<IResult> EmitUserCreatedOrUpdatedEvent(
37-
IUser discordUser)
37+
IUser user)
3838
{
3939
var executor = interactionContext.Interaction.Member;
4040
var executingUser = executor.FlatMap(m => m.User);
4141
var permissions = executor.FlatMap(m => m.Permissions);
4242
if (!permissions.HasValue &&
43-
!(executingUser.HasValue && executingUser.Value.ID.Equals(discordUser.ID)))
43+
!(executingUser.HasValue && executingUser.Value.ID.Equals(user.ID)))
4444
{
4545
return await feedbackService.SendContextualErrorAsync(
4646
"You are not authorized to run this command for other users"
4747
);
4848
}
4949

5050
if (permissions.HasValue && executingUser.HasValue
51-
&& !executingUser.Value.ID.Equals(discordUser.ID)
51+
&& !executingUser.Value.ID.Equals(user.ID)
5252
&& !permissions.Value.HasPermission(DiscordPermission.Administrator))
5353
{
5454
return Result.FromError(await feedbackService.SendContextualEmbedAsync(
@@ -73,15 +73,15 @@ public async Task<IResult> EmitUserCreatedOrUpdatedEvent(
7373
}));
7474
}
7575

76-
var user = await userRepository.GetBySnowflakeAsync(discordUser.ID);
77-
if (user == null)
76+
var portalUser = await userRepository.GetBySnowflakeAsync(user.ID);
77+
if (portalUser == null)
7878
{
7979
return Result.FromError(await feedbackService.SendContextualEmbedAsync(
8080
new Embed
8181
{
8282
Title = "Unknown User",
8383
Description =
84-
$"The user {discordUser.Username} is not registered in the authentication system. Ensure they have linked their Discord account.",
84+
$"The user {user.Username} is not registered in the authentication system. Ensure they have linked their Discord account.",
8585
Colour = Color.Red
8686
}));
8787
}
@@ -91,14 +91,14 @@ await bus.ExecuteProtectedAsync(
9191
"Failed to recalculate rewards",
9292
async b =>
9393
{
94-
await b.PublishAsync(new NewUserCreatedOrUpdated(user.UserId, user.Username));
94+
await b.PublishAsync(new NewUserCreatedOrUpdated(portalUser.UserId, portalUser.Username));
9595

9696
await feedbackService.SendContextualEmbedAsync(
9797
new Embed
9898
{
9999
Title = "Event emitted",
100100
Description =
101-
$"The user created or updated event for {user.Username} has been emitted, you might need to recalculate the rewards!",
101+
$"The user created or updated event for {portalUser.Username} has been emitted, you might need to recalculate the rewards!",
102102
Colour = Color.Green
103103
});
104104

0 commit comments

Comments
 (0)