消息中的按钮,不和谐

Buttons in a message, discord

如何在欢迎消息中添加按钮? 按钮切换到另一个频道

@client.event
async def on_member_join(member):
    channel = client.get_channel(channelID)
    await channel.send(f'Hello')

对于我使用的按钮 discord-py-slash-command package (documentation).

from discord_slash.utils import manage_components
from discord_slash.model import ButtonStyle

@client.event
async def on_member_join(member):
    channel = client.get_channel(channelID)

    button = manage_components.create_button(style=ButtonStyle.URL, label="Your channel", url=f'https://discord.com/channels/{member.guild.id}/{channel.id}')
    action_row = manage_components.create_actionrow(button)
    
    await channel.send(content=f'Hello', components=[action_row])

这将创建一个按钮,将您转到您的频道。
Link 包括: https://discord.com/channels/<server_id>/<channel_id>

Read more about Discord buttons