Esempio n. 1
0
        public static async Task <IUserMessage> SendMessageAsync(this IMessageChannel channel,
                                                                 BaseUser user,
                                                                 Message message,
                                                                 RequestOptions options = null)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var content = new StringBuilder();

            if (user.Notifier.CanNotify)
            {
                content.AppendLine(user.Notifier.Notify(2000 - (message.Text?.Length ?? 0)));
                user.Notifier.LastNotified = DateTime.UtcNow;
            }

            if (!string.IsNullOrWhiteSpace(message.Text))
            {
                content.Append(message.Text);
            }

            if (!string.IsNullOrWhiteSpace(message.AttachmentUrl))
            {
                return(await channel.SendFileAsync(message.AttachmentUrl, content.ToString(), message.IsTTS, message.Embed, options, message.IsSpoiler));
            }

            return(await channel.SendMessageAsync(content.ToString(), message.IsTTS, message.Embed, options));
        }
        public override string OnWriteMenu(InfoService service, BaseUser user = null)
        {
            bool showTooltips = user?.Config?.Tooltips ?? true;

            var menu = new StringBuilder();

            menu.AppendLine(GetMenuHeader(showTooltips));
            menu.Append(GetMenuGuides());
            menu.Append(GetMenuCategories(service));

            return(menu.ToString());
        }
Esempio n. 3
0
        public static async Task <IUserMessage> SendMessageAsync(this IMessageChannel channel,
                                                                 BaseUser user,
                                                                 string text                     = null,
                                                                 bool isTTS                      = false,
                                                                 Embed embed                     = null,
                                                                 RequestOptions options          = null,
                                                                 AllowedMentions allowedMentions = null)
        {
            var content = new StringBuilder();

            if (user.Notifier.CanNotify)
            {
                text ??= string.Empty;
                content.AppendLine(user.Notifier.Notify(2000 - text.Length));
                user.Notifier.LastNotified = DateTime.UtcNow;
            }

            if (!string.IsNullOrWhiteSpace(text))
            {
                content.Append(text);
            }

            return(await channel.SendMessageAsync(content.ToString(), isTTS, embed, options, allowedMentions));
        }
Esempio n. 4
0
 public abstract string OnWriteMenu(InfoService service, BaseUser user = null);