public async Task ChangeNickname([Remainder] string nickname)
        {
            SocketGuildUser user    = (SocketGuildUser)Context.User;
            UserNicknames   account = UsersNicknames.GetNicknames(Context.User.Id);

            if (DateTime.Compare(DateTime.Now, account.TimeToNickChange) >= 0)
            {
                if (nickname.Length > 32)
                {
                    await Context.Channel.SendMessageAsync("Nick jest za długi. Przekroczyłeś odgórne limity Discorda.");
                }
                else
                {
                    await user.ModifyAsync(x =>
                    {
                        x.Nickname = nickname;
                    });

                    GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(Context.Guild);

                    account.Nicknames.Add(nickname);
                    account.TimeToNickChange = DateTime.Now + TimeSpan.FromDays(guildCfg.DaysTillNextNicknameChange);

                    UsersNicknames.Save();

                    await Context.Channel.SendMessageAsync($"Pomyślnie zmieniono pseudonim. Następna zmiana będzie możliwa dopiero {account.TimeToNickChange}");
                }
            }
            else
            {
                await Context.Channel.SendMessageAsync($"Nie możesz zmienić pseudonimu. Będziesz to mógł zrobić dopiero {account.TimeToNickChange}");
            }
        }
        public static async void MonitorChannel(SocketCommandContext context)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(context.Guild);
            ISocketMessageChannel logChannel = (ISocketMessageChannel)Methods.GetTextChannelByID(context.Guild, guildCfg.LogChannelID);

            await logChannel.SendMessageAsync($"{context.Message.CreatedAt} | {context.Message.Author} | {context.Message.Content}");
        }
Beispiel #3
0
        public async Task Cfg(IRole adminRole, IRole modRole, IRole userRole, IRole maleRole, IRole femaleRole, IRole punishmentRole,
                              ITextChannel modChannel, ITextChannel generalChannel, ITextChannel statuteChannel, ITextChannel logChannel,
                              ITextChannel inChannel, ITextChannel outChannel, ITextChannel touChannel, ITextChannel punishChannel,
                              uint days = 0, uint warnDuration = 0)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(Context.Guild);

            guildCfg.AdminRoleID      = adminRole.Id;
            guildCfg.ModeratorRoleID  = modRole.Id;
            guildCfg.UserRoleID       = userRole.Id;
            guildCfg.MaleRoleID       = maleRole.Id;
            guildCfg.FemaleRoleID     = femaleRole.Id;
            guildCfg.PunishmentRoleID = punishmentRole.Id;

            guildCfg.ModeratorChannelID  = modChannel.Id;
            guildCfg.GeneralChannelID    = generalChannel.Id;
            guildCfg.StatuteChannelID    = statuteChannel.Id;
            guildCfg.LogChannelID        = logChannel.Id;
            guildCfg.InChannelID         = inChannel.Id;
            guildCfg.OutChannelID        = outChannel.Id;
            guildCfg.ToUChannelID        = touChannel.Id;
            guildCfg.PunishmentChannelID = punishChannel.Id;

            guildCfg.DaysTillNextNicknameChange = days;
            guildCfg.WarnDuration = warnDuration;

            GuildsCfgs.Save();

            GuildCfg guildCfg2 = GuildsCfgs.GetGuildCfg(Context.Guild);

            await Context.Channel.SendMessageAsync($"{guildCfg2.GuildID}|{guildCfg2.UserRoleID}");
        }
        public static async Task UserBanned(SocketUser arg1, SocketGuild arg2)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(arg2);
            ISocketMessageChannel modChannel = (ISocketMessageChannel)Methods.GetTextChannelByID(arg2, guildCfg.ModeratorChannelID);

            RestBan ban = arg2.GetBansAsync().Result.ToList().FirstOrDefault(x => x.User.Id == arg1.Id);

            await modChannel.SendMessageAsync($"{ban.User.Mention} ({ban.User.Id}) otrzymał bana. Powód: {ban.Reason}");
        }
        public async Task Mute(SocketGuildUser user, bool mute)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(Context.Guild);

            ISocketMessageChannel modChannel = (ISocketMessageChannel)Methods.GetTextChannelByID(Context.Guild, guildCfg.ModeratorChannelID);

            UserExpMute account = UsersExpMute.GetExpMute(user.Id);

            account.IsMuted = mute;

            UsersExpMute.Save();

            await modChannel.SendMessageAsync($"Pomyślnie zmieniono możliwość swobodnej wypowiedzi użytkownikowi {user.Mention} na: {!account.IsMuted}.");
        }
        public async Task GiveKarcerAsync(SocketGuildUser user, byte time, [Remainder] string reason)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(Context.Guild);

            IDMChannel dmChannel = await user.GetOrCreateDMChannelAsync();

            ISocketMessageChannel modChannel = (ISocketMessageChannel)Methods.GetTextChannelByID(Context.Guild, guildCfg.ModeratorChannelID);

            SocketRole role = Methods.GetRoleByID(Context.Guild, guildCfg.PunishmentRoleID);
            await user.AddRoleAsync(role);

            await dmChannel.SendMessageAsync($"Zostałeś wysłany na {time}h do {role.Name}, z powodu: {reason}");

            await modChannel.SendMessageAsync($"Karc{time}: Użytkownik {user.Mention} został wysłany na {time}h do {role.Name}, z powodu: {reason}");
        }
Beispiel #7
0
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg((SocketGuild)context.Guild);

            SocketRole role = Methods.GetRoleByID((SocketGuild)context.Guild, guildCfg.UserRoleID);

            if (!(context.User as SocketGuildUser).Roles.Contains(role))
            {
                return(Task.FromResult(PreconditionResult.FromSuccess()));
            }
            else
            {
                return(Task.FromResult(PreconditionResult.FromError($"Wywołujący jest już użytkownikiem")));
            }
        }
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg((SocketGuild)context.Guild);

            SocketGuildChannel channel = Methods.GetTextChannelByID((SocketGuild)context.Guild, guildCfg.ToUChannelID);

            if (context.Channel == channel)
            {
                return(Task.FromResult(PreconditionResult.FromSuccess()));
            }
            else
            {
                return(Task.FromResult(PreconditionResult.FromError($"Niewłaściwy kanał.")));
            }
        }
        public override Task <PreconditionResult> CheckPermissionsAsync(ICommandContext context, CommandInfo command, IServiceProvider services)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg((SocketGuild)context.Guild);

            IRole role = Methods.GetRoleByID((SocketGuild)context.Guild, guildCfg.ModeratorRoleID);

            if ((context.User as SocketGuildUser).Roles.Contains(role) || (context.User as SocketGuildUser).GuildPermissions.Administrator)
            {
                return(Task.FromResult(PreconditionResult.FromSuccess()));
            }
            else
            {
                return(Task.FromResult(PreconditionResult.FromError($"Nie masz uprawnień")));
            }
        }
        public async Task Reminder(SocketGuildUser user, [Remainder] string reason = "Naruszenie regulaminu serwera")
        {
            try
            {
                GuildCfg   guildCfg  = GuildsCfgs.GetGuildCfg(Context.Guild);
                IDMChannel dmChannel = await user.GetOrCreateDMChannelAsync();

                await dmChannel.SendMessageAsync($"{user.Mention} otrzymałeś upomnienie, powód: {reason}\nPolecam przeczytać regulamin dostępny na <#{guildCfg.StatuteChannelID}>.");

                await Context.Channel.SendMessageAsync($"Upom100: Dokładna treść wysłanej wiadomości:\n{user.Mention} otrzymałeś upomnienie, powód: {reason}\nPolecam przeczytać regulamin dostępny na <#{guildCfg.StatuteChannelID}>.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public async Task Praise(SocketUser user, [Remainder] string reason)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(Context.Guild);
            ISocketMessageChannel generalChannel = (ISocketMessageChannel)Methods.GetTextChannelByID(Context.Guild, guildCfg.GeneralChannelID);
            UserPraises           account        = UsersPraises.GetUserPraises(user.Id);

            uint id = (uint)account.Praises.Count;

            Praise praise = Praises.CreatePraise(user, id, reason);

            account.Praises.Add(praise);
            UsersPraises.Save();

            await generalChannel.SendMessageAsync($"Użytkownik {user.Mention} otrzymał pochwałę od {Context.User.Username}. Powód: {reason}");

            await Context.Channel.SendMessageAsync("Dodano pochwałę.");
        }
        public async Task Warn(SocketGuildUser user, [Remainder] string reason = "Naruszenie regulaminu serwera")
        {
            Random random = new Random(DateTime.Now.Millisecond);
            uint   id     = (uint)random.Next(0, 100000);

            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(Context.Guild);

            IDMChannel dmChannel = await user.GetOrCreateDMChannelAsync();

            ISocketMessageChannel modChannel = (ISocketMessageChannel)Methods.GetTextChannelByID(Context.Guild, guildCfg.ModeratorChannelID);

            UserWarnings account = UsersWarnings.GetUserWarnings(user);
            SocketRole   role    = Methods.GetRoleByID(Context.Guild, guildCfg.PunishmentRoleID);

            Methods.DeleteExpiredWarnings(account);

            Warning warning = Warnings.CreateWarning(id, reason, guildCfg.WarnDuration);

            account.Warnings.Add(warning);
            UsersWarnings.Save();

            string msg     = "";
            string message = "";

            if (account.Warnings.Count >= 5)
            {
                await user.BanAsync(0, "Przekroczenie limitu ostrzeżeń.");
            }
            else if (account.Warnings.Count > 2)
            {
                await user.AddRoleAsync(role);

                msg     = $"{user.Mention} przekroczyłeś limit dopuszczalnych ostrzeżeń, co spowodowało Twój pobyt w {role.Name}.\nPowód ostatniego ostrzeżenia: {reason}\nPolecam przeczytać regulamin dostępny na <#{guildCfg.StatuteChannelID}>.";
                message = $"KarcNaN: Przekroczono limit ostrzeżeń, co skutkuje pobytem {user.Mention} w Karcerze.\nDokładna treść wysłanej wiadomości:\n{msg}";
            }
            else
            {
                msg     = $"{user.Mention} otrzymałeś ostrzeżenie, powód: {reason}\nMasz {account.Warnings.Count} ostrzeżeń (maksymalnie możesz mieć 2, każdy kolejny, to {role.Name}).\nPolecam przeczytać regulamin dostępny na <#{guildCfg.StatuteChannelID}>.";
                message = $"Ostrz101: Dokładna treść wysłanej wiadomości:\n{msg}";
            }

            await dmChannel.SendMessageAsync(msg);

            await modChannel.SendMessageAsync(message);
        }
        public async Task RemoveWarning(SocketGuildUser user, uint id)
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(Context.Guild);

            ISocketMessageChannel modChannel = (ISocketMessageChannel)Methods.GetTextChannelByID(Context.Guild, guildCfg.ModeratorChannelID);

            UserWarnings account = UsersWarnings.GetUserWarnings(user);
            Warning      warning = Warnings.GetWarning(account, id);

            if (warning != null)
            {
                account.Warnings.Remove(warning);

                UsersWarnings.Save();

                await modChannel.SendMessageAsync($"Pomyślnie usunięto ostrzeżenie {warning.ID} z konta {user.Mention}.");
            }
            else
            {
                await modChannel.SendMessageAsync($"Coś poszło nie tak... Czy na pewno użyłeś dobrego ID? 🤔");
            }
        }
Beispiel #14
0
        public async Task CfgCheck()
        {
            GuildCfg guildCfg = GuildsCfgs.GetGuildCfg(Context.Guild);

            await Context.Channel.SendMessageAsync($"{guildCfg.GuildID}|{guildCfg.UserRoleID}");
        }