コード例 #1
0
ファイル: Developer.cs プロジェクト: LoliDevs/LoliBase
        public async Task PrefixSuccess(CommandContext ctx, [DSharpPlus.CommandsNext.Attributes.Description("The operation to be executed [add/list/del] ")]
                                        string operation)
        {
            switch (operation.ToLowerInvariant())
            {
            case "add":
                var msg = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Prefix to be added"));

                InteractivityResult <DiscordMessage> response = await ctx.Message.GetNextMessageAsync();

                var prefix = response.Result.Content;
                if (Program.Config.Prefixes.Contains(prefix.ToLowerInvariant()))
                {
                    await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"This prefix is already added."));
                }
                else
                {
                    Program.Config.Prefixes.Add(prefix.ToLowerInvariant());
                    File.WriteAllText(Directory.GetCurrentDirectory() + "/Config.json",
                                      JsonConvert.SerializeObject(Program.Config, Formatting.Indented));
                    await msg.ModifyAsync(embed : EmbedBase.OutputEmbed($"Prefix added without errors."));
                }

                break;

            case "del":
                var msg2 = await ctx.RespondAsync(embed : EmbedBase.InputEmbed("Prefix to be removed"));

                InteractivityResult <DiscordMessage> response2 = await ctx.Message.GetNextMessageAsync();

                var prefix2 = response2.Result.Content;
                if (!Program.Config.Prefixes.Contains(prefix2.ToLowerInvariant()))
                {
                    await msg2.ModifyAsync(embed : EmbedBase.OutputEmbed($"This prefix doesn't exists."));
                }
                else
                {
                    Program.Config.Prefixes.Remove(prefix2.ToLowerInvariant());
                    File.WriteAllText(Directory.GetCurrentDirectory() + "/Config.json",
                                      JsonConvert.SerializeObject(Program.Config, Formatting.Indented));
                    await msg2.ModifyAsync(embed : EmbedBase.OutputEmbed($"Prefix removed without errors."));
                }
                break;

            case "list":
                await ctx.RespondAsync(embed : EmbedBase.OrderedListEmbed(Program.Config.Prefixes, "Prefixes"));

                break;

            default:
                var embed = EmbedBase.CommandHelpEmbed(ctx.Command);
                await ctx.RespondAsync(embed : embed);

                break;
            }
        }
コード例 #2
0
ファイル: prisao.cs プロジェクト: joaodev123/CSUB
 public async Task soltarFailed(CommandContext ctx) => await ctx.RespondAsync(embed : EmbedBase.CommandHelpEmbed(ctx.Command));
コード例 #3
0
 public async Task AddFail(CommandContext ctx)
 {
     await ctx.RespondAsync(embed : EmbedBase.CommandHelpEmbed(ctx.Command));
 }
コード例 #4
0
ファイル: Developer.cs プロジェクト: LoliDevs/LoliBase
 public async Task PrefixError(CommandContext ctx)
 {
     var embed = EmbedBase.CommandHelpEmbed(ctx.Command);
     await ctx.RespondAsync(embed : embed);
 }
コード例 #5
0
 public async Task RemoveFail(CommandContext ctx) => await ctx.RespondAsync(embed : EmbedBase.CommandHelpEmbed(ctx.Command));