This repository was archived by the owner on Mar 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
96 lines (83 loc) · 3.91 KB
/
bot.py
File metadata and controls
96 lines (83 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import configparser
import disnake
from disnake.ext import commands
from disnake import TextInputStyle
config = configparser.ConfigParser() # создаём объекта парсера
config.read("config.ini") # читаем конфиг
bot = commands.InteractionBot(test_guilds=[int(config["Auth"]["guild_id"])])
@bot.event
async def on_ready():
await bot.change_presence(activity=disnake.Activity(type=disnake.ActivityType.watching, name="на развитие Bisquit.Host"))
@bot.slash_command(
name="create-button",
description="Заспавнить кнопку создания тикета.",
)
@commands.has_guild_permissions(administrator=True)
async def buttons(inter: disnake.ApplicationCommandInteraction):
embed = disnake.Embed(
title="Создать тикет",
description="Если у вас возникла проблема или вам нужна помощь. Вы можете создать тикет, для этого нажмите на кнопку ниже. Команда поддержки свяжется с вами и постарается Вам помочь.",
color=0x46ec12,
)
await inter.channel.send(
components=[disnake.ui.Button(label="Создать тикет", style=disnake.ButtonStyle.success, custom_id="+", emoji="📩")],
embed=embed
)
await inter.send("Кнопка успешно создана.", ephemeral=True)
@bot.listen("on_button_click")
async def help_listener(inter: disnake.MessageInteraction):
if inter.component.custom_id not in ["+", "-"]:
return
if inter.component.custom_id == "+":
await inter.response.send_modal(modal=MyModal())
elif inter.component.custom_id == "-":
await inter.channel.delete()
class MyModal(disnake.ui.Modal):
def __init__(self):
components = [
disnake.ui.TextInput(
label="Тема",
placeholder="Введите тему тикета",
custom_id="theme",
style=TextInputStyle.short,
max_length=50,
),
disnake.ui.TextInput(
label="Описание проблемы",
placeholder="Подробно опишите вашу проблему.",
custom_id="description",
style=TextInputStyle.paragraph,
),
]
super().__init__(title="Создать тикет", components=components)
async def callback(self, inter: disnake.ModalInteraction):
guild22 = inter.guild
await inter.response.send_message("Ваш тикет создан.", ephemeral=True)
techSupport = guild22.get_role(int(config["Roles"]["support"]))
preTechSupport = guild22.get_role(int(config["Roles"]["sub_support"]))
overwrites = {
guild22.default_role: disnake.PermissionOverwrite(view_channel=False),
inter.author: disnake.PermissionOverwrite(view_channel=True),
techSupport: disnake.PermissionOverwrite(view_channel=True),
preTechSupport: disnake.PermissionOverwrite(view_channel=True)
}
channel = await inter.channel.category.create_text_channel(name= f"ticket-{inter.author}", overwrites=overwrites)
embed = disnake.Embed(
title="Ваш тикет",
color=disnake.Colour.green(),
)
for key, value in inter.text_values.items():
embed.add_field(
name=replaceName(key),
value=value[:1024],
inline=False,
)
await channel.send(embed = embed, components=[
disnake.ui.Button(label="Закрыть тикет", style=disnake.ButtonStyle.danger, custom_id="-", emoji="🔒"),
])
def replaceName(arg: str):
if arg == "theme":
return "Тема"
else:
return "Описание"
bot.run(config["Auth"]["token"])