added try catch to avoid discord error message if renaming user is not possible
This commit is contained in:
parent
26dd595057
commit
104b938afc
1 changed files with 9 additions and 5 deletions
|
@ -58,15 +58,19 @@ namespace DiscordBot.CommandHandlers
|
||||||
string nickname = $"{name} | {account}";
|
string nickname = $"{name} | {account}";
|
||||||
foreach(ulong serverId in serverList)
|
foreach(ulong serverId in serverList)
|
||||||
{
|
{
|
||||||
SocketGuild guild = client.Guilds.FirstOrDefault(g => g.Id == serverId);
|
try
|
||||||
if(guild != null)
|
|
||||||
{
|
{
|
||||||
SocketGuildUser user = guild.GetUser(userId);
|
SocketGuild guild = client.Guilds.FirstOrDefault(g => g.Id == serverId);
|
||||||
if(user != null)
|
if(guild != null)
|
||||||
{
|
{
|
||||||
await user.ModifyAsync(p => p.Nickname = nickname);
|
SocketGuildUser user = guild.GetUser(userId);
|
||||||
|
if(user != null)
|
||||||
|
{
|
||||||
|
await user.ModifyAsync(p => p.Nickname = nickname);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue