users are now renamed after joining the discord server

This commit is contained in:
Sarah Faey 2022-11-21 23:05:10 +01:00
parent 601bd10c39
commit 17d8983fb0
4 changed files with 74 additions and 0 deletions

View file

@ -0,0 +1,37 @@
using Discord;
using Discord.Commands;
using Discord.WebSocket;
using System.Reflection;
using DiscordBot.Services;
using SharedClasses.SharedModels;
using DiscordBot.Messages;
namespace DiscordBot.CommandHandlers
{
public class UserHandler
{
private readonly DiscordSocketClient _client;
private readonly HttpService _httpService;
private readonly HandlerFunctions _handlerFunctions;
public UserHandler(DiscordSocketClient client,HttpService httpService)
{
_client = client;
_httpService = httpService;
_handlerFunctions = new HandlerFunctions(_httpService);
}
public async Task HandleUserJoined(SocketGuildUser user)
{
if((await _httpService.GetUserRenameServers()).Contains(user.Guild.Id))
{
if(await _httpService.DoesUserExist(user.Id))
{
ApiRaid.Role.User apiUser = await _httpService.GetUser(user.Id);
await HandlerFunctions.RenameUser(_client, user.Id, apiUser.UserName, apiUser.AccountName, new List<ulong>(){user.Guild.Id});
}
}
}
}
}