简体   繁体   中英

how to get a specified discord text channel ID in discord.net

I am facing some problems in my discord bot using Discord.Net NuGet i want to make my bot gets a channel id by only mentioning it for example: $set-logChannel #kicked-or-banned-logs and then it gets the ID of this channel and sets it as a variable in the database any ideas, please? plus I want a tutorial PDF for Discord.Net NuGet library/package anyone got the pdf please drop the link here and thanks !

If you add a Socket(Text/Voice)Channel parameter named channel you can get the channel's Id with channel.Id :

[Command("logChannel")]
public async Task LogChannel([Remainder] SocketTextChannel channel)
{
    ulong channelId = channel.Id;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM