/// <summary> /// Queues a message to be sent to this discord client. /// </summary> /// <param name="msg">Text to send.</param> public void SendMessage(string msg) { if (AutoFlush) { Task.Run(async() => { try { Message m = await CommandChannel.SendMessage(msg); if (m?.State == MessageState.Failed) { TShock.Log.Error($"discord-bridge: Message broadcasting to channel '{CommandChannel.Name}' failed!"); } } catch (Exception ex) { TShock.Log.Error(ex.ToString()); } }); } else { _messages.Add(msg); } }
public async Task FlushMessages() { if (_messages.Count > 0) { try { Message m = await CommandChannel.SendMessage(String.Join("\n", _messages)); if (m?.State == MessageState.Failed) { TShock.Log.Error($"discord-bridge: Message broadcasting to channel '{CommandChannel.Name}' failed!"); } } catch (Exception ex) { TShock.Log.Error(ex.ToString()); } _messages.Clear(); } }