private async Task <Message> SendMessage(Channel channel, string text, bool isTextToSpeech)
        {
            Message msg;
            var     userIds = !channel.IsPrivate ? Mention.GetUserIds(text).Distinct() : new string[0];

            if (Config.UseMessageQueue)
            {
                var nonce = GenerateNonce();
                msg = _messages.GetOrAdd("nonce_" + nonce, channel.Id, _userId);
                var currentUser = msg.User;
                msg.Update(new MessageInfo
                {
                    Content   = text,
                    Timestamp = DateTime.UtcNow,
                    Author    = new UserReference {
                        Avatar = currentUser.AvatarId, Discriminator = currentUser.Discriminator, Id = _userId, Username = currentUser.Name
                    },
                    ChannelId      = channel.Id,
                    IsTextToSpeech = isTextToSpeech
                });
                msg.Mentions = userIds.Select(x => _users[x, channel.Server.Id]).Where(x => x != null).ToArray();
                msg.IsQueued = true;
                msg.Nonce    = nonce;
                _pendingMessages.Enqueue(msg);
            }
            else
            {
                var model = await _api.SendMessage(channel.Id, text, userIds, null, isTextToSpeech).ConfigureAwait(false);

                msg = _messages.GetOrAdd(model.Id, channel.Id, model.Author.Id);
                msg.Update(model);
                RaiseMessageSent(msg);
            }
            return(msg);
        }
        /// <summary> Edits the provided message, changing only non-null attributes. </summary>
        /// <remarks> While not required, it is recommended to include a mention reference in the text (see Mention.User). </remarks>
        public Task EditMessage(Message message, string text)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            if (text.Length > MaxMessageSize)
            {
                throw new ArgumentOutOfRangeException(nameof(text), $"Message must be {MaxMessageSize} characters or less.");
            }
            CheckReady();

            if (text != null && text.Length > MaxMessageSize)
            {
                text = text.Substring(0, MaxMessageSize);
            }

            return(_api.EditMessage(message.Id, message.Channel.Id, text, Mention.GetUserIds(text)));
        }