public async Task RunAsync() { ReadConfig.Read(); var varrepo = new VariableRepository(ReadConfig.Config.ConnectionString); bool result; #if DEBUG result = varrepo.Read(3, out Variable prefix); //get testPrefix if in designmode #else result = varrepo.Read(2, out Variable prefix); //otherwise get default prefix #endif DiscordConfiguration config = new DiscordConfiguration { Token = ReadConfig.Config.Token, TokenType = TokenType.Bot, AutoReconnect = true, #if DEBUG MinimumLogLevel = Microsoft.Extensions.Logging.LogLevel.Debug, #endif Intents = DiscordIntents.All }; Client = new DiscordClient(config); //Register client events Client.Ready += Events.OnClientReady; Client.GuildDownloadCompleted += Events.Client_GuildDownloadCompleted; Client.MessageCreated += Events.MessageCreated; Client.MessageUpdated += Events.MessageUpdated; Client.MessageDeleted += Events.MessageDeleted; Client.GuildMemberAdded += Events.MemberAdded; Client.MessageReactionAdded += Events.ReactionAdded; Client.MessageReactionRemoved += Events.ReactionRemoved; Client.VoiceStateUpdated += Events.VoiceStateUpdated; Client.ClientErrored += Events.ClientErrored; Client.ComponentInteractionCreated += Events.ComponentTriggered; //Register client events for logging Client.GuildBanAdded += Logger.BanAdded; Client.GuildBanRemoved += Logger.BanRemoved; Client.GuildMemberUpdated += Logger.MemberUpdated; Client.ChannelUpdated += Logger.ChannelUpdated; Client.GuildRoleUpdated += Logger.RoleUpdated; Client.MessageUpdated += Logger.MessageEdited; Client.MessageDeleted += Logger.MessageDeleted; Client.MessagesBulkDeleted += Logger.BulkMessagesDeleted; //Client.GuildEmojisUpdated += Logger.EmojiUpdated; Client.VoiceStateUpdated += Logger.VoiceUpdate; //Register timer events SystemService.Instance.WarnTimer.Elapsed += Events.TimerTick; //Register Logger events SystemService.Instance.Logger.RaiseLogEvent += Events.OnLog; Client.UseInteractivity(new InteractivityConfiguration { Timeout = TimeSpan.FromMinutes(5), PollBehaviour = PollBehaviour.KeepEmojis, AckPaginationButtons = true }); CommandsNextConfiguration commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { prefix.Value }, EnableMentionPrefix = true }; Commands = Client.UseCommandsNext(commandsConfig); //Register commands Commands.RegisterCommands <AuditCommands>(); Commands.RegisterCommands <EmbedCommands>(); Commands.RegisterCommands <InfoCommands>(); Commands.RegisterCommands <LavalinkCommands>(); Commands.RegisterCommands <ReactionCommands>(); Commands.RegisterCommands <RuleCommands>(); Commands.RegisterCommands <TechnicalCommands>(); Commands.RegisterCommands <WarnCommands>(); Commands.RegisterCommands <EventCommands>(); //Register command events Commands.CommandErrored += Events.CommandErrored; SlashCommands = Client.UseSlashCommands(); //Register interactions SlashCommands.RegisterCommands <WarnInteractions>(699555747591094344); //Register interaction events SlashCommands.ContextMenuErrored += Events.ContextMenuErrored; await Client.ConnectAsync(); LavalinkNodeConnection lavaNode = null; lavaNode = await ConnectLavaNodeAsync(); if (lavaNode != null) { //Register lava commands lavaNode.PlaybackFinished += Events.PlaybackFinished; } await Task.Delay(-1); }