add try catch
This commit is contained in:
parent
47de266915
commit
70eedefb37
1 changed files with 13 additions and 5 deletions
|
|
@ -716,12 +716,20 @@ namespace SecondBotEvents.Services
|
||||||
return reply.Id;
|
return reply.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ulong SendMessageToChannel(ulong serverid, ulong channelid, string message)
|
public ulong? SendMessageToChannel(ulong serverid, ulong channelid, string message)
|
||||||
{
|
{
|
||||||
SocketGuild server = DiscordClient.GetGuild(serverid);
|
try
|
||||||
ITextChannel channel = server.GetTextChannel(channelid);
|
{
|
||||||
IMessage reply = channel.SendMessageAsync(message).GetAwaiter().GetResult();
|
SocketGuild server = DiscordClient.GetGuild(serverid);
|
||||||
return reply.Id;
|
ITextChannel channel = server.GetTextChannel(channelid);
|
||||||
|
IMessage reply = channel.SendMessageAsync(message).GetAwaiter().GetResult();
|
||||||
|
return reply.Id;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
LogFormater.Crit("Discord service: Failed to send message to channel "+channelid.ToString()+" on server: "+serverid.ToString()+" because: "+e.Message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string GetChannelName(string input)
|
protected string GetChannelName(string input)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue