X
X
x4zx2021-07-13 01:07:33
Python
x4zx, 2021-07-13 01:07:33

How to stop being an author for a team?

Hello, I am making a bot with a report system for a separate server, a problem has arisen.
My bot works like this: First, you need to write $report to call embed with a button through which to create tickets for reports, the essence of the problem is that if any person clicks on the button to create a report, then the report will be created on my behalf and always, please tell me that make?

import discord
from discord import colour
from discord import member
from discord import channel
from discord.ext import commands
from discord_components import DiscordComponents, Button, ButtonStyle, button, component
import asyncio

from discord_components.interaction import InteractionType

intents = discord.Intents.all()
bot = commands.Bot(command_prefix = "$", intents = intents)
bot.remove_command("help")

@bot.event
async def on_ready():
    DiscordComponents(bot)
    print(f'Вы вошли как {bot.user}')

@bot.command()
@commands.has_role(832536148232503326)
async def report(ctx):
        emb = discord.Embed(title = '', description = "**На всі ваші питання допоможе відповісти - <@&833314249827680257>** \n Щоб зв'язатися з адміністраторами натисніть на кнопку нижче", colour = 0xFF8C00)
        emb.set_image(url = 'https://riskcontrolacademy.com/wp-content/uploads/2019/09/support.png')
        emb.set_footer(text = 'Support Team', icon_url = 'https://cdn.discordapp.com/attachments/772850448892690462/833028640715440128/unknown.png')
        await ctx.send(
            embed = emb,
            components = [
                Button(style = ButtonStyle.gray, label = "Зв'язатися", emoji = '')
            ]
        )
        
        while True:

            res = await bot.wait_for('button_click')
            if res.component.label.startswith("Зв'язатися"):
                await res.respond(type = 6)
                channel = await ctx.guild.create_text_channel(name = f"{ctx.author}", category = ctx.guild.get_channel(833425673188016149))
                await channel.set_permissions(ctx.author, overwrite = discord.PermissionOverwrite(view_channel = True, send_messages = True))

            #for role in ctx.author.roles:
                #mentions = ", ".join(role for role in ctx.author.roles)
                #mention = role.mention

            t = ctx.author.status
            if t == discord.Status.online:
                d = "<:online2:842130462038425653> В сети"
            elif t == discord.Status.offline:
                d = "<:offline2:842130438209536000> Не в сети"
            elif t == discord.Status.idle:
                d = "<:away:842130479339667497> Не активен"
            elif t == discord.Status.dnd:
                d = "<:dnd2:842130417406181436> Не беспокоить"
            elif t == discord.Status.streaming:
                d = "<:streaming:846048619571314719> Стримит"

            await channel.send('**<@&833314249827680257> новий тікет, інформація про користувача нижче**')

            emb1 = discord.Embed(title = "Інформаційне табло", description = 'Це табло надає інформацію про автора тікета', colour = 0xFF8C00)
            emb1.add_field(name = 'Користувач', value = f'{ctx.author.mention}')
            emb1.add_field(name = 'Найвища роль', value = f'{ctx.author.top_role.mention}')
            emb1.add_field(name = 'Статус', value = f'{d}')
            emb1.add_field(name = 'Приєднався', value = f'{ctx.author.joined_at.strftime("%a, %#d %B %Y, %I:%M")}')
            emb1.add_field(name = 'Дата створення', value = f'{ctx.author.created_at.strftime("%a, %#d %B %Y, %I:%M")}')
            emb1.set_thumbnail(url = f'{ctx.author.avatar_url}')
            emb1.set_footer(icon_url = f'{ctx.author.avatar_url}', text = f'{ctx.author} | ID: {ctx.author.id}')
            await channel.send(
                embed = emb1,
                components = [
                    Button(style = ButtonStyle.gray, label = 'Закрити', emoji = '⛔')
                ]
            )

            res = await bot.wait_for('button_click')
            if res.component.label.startswith("Закрити"):
                await res.respond(type = 6)
                emb2 = discord.Embed(title = '', description = '**Тікет видалиться через декілька секунд.**', colour = 0xFF8C00)
                await channel.send(embed = emb2)
                await asyncio.sleep(3)
                await res.channel.delete()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dream, 2021-07-13
@x4zx

To get the user who clicked the button:
member = res.guild.get_member(res.user.id)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question