Код: Выделить всё
public interface IEventHandler
{
public static abstract DiscordIntents RequiredIntents { get; }
}
Код: Выделить всё
class EventHandler(...) : IEventHandler, ...
{
public static DiscordIntents RequiredIntents { get; } = ...;
}
Код: Выделить всё
// Classes that implement `IEventHandler`.
IEnumerable event_modules =
[
typeof(EventHandler),
...
];
var intents = ...;
foreach (var event_module in event_modules)
{
intents |= (DiscordIntents)event_module.InvokeMember("RequiredIntents", BindingFlags.Static | BindingFlags.Public | BindingFlags.GetProperty, null, null, null);
}
DiscordClientBuilder builder = DiscordClientBuilder.CreateDefault(token, intents);
Подробнее здесь: https://stackoverflow.com/questions/790 ... rom-a-type
Мобильная версия