Привет
- User
Привет
- Assistant
Привет! Как я могу помочь тебе сегодня?
- User
@bot.command() async def запрос(ctx): author_id = ctx.author.id author_name = ctx.author.name ru_ticket_author[author_id] = author_name
guild = ctx.guild category = disnake.utils.get(guild.categories, name='RU-Тикеты') if not category: category = await guild.create_category(name='RU-Тикеты') ticket_name = f'Запрос・{author_name}' overwrites = { guild.default_role: disnake.PermissionOverwrite(read_messages=False), ctx.author: disnake.PermissionOverwrite(read_messages=True) } ticket_channel = await category.create_text_channel(name=ticket_name, overwrites=overwrites) message = await ticket_channel.send( f'{ctx.author.mention}, Я слушаю Вас.') await asyncio.sleep(86400) del ru_ticket_author[author_id] await ticket_channel.delete()@bot.command() async def обращение(ctx): button = DeleteMessageButton() message = await ctx.send("Нажмите кнопку, чтобы вызвать команду запрос", components=[[button]])
interaction = await bot.wait_for("button_click", check=lambda i: i.component.custom_id == "delete_message" and i.user == ctx.author) await interaction.response.send_message("Команда запрос вызвана", ephemeral=True) command_ctx = await bot.get_context(interaction) command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)@bot.event async def on_button_click(interaction): if interaction.component.custom_id == "delete_message": await interaction.respond("Команда запрос вызвана", ephemeral=True) channel_name = f'Запрос・{interaction.user.name}' channel = disnake.utils.get(interaction.guild.channels, name=channel_name) if channel: command_ctx = await bot.get_context(interaction, channel=channel) command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)
В этом коде автором должен быть пользователь нажавший на ссылку, исправь чтобы это был не бот
- Assistant
Привет! Чтобы автором команды был пользователь, а не бот, можно использовать свойство
interaction.userвместоctx.author.Вот исправленный код:
@bot.command() async def запрос(ctx): author_id = ctx.author.id author_name = ctx.author.name ru_ticket_author[author_id] = author_name guild = ctx.guild category = disnake.utils.get(guild.categories, name='RU-Тикеты') if not category: category = await guild.create_category(name='RU-Тикеты') ticket_name = f'Запрос・{author_name}' overwrites = { guild.default_role: disnake.PermissionOverwrite(read_messages=False), ctx.author: disnake.PermissionOverwrite(read_messages=True) } ticket_channel = await category.create_text_channel(name=ticket_name, overwrites=overwrites) message = await ticket_channel.send( f'{ctx.author.mention}, Я слушаю Вас.') await asyncio.sleep(86400) del ru_ticket_author[author_id] await ticket_channel.delete() @bot.command() async def обращение(ctx): button = DeleteMessageButton() message = await ctx.send("Нажмите кнопку, чтобы вызвать команду запрос", components=[[button]]) interaction = await bot.wait_for("button_click", check=lambda i: i.component.custom_id == "delete_message" and i.user != bot.user) await interaction.response.send_message("Команда запрос вызвана", ephemeral=True) command_ctx = await bot.get_context(interaction) command_ctx.author = interaction.user command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx) @bot.event async def on_button_click(interaction): if interaction.component.custom_id == "delete_message": await interaction.respond("Команда запрос вызвана", ephemeral=True) channel_name = f'Запрос・{interaction.user.name}' channel = disnake.utils.get(interaction.guild.channels, name=channel_name) if channel: command_ctx = await bot.get_context(interaction, channel=channel) command_ctx.author = interaction.user command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)Теперь автором команды будет пользователь, а не бот.
- User
@bot.command() async def запрос(ctx): author_id = ctx.author.id author_name = ctx.author.name ru_ticket_author[author_id] = author_name
guild = ctx.guild category = disnake.utils.get(guild.categories, name='RU-Тикеты') if not category: category = await guild.create_category(name='RU-Тикеты') ticket_name = f'Запрос・{author_name}' overwrites = { guild.default_role: disnake.PermissionOverwrite(read_messages=False), guild.get_member(author_id): disnake.PermissionOverwrite(read_messages=True) } ticket_channel = await category.create_text_channel(name=ticket_name, overwrites=overwrites) message = await ticket_channel.send( f'{ctx.author.mention}, Я слушаю Вас, гражданин! Опишите ваш вопрос, наши администраторы свяжутся с вами в ближайшее время.') await asyncio.sleep(86400) del ru_ticket_author[author_id] await ticket_channel.delete()@bot.command() async def обращение(ctx): button = DeleteMessageButton() message = await ctx.send("Нажмите кнопку, чтобы вызвать команду запрос", components=[[button]])
interaction = await bot.wait_for("button_click", check=lambda i: i.component.custom_id == "delete_message" and i.user == ctx.author) await interaction.response.send_message("Команда запрос вызвана", ephemeral=True) command_ctx = await bot.get_context(interaction.message) command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)@bot.event async def on_button_click(interaction): if interaction.component.custom_id == "delete_message": await interaction.respond("Команда запрос вызвана", ephemeral=True) channel_name = f'Запрос・{interaction.user.name}' channel = disnake.utils.get(interaction.guild.channels, name=channel_name) if channel: command_ctx = await bot.get_context(interaction.message) command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)
В этом коде автором должен быть пользователь нажавший на ссылку, исправь чтобы это был не бот. Перепиши код там где считаешь нужным
- Assistant
Конечно! Вот исправленный код:
@bot.command() async def запрос(ctx): author_id = ctx.author.id author_name = ctx.author.name ru_ticket_author[author_id] = author_name guild = ctx.guild category = disnake.utils.get(guild.categories, name='RU-Тикеты') if not category: category = await guild.create_category(name='RU-Тикеты') ticket_name = f'Запрос・{author_name}' overwrites = { guild.default_role: disnake.PermissionOverwrite(read_messages=False), guild.get_member(author_id): disnake.PermissionOverwrite(read_messages=True) } ticket_channel = await category.create_text_channel(name=ticket_name, overwrites=overwrites) message = await ticket_channel.send( f'{ctx.author.mention}, Я слушаю Вас, гражданин! Опишите ваш вопрос, наши администраторы свяжутся с вами в ближайшее время.') await asyncio.sleep(86400) del ru_ticket_author[author_id] await ticket_channel.delete() @bot.command() async def обращение(ctx): button = DeleteMessageButton() message = await ctx.send("Нажмите кнопку, чтобы вызвать команду запрос", components=[[button]]) interaction = await bot.wait_for("button_click", check=lambda i: i.component.custom_id == "delete_message" and i.user != bot.user) await interaction.response.send_message("Команда запрос вызвана", ephemeral=True) command_ctx = await bot.get_context(interaction) command_ctx.message = interaction.message command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx) @bot.event async def on_button_click(interaction): if interaction.component.custom_id == "delete_message": await interaction.respond("Команда запрос вызвана", ephemeral=True) channel_name = f'Запрос・{interaction.user.name}' channel = disnake.utils.get(interaction.guild.channels, name=channel_name) if channel: command_ctx = await bot.get_context(interaction) command_ctx.message = interaction.message command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)Внесены изменения в
запросиобращениекоманды, а также вon_button_clickсобытие, чтобы учитывать автора, отличного от бота. Теперь автором команды будет пользователь, а не бот. - Assistant
` @bot.command() async def запрос(ctx): author_id = ctx.author.id author_name = ctx.author.name ru_ticket_author[author_id] = author_name
guild = ctx.guild category = disnake.utils.get(guild.categories, name='RU-Тикеты') if not category: category = await guild.create_category(name='RU-Тикеты') ticket_name = f'Запрос・{author_name}' overwrites = { guild.default_role: disnake.PermissionOverwrite(read_messages=False), ctx.author: disnake.PermissionOverwrite(read_messages=True) } ticket_channel = await category.create_text_channel(name=ticket_name, overwrites=overwrites) message = await ticket_channel.send( f'{ctx.author.mention}, Я слушаю Вас.') await asyncio.sleep(86400) del ru_ticket_author[author_id] await ticket_channel.delete()@bot.command() async def обращение(ctx): button = DeleteMessageButton() message = await ctx.send("Нажмите кнопку, чтобы вызвать команду запрос", components=[[button]])
interaction = await bot.wait_for("button_click", check=lambda i: i.component.custom_id == "delete_message" and i.author != bot.user) await interaction.response.send_message("Команда запрос вызвана", ephemeral=True) command_ctx = await bot.get_context(interaction) command_ctx.author = interaction.author command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)@bot.event async def on_button_click(interaction): if interaction.component.custom_id == "delete_message": await interaction.respond("Команда запрос вызвана", ephemeral=True) channel_name = f'Запрос・{interaction.author.name}' channel = disnake.utils.get(interaction.guild.channels, name=channel_name) if channel: command_ctx = await bot.get_context(interaction, channel=channel) command_ctx.author = interaction.author command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)
В этом коде автором будет являться пользователь, вызывающий команду или нажимающий на кнопку. Я внес изменения взапрос,обращениеиon_button_clickкоманды, чтобы использоватьauthorвместоctx.authorилиi.user` для определения автора запроса. - User
@bot.command() async def обращение(ctx): button = DeleteMessageButton() message = await ctx.send("Нажмите кнопку, чтобы вызвать команду запрос", components=[[button]])
interaction = await bot.wait_for("button_click", check=lambda i: i.component.custom_id == "delete_message" and i.user == ctx.author) await interaction.response.send_message("Команда запрос вызвана", ephemeral=True) command_ctx = await bot.get_context(interaction.message) command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)@bot.event async def on_button_click(interaction): if interaction.component.custom_id == "delete_message": await interaction.respond("Команда запрос вызвана", ephemeral=True) channel_name = f'Запрос・{interaction.user.name}' channel = disnake.utils.get(interaction.guild.channels, name=channel_name) if channel: command_ctx = await bot.get_context(interaction.message) command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)
обьедини
- Assistant
Разумеется! Вот объединенный код:
@bot.command() async def запрос(ctx): author_id = ctx.author.id author_name = ctx.author.name ru_ticket_author[author_id] = author_name guild = ctx.guild category = disnake.utils.get(guild.categories, name='RU-Тикеты') if not category: category = await guild.create_category(name='RU-Тикеты') ticket_name = f'Запрос・{author_name}' overwrites = { guild.default_role: disnake.PermissionOverwrite(read_messages=False), ctx.author: disnake.PermissionOverwrite(read_messages=True) } ticket_channel = await category.create_text_channel(name=ticket_name, overwrites=overwrites) message = await ticket_channel.send( f'{ctx.author.mention}, Я слушаю Вас.') await asyncio.sleep(86400) del ru_ticket_author[author_id] await ticket_channel.delete() @bot.command() async def обращение(ctx): button = DeleteMessageButton() message = await ctx.send("Нажмите кнопку, чтобы вызвать команду запрос", components=[[button]]) check = lambda i: i.component.custom_id == "delete_message" and i.user == ctx.author interaction = await bot.wait_for("button_click", check=check) await interaction.response.send_message("Команда запрос вызвана", ephemeral=True) command_ctx = await bot.get_context(interaction) command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx) @bot.event async def on_button_click(interaction): if interaction.component.custom_id == "delete_message": await interaction.respond("Команда запрос вызвана", ephemeral=True) channel_name = f'Запрос・{interaction.user.name}' channel = disnake.utils.get(interaction.guild.channels, name=channel_name) if channel: command_ctx = await bot.get_context(interaction.message, channel=channel) command_ctx.command = bot.get_command('запрос') await bot.invoke(command_ctx)Теперь команды
обращениеиon_button_clickобъединены в одном блоке кода.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- gpt-4-0314Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-4-0314Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-3.5-turbo-0301Compare side by side →
- gpt-4o-2024-11-20Compare side by side →
- gpt-4o-2024-11-20Compare side by side →