有没有办法使用自定义机器人将频道移动到基于类别名称的类别
Is there a way to move a channel to a category based of category name using a custom bot
我是 Discord.Net API 的新手,并且掌握了很多窍门。但是我在将机器人创建的频道移动到现有类别频道时遇到问题。如果我可以只使用频道 ID 就可以了,但理想情况下它会找到一个名为 'user-reports' 的类别并从中获取 ID 以设置频道父级或位置。
//This is what i have to create a channel for testing purposes
var test = await Context.Guild.CreateTextChannelAsync("HI");
//I used this previously to find if a message was sent in a specific channel then it would act
if (Context.Channel.Name != "report-user")
{
await Context.User.SendMessageAsync(Context.User + " You have tried to send a ticket to the wrong channel. Please use the report-user channel");
return;
}
//Find the ID for the desired category
var categoryId = Context.Guild.CategoryChannels.FirstOrDefault(category => category.Name.Equals("user-reports"))?.Id;
//Set channel category during channel creation
await Context.Guild.CreateTextChannelAsync("Hi", prop => prop.CategoryId = categoryId);
//Set channel category after channel creation
var channel = await Context.Guild.CreateTextChannelAsync("Hello");
await channel.ModifyAsync(prop => prop.CategoryId = categoryId);
我是 Discord.Net API 的新手,并且掌握了很多窍门。但是我在将机器人创建的频道移动到现有类别频道时遇到问题。如果我可以只使用频道 ID 就可以了,但理想情况下它会找到一个名为 'user-reports' 的类别并从中获取 ID 以设置频道父级或位置。
//This is what i have to create a channel for testing purposes
var test = await Context.Guild.CreateTextChannelAsync("HI");
//I used this previously to find if a message was sent in a specific channel then it would act
if (Context.Channel.Name != "report-user")
{
await Context.User.SendMessageAsync(Context.User + " You have tried to send a ticket to the wrong channel. Please use the report-user channel");
return;
}
//Find the ID for the desired category
var categoryId = Context.Guild.CategoryChannels.FirstOrDefault(category => category.Name.Equals("user-reports"))?.Id;
//Set channel category during channel creation
await Context.Guild.CreateTextChannelAsync("Hi", prop => prop.CategoryId = categoryId);
//Set channel category after channel creation
var channel = await Context.Guild.CreateTextChannelAsync("Hello");
await channel.ModifyAsync(prop => prop.CategoryId = categoryId);