【发布时间】:2020-04-07 14:15:42
【问题描述】:
我正在尝试运行一个命令来删除一个频道,然后在同一频道类别中重新创建它,而不是在公会中(它不在任何类别中)。
public Task ExecuteCommand(BotMessageInformation botMessageInfo)
{
return Task.Run(
async
()
=>
{
ulong messageChannelId = botMessageInfo.Message.Channel.Id;
var textChannel = botMessageInfo.Client
.GetChannel(messageChannelId) as SocketTextChannel;
string textChannelName = textChannel.Name;
// ulong textChannelCategory = textChannel.CategoryId;
await textChannel.DeleteAsync();
await botMessageInfo.Client.GetGuild(botMessageInfo.GuildId)
.CreateTextChannelAsync(textChannelName);
});
}
botMessageInfo.Client 的类型为 DiscordSocketClient。
如何在给定类别中创建此频道?我想用textChannel.CategoryId
【问题讨论】:
-
请注意您正在使用的 API 包装器,因为完成您想要的操作的方式取决于库的实现。
-
@Anu6is 我不明白你刚才说什么。
-
DSharpPlus、Discord.Net、其他一些 Discord API 包装器?