Closed Zamiell closed 6 years ago
You should be able to add an existing channel to a category using the newly added ChannelEditComplex
function (ParentID
).
Ah, I see, its on the "develop" branch. Thank you @Seklfreak , I'll try it out!
You should probably always use the develop
branch. master
doesn't get updated very often, and develop
is stable enough.
Through trial and error, I've found that I can query the Discord API directly by myself using curl
in order to get the ID of the category from the parent_id
parameter:
curl --header "Authorization: Bot [key]" https://discordapp.com/api/channels/392872395116904448
{"guild_id": "392182453248458762", "name": "r-1-zamiel-vs-xunhingedmoose", "permission_overwrites": [], "topic": null, "parent_id": "392884552407711744", "nsfw": false, "position": 5, "last_message_id": "392872395381276682", "type": 0, "id": "392872395116904448"}
Ideally, I'd like to be able to use the DiscordGo library to enumerate through all of the categories on a server so that I can find the ID programmatically without having to do this process manually. Is that possible?
If you are using the develop
branch you can access a channels parent id:
channel, err := session.State.Channel("392872395116904448")
fmt.Println(channel.ParentID)
you can then get the get the parent channel from the state
parent, err := session.State.Channel(channel.ParentID)
fmt.Println(parent.Name)
@Seklfreak Are all channel categories just channels themselves?
You can find the name of an existing category from it's ID using session.State.Channel(channelID)
, no need to iterate over all categories.
But here is how to iterate over all categories:
guild, err := session.State.Guild("392182453248458762")
for _, guildChannel := range guild.Channels {
if guildChannel.Type == discordgo.ChannelTypeGuildCategory {
fmt.Println(guildChannel.Name)
}
}
Thank you! I see now that all categories are just channels themselves, which is kind of confusing at first, but makes sense.
@Zamiell I think this issue can be closed. :)
It might be best to close it when the change gets merged into master?
Oh, maybe, I don't know to be honest. 🤔
@bwmarrin Can you put it on master?
It will be, fairly soon.
Hello; this is an excellent library, and thanks so much for providing it.
Does this library allow me to create channels INTO a channel category/group?
I see that the
GuildChannelCreate(guildID, name, ctype string)
function creates channels without ANY category attached to them.Or is there a way with this library to move an existing channel into a category/group? Because then I can just do a two step process.