Untitled

mail@pastecode.io avatar
unknown
python
2 months ago
9.6 kB
2
Indexable
Never
elif rule.value == "1.10":
            role_ban = discord.utils.get(user.guild.roles, id=1120737607484178512) #роль бана
            role_rule_mute = discord.utils.get(user.guild.roles, id=1115270636420468848) #роль мута
            role_pred = discord.utils.get(user.guild.roles, id=1120029727525187656) #роль преда
            try:
                if int(duration) > 14:
                    if int(duration) > 30:
                        try:
                            embed = discord.Embed(title="Ошибка <x_x>", description="Максимальная длительность бана - **30 дней**", color=0x2f3136)
                            embed.add_field(name=f"> Модератор", value=f"<@{interaction.user.id}>", inline=True)
                            embed.add_field(name=f"> Пользователь", value=f"<@{user.id}>", inline=True)
                            embed.add_field(name=f"> Причина", value=f"Нарушение пункта **{rule.value}**", inline=True)
                            embed.set_thumbnail(url = user.display_avatar.url)
                            embed.set_footer(text = "Сегодня в {:d}:{:02d}".format(current_dateTime.hour, current_dateTime.minute))
                            await interaction.response.send_message(content=f"||<@{interaction.user.id}>||", embed = embed, view = None)
                        except AttributeError:
                            pass
                    else:
                        if role_pred in user.roles:
                            print("нет")
                        await user.remove_roles(role_pred) 
                        button24 = discord.ui.Button(label="Подтвердить", style=discord.ButtonStyle.primary)
                        button25 = discord.ui.Button(label="Отмена", style=discord.ButtonStyle.red)
                        view = discord.ui.View()
                        view.add_item(button24)
                        view.add_item(button25)
                        embed = discord.Embed(title="Выдача бана", description="девелоперед by JustadlC3", color=0x2f3136)
                        embed.add_field(name=f"> Модератор", value=f"<@{interaction.user.id}>", inline=True)
                        embed.add_field(name=f"> Пользователь", value=f"<@{user.id}>", inline=True)
                        embed.add_field(name=f"> Причина", value=f"Нарушение пункта **{rule.value}**", inline=True)
                        embed.set_thumbnail(url = user.display_avatar.url)
                        embed.set_footer(text = "Сегодня в {:d}:{:02d}".format(current_dateTime.hour, current_dateTime.minute))
                        await interaction.response.send_message(content=f"||<@{interaction.user.id}>||", embed = embed, view = view)
                        async def button24_callback(interaction):
                            embed = discord.Embed(title="Бан успешно выдан", description="девелоперед by JustadlC3", color=0x2f3136)
                            embed.add_field(name=f"> Модератор", value=f"<@{interaction.user.id}>", inline=True)
                            embed.add_field(name=f"> Пользователь", value=f"<@{user.id}>", inline=True)
                            embed.add_field(name=f"> Причина", value=f"Нарушение пункта **{rule.value}**", inline=True)
                            embed.set_thumbnail(url = user.display_avatar.url)
                            embed.set_footer(text = "Сегодня в {:d}:{:02d}".format(current_dateTime.hour, current_dateTime.minute))
                            await interaction.response.edit_message(content=f"||<@{interaction.user.id}>||", embed = embed, view = None)
                            role_ban = discord.utils.get(user.guild.roles, id=1120737607484178512) #роль бана
                            role_pred = discord.utils.get(user.guild.roles, id=1120029727525187656)
                            if role_pred in user.roles:
                                await user.remove_roles(role_pred)
                            try:
                                remove_warns(ctx=None, member=user)
                                await user.add_roles(role_ban)
                                await asyncio.sleep(int(duration) * 3600)
                                await user.remove_roles(role_ban)
                            except:
                                pass
                        button24.callback = button24_callback
                else:
                    try:
                        embed = discord.Embed(title="Ошибка <x_x>", description="Минимальная длительность бана - **14 дней**", color=0x2f3136)
                        embed.add_field(name=f"> Модератор", value=f"<@{interaction.user.id}>", inline=True)
                        embed.add_field(name=f"> Пользователь", value=f"<@{user.id}>", inline=True)
                        embed.add_field(name=f"> Причина", value=f"Нарушение пункта **{rule.value}**", inline=True)
                        embed.set_thumbnail(url = user.display_avatar.url)
                        embed.set_footer(text = "Сегодня в {:d}:{:02d}".format(current_dateTime.hour, current_dateTime.minute))
                        await interaction.response.send_message(content=f"||<@{interaction.user.id}>||", embed = embed, view = None)
                    except AttributeError:
                        pass
            except ValueError:
                if duration == "None":
                    button24 = discord.ui.Button(label="Подтвердить", style=discord.ButtonStyle.primary)
                    button25 = discord.ui.Button(label="Отмена", style=discord.ButtonStyle.red)
                    view = discord.ui.View()
                    view.add_item(button24)
                    view.add_item(button25)
                    embed = discord.Embed(title="Выдача бана", description="девелоперед by JustadlC3", color=0x2f3136)
                    embed.add_field(name=f"> Модератор", value=f"<@{interaction.user.id}>", inline=True)
                    embed.add_field(name=f"> Пользователь", value=f"<@{user.id}>", inline=True)
                    embed.add_field(name=f"> Причина", value=f"Нарушение пункта **{rule.value}**", inline=True)
                    embed.set_thumbnail(url = user.display_avatar.url)
                    embed.set_footer(text = "Сегодня в {:d}:{:02d}".format(current_dateTime.hour, current_dateTime.minute))
                    await interaction.response.send_message(content=f"||<@{interaction.user.id}>||", embed = embed, view = view)
                    async def button24_callback(interaction):
                        embed = discord.Embed(title="Бан успешно выдан", description="девелоперед by JustadlC3", color=0x2f3136)
                        embed.add_field(name=f"> Модератор", value=f"<@{interaction.user.id}>", inline=True)
                        embed.add_field(name=f"> Пользователь", value=f"<@{user.id}>", inline=True)
                        embed.add_field(name=f"> Причина", value=f"Нарушение пункта **{rule.value}**", inline=True)
                        embed.set_thumbnail(url = user.display_avatar.url)
                        embed.set_footer(text = "Сегодня в {:d}:{:02d}".format(current_dateTime.hour, current_dateTime.minute))
                        await interaction.response.edit_message(content=f"||<@{interaction.user.id}>||", embed = embed, view = None)
                        role_ban = discord.utils.get(user.guild.roles, id=1120737607484178512) #роль бана
                        role_pred = discord.utils.get(user.guild.roles, id=1120029727525187656)
                        if role_pred in user.roles:
                            await user.remove_roles(role_pred)
                        try:
                            remove_warns(ctx=None, member=user)
                            await user.add_roles(role_ban)
                            await asyncio.sleep(14 * 3600)
                            await user.remove_roles(role_ban)
                        except:
                            pass
                    button24.callback = button24_callback
                else:
                    try:
                        embed = discord.Embed(title="Ошибка <x_x>", description="Буквы в параметре **duration**", color=0x2f3136)
                        embed.add_field(name=f"> Модератор", value=f"<@{interaction.user.id}>", inline=True)
                        embed.add_field(name=f"> Пользователь", value=f"<@{user.id}>", inline=True)
                        embed.add_field(name=f"> Причина", value=f"Нарушение пункта **{rule.value}**", inline=True)
                        embed.set_thumbnail(url = user.display_avatar.url)
                        embed.set_footer(text = "Сегодня в {:d}:{:02d}".format(current_dateTime.hour, current_dateTime.minute))
                        await interaction.response.send_message(content=f"||<@{interaction.user.id}>||", embed = embed, view = None)
                    except AttributeError:
                        pass
Leave a Comment