/// <summary> /// send a message to the #server-status channel /// </summary> public void EnqueueEvent_ServerStatus(string text) { DiscordEvent discordEvent = new DiscordEvent(); discordEvent.textChannelId = _setting.discordBotChannelServerStatus; discordEvent.text = text; EnqueueEvent(discordEvent); }
/// <summary> /// send a message to the #server-status channel /// </summary> public void Send_ServerStatus(string text) { DiscordEvent discordEvent = new DiscordEvent(); discordEvent.textChannelId = _setting.discordBotChannelServerStatus; discordEvent.text = text; if (!Send(discordEvent)) { _Logger.Debug($"Discord event not send: {text}"); } }
public async Task <bool> SendAsync(DiscordEvent discordEvent) { if (!_ready) { return(false); } if (discordEvent == null) { _Logger.Error("DiscordEvent is null"); return(false); } try { DiscordSocketClient client = _service.GetRequiredService <DiscordSocketClient>(); SocketGuild guild = client.GetGuild(_setting.discordGuild); if (guild == null) { return(false); } SocketTextChannel textChannel = guild.GetTextChannel(discordEvent.textChannelId); if (textChannel == null) { return(false); } await textChannel.SendMessageAsync(discordEvent.text); return(true); } catch (Exception ex) { _Logger.Exception(ex); } return(false); }
public bool Send(DiscordEvent discordEvent) { Task <bool> sendTask = SendAsync(discordEvent); return(sendTask.Result); }
public void EnqueueEvent(DiscordEvent discordEvent) { _events.Add(discordEvent); }