如果漫游器创建了文本通道,您如何选择它刚刚创建的通道并让漫游器在其中发布消息?

时间:2019-08-19 09:37:14

标签: discord.py-rewrite

我正在制造服务器,并且想要一个机器人。它具有票务系统。您做票(原因),然后它将与用户和一些支持一起创建一个私有文本通道,但是当创建文本通道时,我希望机器人首先说: @Support,@(调用票证的用户)已为(原因)制作票证

当前代码:

@client.command(pass_context=True)
async def ticket(ctx,*,reason):
    global ticketNumber
    ticketNumber = str(ticketNumber)
    global supportRole
    supportRole = discord.utils.get(ctx.guild.roles, name="Support")
    overwrites = {
        ctx.guild.default_role: discord.PermissionOverwrite(read_messages=False),
        ctx.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True),
        supportRole: discord.PermissionOverwrite(read_messages=True, send_messages=True),
        ctx.author: discord.PermissionOverwrite(read_messages=True, send_messages=True)
    }
    name = 'Tickets'
    category = discord.utils.get(ctx.guild.categories, name=name)
    guild = ctx.message.guild
    await guild.create_text_channel(f'Ticket-{ticketNumber}', category=category, overwrites=overwrites)
    ticketNumber = int(ticketNumber) + 1
    await ctx.author.send("Your ticket has been made, a support team member will try to answer it ASAP. Thank you.")
    await ctx.send(reason)
    await ctx.author.add_roles(discord.utils.get(id=ID NUMBER))

1 个答案:

答案 0 :(得分:1)

幸运的是,create_text_channel()返回创建的频道
要提及某个角色,可以使用role.mention


ticket_channel = await ctx.guild.create_text_channel(f'Ticket-{ticketNumber}', category=category, overwrites=overwrites)

msg = f'{supportRole.mention}, {ctx.author.mention} has made a ticket for {reason}'
await ticket_channel.send(msg)