/// <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; }
/// <summary> /// The program runs all discord services and loads all the data here. /// </summary> public void LoadDiscord() { bot = new Bot(new ClientInformation() { Name = "Miki", Version = "0.5", Token = Global.config.Token, ShardCount = Global.config.ShardCount, ConsoleLogLevel = LogLevel.ALL, DatabaseConnectionString = Global.config.ConnString }); if (!string.IsNullOrWhiteSpace(Global.config.SharpRavenKey)) { Global.ravenClient = new SharpRaven.RavenClient(Global.config.SharpRavenKey); } Global.redisClient = new StackExchangeRedisCacheClient(new ProtobufSerializer(), Global.config.RedisConnectionString); if (!string.IsNullOrWhiteSpace(Global.config.DatadogKey)) { var dogstatsdConfig = new StatsdConfig { StatsdServerName = Global.config.DatadogHost, StatsdPort = 8125, Prefix = "miki" }; DogStatsd.Configure(dogstatsdConfig); } bot.Events.AddCommandDoneEvent(x => { x.Name = "datadog-command-done"; x.processEvent = async(msg, cmd, success, t) => { if (!success) { DogStatsd.Counter("commands.error.rate", 1); } DogStatsd.Counter("commands.count", 1); DogStatsd.Histogram("commands.time", t, 0.1); }; }); bot.MessageReceived += Bot_MessageReceived; bot.OnError = async(ex) => Log.Message(ex.ToString()); bot.AddDeveloper(121919449996460033); foreach (ulong l in Global.config.DeveloperIds) { bot.AddDeveloper(l); } bot.Client.JoinedGuild += Client_JoinedGuild; bot.Client.LeftGuild += Client_LeftGuild; bot.OnShardConnect += Bot_OnShardConnect; bot.OnShardDisconnect += Bot_OnShardDisconnect; }