Example #1
0
        public async Task Warnings(CommandContext ctx, [Description("The user to check warnings for. Leave blank to check your own.")] string userMention = null)
        {
            ulong userId = ctx.User.Id;

            if (userMention != null)
            {
                userId = Utils.GetId(userMention);
            }
            GuildUserData user = Database.GetOrCreateGuildData(ctx.Guild.Id).GetOrCreateUserData(userId);

            if (user.Warnings.Count == 0)
            {
                await ctx.RespondAsync("That user doesn't have any warnings in this server!");
            }
            else
            {
                foreach (var warning in user.Warnings)
                {
                    DiscordEmbedBuilder eb = new DiscordEmbedBuilder();
                    eb.WithAuthor($"{ctx.Guild.GetMemberAsync(userId).Result.Username}'s Warnings");
                    eb.AddField($"{warning.Item2.ToString("yyyy-MM-dd HH:mm:ss")}", $"Warned by <@!{warning.Item3}>\nReason: {warning.Item1}");
                    await ctx.RespondAsync(embed : eb.Build());
                }
            }
        }
Example #2
0
        public async Task AFK(CommandContext ctx, [RemainingText, Description("The message to set.")] string message = "AFK")
        {
            GuildUserData userData = Database.GetOrCreateGuildData(ctx.Guild.Id).GetOrCreateUserData(ctx.User.Id);

            userData.SetAFK(message);
            try
            {
                await ctx.Member.ModifyAsync(x => x.Nickname = $"[AFK] {ctx.Member.DisplayName}");
            }
            catch { }
            await ctx.RespondAsync($"Set your AFK: {message}");
        }
Example #3
0
        public async Task Warn(CommandContext ctx, [Description("The user to warn.")] string userMention, [RemainingText] string reason)
        {
            ulong userId           = Utils.GetId(userMention);
            DiscordEmbedBuilder eb = new DiscordEmbedBuilder();

            eb.WithAuthor("Warning Issued");
            if (reason != null)
            {
                eb.WithDescription($"Warned <@!{userId}>: **{reason}**");
            }
            else
            {
                eb.WithDescription($"Warned <@!{userId}>. No reason given.");
            }
            GuildUserData user = Database.GetOrCreateGuildData(ctx.Guild.Id).GetOrCreateUserData(userId);

            if (reason == "" || reason == null)
            {
                reason = "No reason given.";
            }
            user.AddWarning(reason, ctx.User.Id);
            user.FlushData();
            await ctx.RespondAsync(embed : eb.Build());
        }
Example #4
0
 static async Task MainMessageHandler(DiscordClient client, MessageCreateEventArgs e)
 {
     try
     {
         if (debug)
         {
             Console.WriteLine($"{e.Author.Username}#{e.Author.Discriminator}: {e.Message.Content}");
         }
         if (e.Author.Id == discord.CurrentUser.Id)
         {
             return;
         }
         if (e.Channel.IsPrivate)
         {
             return;
         }
         if (e.Author.IsBot)
         {
             return;
         }
         if (conversation)
         {
             await Conversation.Conversation.CarryOutConversation(e.Message);
         }
         if (LevelingData.Servers.ContainsKey(e.Guild.Id))
         {
             if (LevelingData.Servers[e.Guild.Id].Users.ContainsKey(e.Author.Id))
             {
                 await LevelingData.Servers[e.Guild.Id].Users[e.Author.Id].HandleMessage(e.Message);
             }
             else if (!e.Author.IsBot)
             {
                 LevelingData.Servers[e.Guild.Id].CreateUser(e.Message.Author.Id, DateTimeOffset.Now);
             }
         }
         foreach (var user in e.MentionedUsers)
         {
             GuildUserData mentionedUserData = Database.GetOrCreateGuildData(e.Guild.Id).GetOrCreateUserData(user.Id);
             if (mentionedUserData.IsAFK)
             {
                 await e.Channel.SendMessageAsync($"{user.Username} is AFK: {mentionedUserData.AFKMessage}\n({DateTimeOffset.Now.Subtract(mentionedUserData.AFKTime).ToString("g").Split('.')[0]} ago)");
             }
         }
         GuildUserData userData = Database.GetOrCreateGuildData(e.Guild.Id).GetOrCreateUserData(e.Author.Id);
         if (userData.IsAFK)
         {
             userData.RemoveAFK();
             try
             {
                 await e.Guild.GetMemberAsync(e.Author.Id).Result.ModifyAsync(x =>
                 {
                     x.Nickname = e.Guild.GetMemberAsync(e.Author.Id).Result.Nickname.Replace("[AFK] ", "");
                 });
             }
             catch { }
         }
         if (e.Author.Id == 366298290377195522 && e.Message.Content.ToLowerInvariant().Trim().Equals("am i right lads or am i right?"))
         {
             await e.Channel.SendMessageAsync("<@!366298290377195522> You are right lad!");
         }
     }
     catch (Exception ee)
     {
         Logger.Log(ee.ToString(), Logger.CBLogLevel.EXC);
     }
 }