Esempio n. 1
0
        public async Task Send(ISocketMessageChannel channel)
        {
            List <EmbedBuilder> embeds = new List <EmbedBuilder>(1);

            StringBuilder currentField = new StringBuilder();
            EmbedBuilder  currentEmbed = getEmbedBuilder();

            foreach (string line in content)
            {
                Append(embeds, currentField, currentEmbed, line);
            }

            if (currentField.Length > 0)
            {
                Append(embeds, currentField, currentEmbed, string.Empty);
                currentEmbed.AddField("\0", currentField);
                embeds.Add(currentEmbed);
            }

            if (embeds.Count > 1)
            {
                for (int i = 0; i < embeds.Count; i++)
                {
                    embeds[i].Title += $" ({i + 1}/{embeds.Count})";
                }
            }

            foreach (EmbedBuilder embed in embeds)
            {
                await channel.SendEmbedAsync(embed);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sends as many embeds as necessary based on a list of embed fields. Adhering to the maximum of 25 embed fields per embed
        /// </summary>
        /// <param name="title">The title applied to all embeds</param>
        /// <param name="embeds">List of embed field builders</param>
        /// <param name="description">The description applied to all embeds</param>
        public async static Task SendSafeEmbedList(this ISocketMessageChannel channel, string title, List <EmbedFieldBuilder> embeds, string description = null)
        {
            List <EmbedBuilder> embedMessages  = new List <EmbedBuilder>();
            EmbedBuilder        CurrentBuilder = null;

            for (int i = 0; i < embeds.Count; i++)
            {
                if (i % 25 == 0)
                {
                    CurrentBuilder = new EmbedBuilder
                    {
                        Color = BotCore.EmbedColor,
                        Title = title
                    };
                    if (!string.IsNullOrEmpty(description))
                    {
                        CurrentBuilder.Description = description;
                    }
                    embedMessages.Add(CurrentBuilder);
                }

                EmbedFieldBuilder embed = embeds[i];
                if (CurrentBuilder != null)
                {
                    CurrentBuilder.AddField(embed);
                }
            }

            foreach (EmbedBuilder embedMessage in embedMessages)
            {
                await channel.SendEmbedAsync(embedMessage);
            }
        }
Esempio n. 3
0
 public static async Task ThrowAsync(this ISocketMessageChannel channel, string error, string reason = null)
 {
     EmbedBuilder eb = ExceptionEmbed;
     eb.WithTitle(error);
     if (reason.Exists())
         eb.WithDescription(reason);
     await channel.SendEmbedAsync(eb.Build());
 }
Esempio n. 4
0
 public static async Task CatchAsync(this ISocketMessageChannel channel, Exception exception)
 {
     EmbedBuilder eb = ExceptionEmbed;
     eb.WithTitle($"**Oops!**\nAn error has occured. `{exception.HResult}`");
     eb.WithDescription((exception.Message.Length > 2039 ? exception.Message.Substring(0, 2039) + "..." : exception.Message).DiscordBlock());
     eb.WithFooter(exception.StackTrace);
     await channel.SendEmbedAsync(eb.Build());
 }
Esempio n. 5
0
        public static Task SendHelpList(IDMCommandContext context, ISocketMessageChannel outputchannel = null)
        {
            EmbedBuilder embed = GetHelpListEmbed(context);

            if (outputchannel == null)
            {
                outputchannel = context.Channel;
            }
            return(outputchannel.SendEmbedAsync(embed));
        }
Esempio n. 6
0
        public static Task SendCommandCollectionHelp(IDMCommandContext context, CommandCollection collection, ISocketMessageChannel outputchannel = null)
        {
            EmbedBuilder embed = GetCommandCollectionEmbed(context, collection);

            if (outputchannel == null)
            {
                outputchannel = context.Channel;
            }
            return(outputchannel.SendEmbedAsync(embed));
        }
Esempio n. 7
0
 internal static async Task WelcomeNewUser(SocketUser user)
 {
     if (WelcomeMessageChannelId != 0)
     {
         ISocketMessageChannel channel = Var.client.GetChannel(WelcomeMessageChannelId) as ISocketMessageChannel;
         if (channel != null)
         {
             //await channel.SendMessageAsync(string.Format(welcomingMessage, user.Mention));
             await channel.SendEmbedAsync(user.Mention, string.Format(welcomingMessage, user.Mention));
         }
     }
 }
        public static async Task ReadAsync(this ISocketMessageChannel Channel, Interpreter itr, OldAccount a)
        {
            AccountOptions opts = AccountOptions.Default;

            if (opts.OutputFormat == OutputFormat.Markdown)
            {
                await Channel.SendMessageAsync(itr.Markdown());
            }
            else
            {
                await Channel.SendEmbedAsync(itr.Build(a));
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Sends a message into the Debug Message Channel if it is defined and Debug is true
 /// </summary>
 /// <param name="message">Message to send</param>
 public static async Task SendDebugMessage(string message, DebugCategories category)
 {
     if (DebugMessage != null)
     {
         await DebugMessage(new LogMessage(LogSeverity.Debug, category.ToString(), message));
     }
     if (debugLogging[(int)category] && DebugMessageChannelId != 0)
     {
         ISocketMessageChannel channel = Var.client.GetChannel(DebugMessageChannelId) as ISocketMessageChannel;
         if (channel != null)
         {
             EmbedBuilder debugembed = new EmbedBuilder();
             debugembed.Color       = Var.BOTCOLOR;
             debugembed.Title       = string.Format("**__Debug: {0}__**", category.ToString().ToUpper());
             debugembed.Description = message;
             await channel.SendEmbedAsync(debugembed);
         }
     }
 }
Esempio n. 10
0
        private static async Task MoveNext(ISocketMessageChannel channel, IndexArray <DesyncItem> desyncs)
        {
            var embed = desyncs.First.ToEmbed();

            embed.Footer = new EmbedFooterBuilder()
            {
                Text = "Desyncs left: " + desyncs.Count
            };
            var message = await channel.SendEmbedAsync(embed);

            GuildDesyncInteractiveMessage interactiveMessage = new GuildDesyncInteractiveMessage(message, desyncs);

            IEmote[] emotes = new IEmote[desyncs.First.Options.Count];
            for (int i = 0; i < emotes.Length; i++)
            {
                emotes[i] = UnicodeEmoteService.Numbers[i];
            }
            await message.AddReactionsAsync(emotes);
        }
Esempio n. 11
0
 public static async Task PaginatedReplyAsync(this ISocketMessageChannel channel, List<string> data, int page = 1, EmbedBuilder eb = null)
 {
     await channel.SendEmbedAsync(Paginate(data, page, eb));
 }