How do I get the channel a message was sent in?

老子叫甜甜 提交于 2021-01-28 21:36:29

问题


I have been trying and making and building some channel lockdown commands, but they all didn't work. So far, I only have a lockdown command which locks a specific, fixed channel (code down below). So could someone tell me how to make a lockdown command which locks the channel the command was sent in?

@bot.command(aliases=['sd'])
@commands.has_role('Admin')
async def shutdown(ctx):
    """Shuts down #bank"""
    intro = bot.get_channel(768788764008251436)
    await intro.set_permissions(ctx.guild.default_role, send_messages=False)

回答1:


You retrieve the channel a message was sent in by calling.

intro = ctx.channel


来源:https://stackoverflow.com/questions/65608857/how-do-i-get-the-channel-a-message-was-sent-in

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!