mirror of
https://github.com/RPCS3/discord-bot.git
synced 2026-07-19 13:54:44 -04:00
22 lines
755 B
C#
22 lines
755 B
C#
using CompatBot.Database;
|
|
using CompatBot.Utils.Extensions;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace CompatBot;
|
|
|
|
internal static class UserRolesValidationMonitor
|
|
{
|
|
public static async Task OnMemberAdded(DiscordClient client, GuildMemberAddedEventArgs args)
|
|
{
|
|
bool assignRole = false;
|
|
using (var rdb = await BotDb.OpenReadAsync().ConfigureAwait(false))
|
|
{
|
|
assignRole = await rdb.ForcedWarningRoles.AsNoTracking()
|
|
.AnyAsync(wr => wr.UserId == args.Member.Id)
|
|
.ConfigureAwait(false);
|
|
}
|
|
if (assignRole)
|
|
await args.Member.AddRoleAsync(Config.WarnRoleId, client, args.Guild, "User previously had this role assigned").ConfigureAwait(false);
|
|
}
|
|
}
|