Search code examples
pythondiscord.py

How to get a list of all dms discord.py


I am experimenting with discord.py and I can't find out how to get a list of all the DM channels the bot is in! I basicly need a list of either channel objects or channel ids of all DMs.

I have tried:

bot.get_private_channels()
bot.get_channels()
bot.get_dms()
bot.channels

and I have looked all over the internet for an answer, but I can't find anything.

Is this even possible in discord.py?

I really appreciate any help, thanks!


Solution

  • I don't think it is possible, but an alternative could be to look through all the members of all the guilds your bot is in, and check if member.dm_channel is not None, if it is not None, it means there is a dm channel that was created between the bot and the member