如何在discord.net中获取指定的discord文本频道ID

问题描述

我在使用 discord.Net NuGet 的 discord 机器人中遇到了一些问题 我想让我的机器人通过只提到它来获得频道 ID 例如: $set-logChannel #kicked-or-banned-logs 然后它获取这个频道的ID并将其设置为数据库中的变量 有什么想法吗?另外我想要一个 discord.Net NuGet 库/包的教程 PDF 任何人得到了 pdf,请把链接在这里,谢谢!

解决方法

如果您添加名为 channel 的 Socket(Text/Voice)Channel 参数,您可以使用 channel.Id 获取频道的 Id:

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