Exemple #1
0
        public async Task <String> GetPrefix()
        {
            var config = BotConfig.New();

            if (GetGuild() == null)
            {
                return("g!");
            }
            var guildId = (Int64)GetGuild().Id;

            if (await config.GetGuildAsync(guildId) == null)
            {
                return("g!");
            }
            return((await config.GetGuildAsync(guildId)).CustomPrefix ?? "g!");
        }
        public static async Task Yardim(MRCommandCtx ctx)
        {
            var currentAssembly = Assembly.GetExecutingAssembly();
            var assemblyTypes   = currentAssembly.GetTypes();
            var tmp1            = assemblyTypes
                                  .Select(type => type.GetMethods());
            var methods = new List <MethodInfo>();

            foreach (var methodInfos in tmp1)
            {
                methods.AddRange(methodInfos);
            }
            var dict         = methods.Where(method => method.GetCustomAttributes().Any(attr => attr is CommandAttribute));
            var embedBuilder = new DiscordEmbedBuilder();

            embedBuilder
            .WithTitle("Yardım")
            .WithColor(DiscordColor.Blue);
            String description;
            var    descriptionBuilder = new StringBuilder();
            var    prefix             = $"{(BotConfig.New().GetGuildAsync((Int64) ctx.Channel.GuildId).Result == null ? "g!" : BotConfig.New().GetGuildAsync((Int64) ctx.Channel.GuildId).Result!.CustomPrefix ?? "g!")}";

            descriptionBuilder.AppendLine("Prefix: " + prefix);
            descriptionBuilder.Append("\n");
            foreach (var methodInfo in dict)
            {
                var attributes =
                    (CommandAttribute)methodInfo.GetCustomAttributes()
                    .First(attribute => attribute is CommandAttribute);

                description = attributes.Description ?? "*Açıklama yok.*";
                String alias = attributes.Alias ?? methodInfo.Name;
                descriptionBuilder.AppendLine($"**{alias}** :: {description}");
            }
            description = descriptionBuilder.ToString();
            embedBuilder.WithDescription(description);
            var builder = embedBuilder.Build();
            await ctx.ReplyAsync(embed : builder);
        }