Example #1
0
        public async Task PrefixAsync(EventContext e)
        {
            var    cache = (ICacheClient)e.Services.GetService(typeof(ICacheClient));
            string args  = e.Arguments.Pack.TakeAll();

            if (string.IsNullOrEmpty(args))
            {
                await e.ErrorEmbed(e.Locale.GetString("miki_module_general_prefix_error_no_arg")).ToEmbed().QueueToChannelAsync(e.Channel);

                return;
            }

            PrefixInstance defaultInstance = e.commandHandler.GetDefaultPrefix();

            using (var context = new MikiContext())
            {
                await defaultInstance.ChangeForGuildAsync(context, cache, e.Guild.Id, args);
            }

            EmbedBuilder embed = new EmbedBuilder();

            embed.SetTitle(e.Locale.GetString("miki_module_general_prefix_success_header"));
            embed.SetDescription(
                e.Locale.GetString("miki_module_general_prefix_success_message", args
                                   ));

            await embed.ToEmbed().QueueToChannelAsync(e.Channel);
        }
Example #2
0
        public async Task PrefixAsync(EventContext e)
        {
            if (string.IsNullOrEmpty(e.Arguments.ToString()))
            {
                e.ErrorEmbed(e.Locale.GetString("miki_module_general_prefix_error_no_arg")).ToEmbed().QueueToChannel(e.Channel);
                return;
            }

            PrefixInstance defaultInstance = e.commandHandler.GetDefaultPrefix();

            using (var context = new MikiContext())
            {
                await defaultInstance.ChangeForGuildAsync(context, Global.RedisClient, e.Guild.Id, e.Arguments.ToString());
            }

            EmbedBuilder embed = Utils.Embed;

            embed.SetTitle(e.Locale.GetString("miki_module_general_prefix_success_header"));
            embed.SetDescription(e.Locale.GetString("miki_module_general_prefix_success_message", e.Arguments.ToString()));

            embed.ToEmbed().QueueToChannel(e.Channel);
        }