Hikari: Add member to a channel
Question:
I’ve looked through Hikari’s documentation including channels, users, guild, and rest, but I can’t find how to add members to a channel. In discord, it’s very easy to add a member to a specific channel, but it’s not clear how to replicate this functionality with the API.
Answers:
Figured out you need the channel id and user id, then you can call edit_overwrite on the channel instance to change its permissions to include the new member.
# add user to channel
channel = await bot.rest.fetch_channel(YOUR_CHANNEL_ID)
user = await bot.rest.fetch_user(YOUR_USER_ID)
await channel.edit_overwrite(target=user, allow=Permissions.VIEW_CHANNEL)
If you want to add multiple permissions you can do this:
await channel.edit_overwrite(target=user, allow=(Permissions.VIEW_CHANNEL | Permissions.SEND_MESSAGES))
I’ve looked through Hikari’s documentation including channels, users, guild, and rest, but I can’t find how to add members to a channel. In discord, it’s very easy to add a member to a specific channel, but it’s not clear how to replicate this functionality with the API.
Figured out you need the channel id and user id, then you can call edit_overwrite on the channel instance to change its permissions to include the new member.
# add user to channel
channel = await bot.rest.fetch_channel(YOUR_CHANNEL_ID)
user = await bot.rest.fetch_user(YOUR_USER_ID)
await channel.edit_overwrite(target=user, allow=Permissions.VIEW_CHANNEL)
If you want to add multiple permissions you can do this:
await channel.edit_overwrite(target=user, allow=(Permissions.VIEW_CHANNEL | Permissions.SEND_MESSAGES))