【发布时间】:2021-08-18 20:38:21
【问题描述】:
我想用我的机器人创建一个只有管理员角色才能访问的私人频道。 我已通读this article,了解如何让您的机器人创建专用频道,特定角色可以查看/加入。
到目前为止,discord 有一个功能,您可以完全跳过角色步骤,让所有管理员角色查看它。
有没有办法在 discord.net C# 中做到这一点?
这是我创建频道的代码:
var channel = Context.Guild.Channels.SingleOrDefault(x => x.Name == "log");
if (channel == null) // there is no channel with the name of 'log'
{
// create the channel
var newChannel = await Context.Guild.CreateTextChannelAsync("log");
// If you need the newly created channels id
var newChannelId = newChannel.Id;
await ReplyAsync("Created channel ``'log'``");
}
else // reply that the channel already exists
{
await ReplyAsync("Unable to create channel ``log`` channel already exists.");
}
请记住,这不是重复的,因为另一个问题提到添加可以查看频道的角色,而不是像在不和谐中手动创建频道时那样跳过它。
日志指的是文本通道,Discord.net NuGet 包版本 2.1.1,使用 Visual Studio 2019 最新的 32 位进行编译。
【问题讨论】:
标签: c# discord.net