forked from Sarah/Lieb-Website
fixed renaming users
This commit is contained in:
parent
778c262642
commit
412e707e25
2 changed files with 16 additions and 3 deletions
|
@ -64,13 +64,22 @@ namespace DiscordBot.CommandHandlers
|
|||
if(guild != null)
|
||||
{
|
||||
SocketGuildUser user = guild.GetUser(userId);
|
||||
if(user == null)
|
||||
{
|
||||
await guild.DownloadUsersAsync();
|
||||
user = guild.GetUser(userId);
|
||||
}
|
||||
if(user != null)
|
||||
{
|
||||
await user.ModifyAsync(p => p.Nickname = nickname);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {}
|
||||
catch(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine(e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,16 @@ namespace DiscordBot
|
|||
|
||||
public async Task MainAsync(string[] args)
|
||||
{
|
||||
var dicordConfig = new DiscordSocketConfig();
|
||||
var discordConfig = new DiscordSocketConfig()
|
||||
{
|
||||
AlwaysDownloadUsers = true,
|
||||
GatewayIntents = GatewayIntents.GuildMembers
|
||||
};
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddSingleton(dicordConfig);
|
||||
builder.Services.AddSingleton(discordConfig);
|
||||
builder.Services.AddSingleton<DiscordSocketClient>();
|
||||
builder.Services.AddSingleton<CommandService>();
|
||||
builder.Services.AddSingleton<CommandHandler>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue