コード例 #1
0
        public async Task Shutdown(bool SaveChanges = true)
        {
            await Context.Message.AddReactionAsync(new Emoji("👋"));

            await ReplyAsync($":ok_hand: `{StringResourceHandler.GetTextStatic("Admin", "shutdown")}`").ConfigureAwait(false);

            LogManager.GetCurrentClassLogger().Info(">>SHUTTING DOWN");
            if (SaveChanges)
            {
                _config.SaveConfig(true);
            }
            LogManager.GetCurrentClassLogger().Info("Logging out...");
            await Context.Client.LogoutAsync().ConfigureAwait(false);

            LogManager.GetCurrentClassLogger().Info("The bot is now DOWN!");
            await Task.Delay(2000).ConfigureAwait(false);

            Environment.Exit(0);
        }
コード例 #2
0
        public async Task AddCustomReaction(string trigger, [Remainder] string response)
        {
            if (_config.EnableCustomReactions)
            {
                var  pleasewait       = Context.Channel.EnterTypingState();
                int  respnum          = 1;
                bool keyAlreadyExists = false;
                foreach (var existingKey in _config.CustomReactions.Keys)
                {
                    if (existingKey.ToLowerInvariant() == trigger.ToLowerInvariant())
                    {
                        keyAlreadyExists = true;
                        _config.CustomReactions[existingKey].Add(response);
                        respnum = _config.CustomReactions[existingKey].Count;
                        break;
                    }
                }
                if (!keyAlreadyExists)
                {
                    _config.CustomReactions.Add(trigger, new List <string>());
                    _config.CustomReactions[trigger].Add(response);
                }
                _config.SaveConfig(true);
                _config.ReloadConfig(false);
                var replyEmbed = new EmbedBuilder()
                                 .WithTitle("✨ " + StringResourceHandler.GetTextStatic("CustomReactions", "AddCustomReaction"))
                                 .AddField(StringResourceHandler.GetTextStatic("CustomReactions", "trigger"), trigger)
                                 .AddField(StringResourceHandler.GetTextStatic("CustomReactions", "response", respnum), response)
                                 .Build();
                await Context.Message.AddReactionAsync(new Emoji("✨"));

                pleasewait.Dispose();
                await ReplyAsync(Context.User.Mention, false, replyEmbed);
            }
            else
            {
                await Context.Message.AddReactionAsync(new Emoji("⛔"));
                await ReplyAsync($":no_entry: `{StringResourceHandler.GetTextStatic("CustomReactions", "disabled")}`").ConfigureAwait(false);
            }
        }