Example #1
0
        /// <summary>
        /// The program runs all discord services and loads all the data here.
        /// </summary>
        public void LoadDiscord()
        {
            bot = new Bot(x =>
            {
                x.Name            = "Miki";
                x.Version         = "0.3.71";
                x.Token           = Global.ApiKey;
                x.ShardCount      = Global.shardCount;
                x.ConsoleLogLevel = LogLevel.ALL;
            });

            bot.Events.OnCommandError = async(ex, cmd, msg) =>
            {
                RuntimeEmbed e = new RuntimeEmbed();
                e.Title = Locale.GetEntity(0).GetString(Locale.ErrorMessageGeneric);
                e.Color = new IA.SDK.Color(1, 0.4f, 0.6f);

                if (Notification.CanSendNotification(msg.Author.Id, DatabaseEntityType.USER, DatabaseSettingId.ERRORMESSAGE))
                {
                    e.Description = "Miki has encountered a problem in her code with your request. We will send you a log and instructions through PM.";

                    await msg.Channel.SendMessage(e);

                    e.Title       = $"You used the '{cmd.Name}' and it crashed!";
                    e.Description = "Please screenshot this message and send it to the miki issue page (https://github.com/velddev/miki/issues)";
                    e.AddField(f =>
                    {
                        f.Name     = "Error Message";
                        f.Value    = ex.Message;
                        f.IsInline = true;
                    });

                    e.AddField(f =>
                    {
                        f.Name     = "Error Log";
                        f.Value    = "```" + ex.StackTrace + "```";
                        f.IsInline = true;
                    });

                    e.CreateFooter();
                    e.Footer.Text = "Did you not want this message? use `>toggleerrors` to disable it!";

                    await msg.Author.SendMessage(e);

                    return;
                }
                e.Description = "... but you've disabled error messages, so we won't send you a PM :)";
                await msg.Channel.SendMessage(e);
            };

            bot.AddDeveloper(121919449996460033);

            if (!string.IsNullOrEmpty(devId))
            {
                bot.AddDeveloper(ulong.Parse(devId));
            }

            bot.Client.JoinedGuild += Client_JoinedGuild;
        }