Reputation: 37
How can I get all the info of a Webhook of a channel?
I've found the API reference of the discord library. But I'm stuck at the beginning and don't see how I can even start. Could I get some help finding a way to get started?
Upvotes: 0
Views: 1609
Reputation: 1173
I am not sure if this is what you wanted.
But lets say there is a webhook in channel 'a'. We can use the following code. To retrieve all the webhooks linked to that particular channel (when this command is called in channel 'a'):
@commands.command()
async def get_channel_webhooks(self, ctx):
# Loops through every webhook linked to the channel
for hook in await ctx.channel.webhooks():
hook_channel_id = hook.channel_id
await ctx.send(f"channel_id of hook: {hook_channel_id}")
When you read this documentation you will see what you can do with the webhook object. In the code previously shown. We used hook.channel_id
to retrieve the channel_id the webhook is linked to. And ctx.channel.webhooks()
to retrieve a full list of all webhooks linked to that channel (documentation).
But you can also get information about: user, url, name etc (read the documentation for more),
Upvotes: 1