private async Task DiscordAsync(string[] args) { client = new DiscordClient(new DiscordConfiguration { Token = Config.Token, TokenType = TokenType.Bot, AutoReconnect = true, }); commands = client.UseCommandsNext(new CommandsNextConfiguration { StringPrefixes = prefixes, EnableDms = false, EnableMentionPrefix = true, CaseSensitive = false, EnableDefaultHelp = false, }); commands.RegisterCommands <Fun>(); commands.RegisterCommands <General>(); commands.RegisterCommands <Misc>(); commands.RegisterCommands <Moderation>(); commands.RegisterCommands <OSDistro>(); client.Ready += BotEvents.Ready; client.GuildMemberAdded += GuildEvents.GuildMemberAdded; client.GuildMemberRemoved += GuildEvents.GuildMemberRemoved; client.MessageDeleted += GuildEvents.MessageDeleted; client.MessageUpdated += GuildEvents.MessageUpdated; commands.CommandErrored += CommandEvents.CommandErrored; await client.ConnectAsync(); await Task.Delay(-1); }
public async Task RunAsync() { var json = string.Empty; using (var fs = File.OpenRead("C:/Users/schsesports/source/repos/DSharpBot/DSharpBot/config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = await sr.ReadToEndAsync().ConfigureAwait(false); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); var config = new DiscordConfiguration { Token = configJson.token, TokenType = TokenType.Bot, AutoReconnect = true, MinimumLogLevel = LogLevel.Debug, }; Client = new DiscordClient(config); Client.Ready += OnReady; Client.MessageCreated += OnMessageReceived; var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.prefix }, EnableMentionPrefix = true, EnableDms = false, DmHelp = true, }; Commands = Client.UseCommandsNext(commandsConfig); Commands.RegisterCommands <FunCommands>(); Commands.RegisterCommands <ModerationModule>(); await Client.ConnectAsync(); await Task.Delay(-1); }
public Bot() { Instance = this; //DownloadAudioClips(); DiscordConfiguration discordConfiguration = new DiscordConfiguration() { AutoReconnect = true, Token = Config.Instance.Token, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Info, DateTimeFormat = "MM/dd/yyyy hh:mm:ss tt" }; discord = new DiscordClient(discordConfiguration); discord.DebugLogger.LogMessageReceived += LogMessageReceived; interactivity = discord.UseInteractivity(new InteractivityConfiguration()); voice = discord.UseVoiceNext(); commands = discord.UseCommandsNext(new CommandsNextConfiguration() { StringPrefixes = new[] { Config.Instance.Prefix }, CaseSensitive = false }); commands.RegisterCommands <GeneralCommands>(); commands.RegisterCommands <AudioModule>(); commands.RegisterCommands <MinecraftCommands>(); commands.CommandErrored += CommandErrored; commands.CommandExecuted += CommandExecuted; //discord.MessageCreated += MessageCreated; discord.Ready += Ready; }
private static async Task MainAsync(string[] arguments) { _discordClient = new DiscordClient(new DiscordConfiguration { Token = _config.Token, TokenType = TokenType.Bot, MinimumLogLevel = LogLevel.Information }); _discordClient.MessageCreated += CheckForCannedResponses; _commandsNext = _discordClient.UseCommandsNext(new CommandsNextConfiguration { EnableMentionPrefix = true, StringPrefixes = new List <string> { _config.CommandPrefix }, CaseSensitive = false }); _commandsNext.RegisterCommands <ShittyVerseModule>(); _commandsNext.RegisterCommands <CopyPastaModule>(); InteractivityExtension = _discordClient.UseInteractivity(new InteractivityConfiguration()); await _discordClient.ConnectAsync(); await Task.Delay(-1); }
public Bot( IServiceProvider services, string token, List <string> prefixes ) { var config = new DiscordConfiguration { Token = token, TokenType = TokenType.Bot, AutoReconnect = true, MinimumLogLevel = Microsoft.Extensions.Logging.LogLevel.Debug, //Intents = DiscordIntents.GuildMembers }; Client = new DiscordClient(config); Client.Ready += OnClientReady; var commandsConfig = new CommandsNextConfiguration { StringPrefixes = prefixes, EnableMentionPrefix = true, DmHelp = true, Services = services }; Commands = Client.UseCommandsNext(commandsConfig); Commands.RegisterCommands <TestCommand>(); Commands.RegisterCommands <GuildMemberCommands>(); Commands.RegisterCommands <GuildCommands>(); Commands.RegisterCommands <SwitchRequestCommands>(); Client.ConnectAsync(); }
private static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = token, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); discord.GuildMemberAdded += Discord_GuildMemberAdded; string[] prefixes = { "!" }; commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefixes = prefixes }); commands.RegisterCommands <Commands>(); commands.RegisterCommands <AdministrationCommands>(); commands.CommandErrored += Commands_CommandErrored; await discord.ConnectAsync(); await Task.Delay(-1); }
public Bot() { var discordConfig = new DiscordConfiguration { Token = Settings.GetSettings().DiscordToken, TokenType = TokenType.Bot, Intents = DiscordIntents.All }; var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new List <string>() { "?" }, EnableDefaultHelp = false }; Discord = new DiscordClient(discordConfig); Discord.GuildAvailable += Discord_GuildAvailable; Discord.GuildMemberAdded += Discord_GuildMemberAdded; CommandService = Discord.UseCommandsNext(commandsConfig); CommandService.RegisterCommands(typeof(Commands)); CommandService.RegisterCommands(typeof(PeerCommands)); }
public async Task RunAsync() { if (File.Exists("config.json")) { _config = JObject.Parse(File.ReadAllText("config.json")).ToObject <Config>(); } else { File.Create("config.json").Close(); File.WriteAllText("config.json", JObject.FromObject(new Config()).ToString()); Console.WriteLine("Created a new config file. Please write out all values"); Console.ReadKey(); Environment.Exit(0); } this._client = new DiscordClient(new DiscordConfiguration() { AutoReconnect = true, LogLevel = LogLevel.Debug, Token = _config.Token, TokenType = TokenType.Bot, UseInternalLogHandler = true }); this._interactivity = this._client.UseInteractivity(new InteractivityConfiguration() { PaginationBehaviour = PaginationBehaviour.WrapAround, PaginationDeletion = PaginationDeletion.DeleteEmojis, PaginationEmojis = new PaginationEmojis(), PollBehaviour = PollBehaviour.DeleteEmojis, Timeout = TimeSpan.FromSeconds(45) // timeout op interactivity }); var services = new ServiceCollection() .AddSingleton <DiscordClient>(_client) .AddSingleton <InteractivityExtension>(_interactivity) .AddSingleton <Config>(_config) .AddSingleton <Bot>(this) .BuildServiceProvider(); this._commands = this._client.UseCommandsNext(new CommandsNextConfiguration() { StringPrefixes = new List <string> { _config.CommandPrefix }, EnableDms = false, // geen commands via DM, kan je aanpassen als je wil EnableDefaultHelp = true, // zelf geen help maken, vet handig EnableMentionPrefix = true, // @bot doe dingen, vet leuk CaseSensitive = false, // @bOt dOe dINgEn lekker sarcastisch Services = services }); _commands.RegisterCommands <MainCommands>(); _commands.RegisterCommands <OwnerCommands>(); status = "hentai"; //client connect event: _client.Ready += Client_Ready; await _client.ConnectAsync(); }
static async Task RunBot() { DiscordClient client = new DiscordClient(new DiscordConfiguration { Token = config["token"].ToString(), AutoReconnect = true, UseInternalLogHandler = true, LogLevel = LogLevel.Info }); client.Ready += ClientReady; client.Heartbeated += ClientHeartbeated; client.UseInteractivity(new InteractivityConfiguration()); CommandsNextExtension commands = client.UseCommandsNext(new CommandsNextConfiguration { EnableMentionPrefix = true }); commands.CommandErrored += CommandErrored; commands.RegisterCommands <SwitchCommands>(); commands.RegisterCommands <OwnerCommands>(); await client.ConnectAsync(); await Task.Delay(-1, cancellationToken); }
static async Task MainAsync() { client = new DiscordClient(new DiscordConfiguration { Token = ConfigurationManager.AppSettings.Get("ClientToken"), TokenType = TokenType.Bot, MinimumLogLevel = LogLevel.Debug }); client.UseInteractivity(new InteractivityConfiguration()); commands = client.UseCommandsNext(new CommandsNextConfiguration { StringPrefixes = new string[1] { "!" } }); commands.RegisterCommands <MahjongCommands>(); commands.RegisterCommands <RankingCommands>(); commands.RegisterCommands <UserCommands>(); commands.RegisterCommands <LeagueConfigCommands>(); commands.RegisterCommands <InitCommands>(); client.MessageReactionAdded += ReactionListener.OnReactionAdded; client.MessageReactionRemoved += ReactionListener.OnReactionRemoved; await client.ConnectAsync(); await Task.Delay(-1); }
private async Task RunCopebot() { string json; using (var stream = File.OpenRead(Path.Combine(Environment.CurrentDirectory, "config.json"))) using (var reader = new StreamReader(stream, new UTF8Encoding(false))) json = await reader.ReadToEndAsync(); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); var config = new DiscordConfiguration { Token = configJson.MainToken, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Info, UseInternalLogHandler = true }; var eventHandlers = new EventHandlers(configJson.TypingChannelId); Client = new DiscordClient(config); Client.MessageCreated += eventHandlers.Bot_MessageCreated; Client.ChannelPinsUpdated += eventHandlers.Bot_PinsUpdated; Client.TypingStarted += eventHandlers.Bot_TypingStarted; var interactivityConfig = new InteractivityConfiguration { Timeout = TimeSpan.FromMinutes(1.0) }; Client.UseInteractivity(interactivityConfig); var prefixes = new List <string> { configJson.CommandPrefix }; var minecraftServerHelper = new MinecraftServerHelper(HttpClient, configJson.ImgbbApiKey); var services = new ServiceCollection() .AddSingleton(minecraftServerHelper) .BuildServiceProvider(); var commandsConfig = new CommandsNextConfiguration { StringPrefixes = prefixes, Services = services, EnableMentionPrefix = true, EnableDms = true }; Commands = Client.UseCommandsNext(commandsConfig); Commands.RegisterCommands <UngroupedBotCommands>(); Commands.RegisterCommands <BotUserCommands>(); await Client.ConnectAsync(); await Task.Delay(-1); }
public Bot(string Token, string mysqlCon) { connection = new MySqlConnection(mysqlCon); ShutdownRequest = new CancellationTokenSource(); var cfg = new DiscordConfiguration { Token = Token, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true }; Client = new DiscordClient(cfg); Client.GuildDownloadCompleted += BotGuildsDownloaded; Client.GuildMemberAdded += MemberAdd; Client.GuildMemberUpdated += MemberUpdate; Client.GuildMemberRemoved += MemberLeave; Client.GuildCreated += BotGuildAdded; //Client.MessageReactionAdded += ReactAdd; //Client.MessageReactionRemoved += ReactRemove; CNext = Client.UseCommandsNext(new CommandsNextConfiguration { StringPrefixes = new string[] { "$", "!", "%" }, EnableDefaultHelp = false }); CNext.RegisterCommands <Commands.UserCommands>(); CNext.RegisterCommands <Commands.AdminCommands>(); CNext.RegisterCommands <Commands.OwnerCommands>(); CNext.RegisterCommands <Config.UserConfig>(); INext = Client.UseInteractivity(new InteractivityConfiguration { }); }
public void IniciarComandos() { _comandos.RegisterCommands <ComandosDivertidos>(); _comandos.RegisterCommands <ComandosDeAudio>(); RegistrarMusicas(); }
} //Commands Handler public async Task RunAsync() { #region Using the .json file var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = await sr.ReadToEndAsync().ConfigureAwait(false); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); #endregion #region Bot Configuration var config = new DiscordConfiguration { Token = configJson.Token, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true }; Client = new DiscordClient(config); #endregion #region Interactivity Configuration Client.UseInteractivity(new InteractivityConfiguration { PollBehaviour = PollBehaviour.KeepEmojis, Timeout = TimeSpan.FromDays(1) }); #endregion #region Command Configuration and Adding Them To The Available Commands var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.Prefix }, EnableMentionPrefix = true, EnableDms = true, EnableDefaultHelp = true, DmHelp = false }; Commands = Client.UseCommandsNext(commandsConfig); Commands.RegisterCommands <Test>(); Commands.RegisterCommands <Moderation>(); Commands.RegisterCommands <Interactive>(); Commands.RegisterCommands <UserInfo>(); Commands.RegisterCommands <Kingdom.Commands>(); Commands.SetHelpFormatter <Vinex_Bot.Commands.Help>(); #endregion await Client.ConnectAsync(); await Task.Delay(-1); }
public async Task RunAsync() { var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = await sr.ReadToEndAsync().ConfigureAwait(false); ConfigJson ConfigJson = JsonConvert.DeserializeObject <ConfigJson>(json); DiscordConfiguration config = new DiscordConfiguration { Token = ConfigJson.Token, TokenType = TokenType.Bot, AutoReconnect = true, MinimumLogLevel = Microsoft.Extensions.Logging.LogLevel.Debug }; #pragma warning disable IDE0003 this.Client = new DiscordClient(config); #pragma warning restore IDE0003 Client.Ready += OnClientReady; CommandsNextConfiguration commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { ConfigJson.Prefix }, EnableDms = false, EnableMentionPrefix = true, IgnoreExtraArguments = true, }; Commands = Client.UseCommandsNext(commandsConfig); Commands.CommandErrored += CmdErroredHandler; Commands.SetHelpFormatter <CustomHelpFormatter>(); // Basic: Commands.RegisterCommands <Basic>(); // Economy: Commands.RegisterCommands <Balance>(); Commands.RegisterCommands <Experience>(); Commands.RegisterCommands <Leaderboards>(); Commands.RegisterCommands <Transactions>(); await Client.ConnectAsync(); // Deserializes Transactions Hooks await Transactions.TransactionStartup(Client); // Create transaction hub object TransactionHub tHub = new TransactionHub(); // Hook transaction event to method tHub.OnTransaction += async(transaction) => await Transactions.HandleTransactionAsync(transaction); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { client = new DiscordClient(new DiscordConfiguration { // Please for the love of all that is holy don't include this in the GitHub Token = "", TokenType = TokenType.Bot, UseInternalLogHandler = true, // LogLevel.Debug for Debugguging info, LogLevel.Error for errors LogLevel = LogLevel.Debug }); client.Ready += async e => { Console.WriteLine("Awaiting despair..."); // Set the Activity await client.UpdateStatusAsync(new DSharpPlus.Entities.DiscordActivity { Name = "despair", ActivityType = DSharpPlus.Entities.ActivityType.Watching }, DSharpPlus.Entities.UserStatus.DoNotDisturb); }; // Our prefixes! string[] prefixes = new string[] { "!!" }; commands = client.UseCommandsNext(new CommandsNextConfiguration { // Heck off DMs >:( EnableDms = false, // Mention the bot for commands as well EnableMentionPrefix = true, // Those prefixes from earlier StringPrefixes = prefixes, // Disable help command in place of our own EnableDefaultHelp = false }); // Why is there no overload for leaving it blank? (it's even shown this way in the docs) interactivity = client.UseInteractivity(new InteractivityConfiguration()); // Car salesman: *slaps roof of Client* This bad boy can fit so many f*****g command modules in it commands.RegisterCommands <TestingCommands>(); commands.RegisterCommands <ModerationCommands>(); commands.RegisterCommands <StandardCommands>(); commands.RegisterCommands <FunCommands>(); // Please just show me errors commands.CommandErrored += async e => { Console.WriteLine(e.Exception); }; // Connect await client.ConnectAsync(); // I'LL BE WAITING FOR YOU *I'll be waiting I'll be waiting* await Task.Delay(-1); }
private void InitializeCommandService() { var config = GetDefaultCommandsNextConfiguration(); _commandService = _discordClient.UseCommandsNext(config); _commandService.RegisterCommands <ProfileCommand>(); _commandService.RegisterCommands <RemoteRepositoryCommand>(); _commandService.RegisterCommands <DirectoryCommand>(); RegisterConvertors(); }
//constructor public async Task RunAsync() { //creates the string to hold the config file string json = string.Empty; //reads the config file using (FileStream fs = File.OpenRead("config.json")) using (StreamReader sr = new StreamReader(fs, new UTF8Encoding(false))) json = sr.ReadToEnd(); //deserializes the json into a struct ConfigJson configJson = JsonConvert.DeserializeObject <ConfigJson>(json); //configures up the bot's settings DiscordConfiguration config = new DiscordConfiguration { Token = configJson.Token, TokenType = TokenType.Bot, AutoReconnect = true }; //initializes the client Client = new DiscordClient(config); //readies the bot Client.Ready += OnClientReady; //configures the interactivity settings Client.UseInteractivity(new InteractivityConfiguration { PollBehaviour = DSharpPlus.Interactivity.Enums.PollBehaviour.KeepEmojis }); //configures the command settings CommandsNextConfiguration commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.Prefix }, EnableDms = false, EnableMentionPrefix = true, DmHelp = true }; //activates commands Commands = Client.UseCommandsNext(commandsConfig); //register all commands for the bot Commands.RegisterCommands <FunCommands>(); Commands.RegisterCommands <LinkCommands>(); Commands.RegisterCommands <RoleCommands>(); //connects to the server await Client.ConnectAsync().ConfigureAwait(false); await Task.Delay(-1); }
} // Allows for commands to be set #endregion /// <summary> /// Runs the bot. /// </summary> /// <returns></returns> public async Task RunAsync() { #region Bot Configuration // Load in the JSON configuration (token & prefix) var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = await sr.ReadToEndAsync().ConfigureAwait(false); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); // Configures the bot var config = new DiscordConfiguration() { Token = configJson.Token, TokenType = TokenType.Bot, AutoReconnect = true, // Reconnects automatically if the bot turns off LogLevel = LogLevel.Debug, // Gets all logs rather than just errors UseInternalLogHandler = true }; Client = new DiscordClient(config); #endregion #region Enable Interactivity Client.UseInteractivity(new InteractivityConfiguration { Timeout = TimeSpan.FromMinutes(5) }); #endregion #region Commands Configuration var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.Prefix }, // Prefix used to communicate with bot EnableMentionPrefix = true, // Allows bot to be communicated with by mentioning it EnableDefaultHelp = false // Disables the default help command }; Commands = Client.UseCommandsNext(commandsConfig); // Automatically handles commands // Enables user-created commands Commands.RegisterCommands <AttendanceCommand>(); Commands.RegisterCommands <HelpCommand>(); #endregion await Client.ConnectAsync(); // Connects the bot await Task.Delay(-1); // Stops the bot from quitting early }
public async Task RunAsync() { var json = string.Empty; using (var fs = File.OpenRead("config.json")) //file config.json contains bot token and prefix using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = await sr.ReadToEndAsync().ConfigureAwait(false); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); var config = new DiscordConfiguration { Token = configJson.Token, TokenType = TokenType.Bot, AutoReconnect = true, MinimumLogLevel = Microsoft.Extensions.Logging.LogLevel.Debug, }; Client = new DiscordClient(config); Client.Ready += OnClientReady; Client.UseInteractivity(new InteractivityConfiguration { PollBehaviour = DSharpPlus.Interactivity.Enums.PollBehaviour.KeepEmojis, Timeout = TimeSpan.FromMinutes(2) }); var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.Prefix }, EnableDms = false, EnableMentionPrefix = true, // uses prefix instead of having to @bot DmHelp = true, // The help commands are dmed to the user //EnableDefaultHelp = false, // possibly create my own help section eventually. Turns off default with false. UseDefaultCommandHandler = true, // possibly turn off later }; Commands = Client.UseCommandsNext(commandsConfig); Commands.CommandErrored += CmdErroredHandler; //registering command class to the bot. Do this for every command class Commands.RegisterCommands <ManagerCommands>(); Commands.RegisterCommands <FunCommands>(); Commands.RegisterCommands <BotInfoCommands>(); await Client.ConnectAsync(); await Task.Delay(-1); //keeps the bot running until terminated }
/// <summary> /// Inits all commands and events the bot has to /// </summary> /// <param name="apiSecret">The discord bot API secret</param> /// <param name="prefixes">All prefixes the bot should react to</param> private static void Init(string apiSecret) { // Reading the Options _options = Options.LoadFromFile(); if (string.IsNullOrWhiteSpace(_options.DatabaseConnectionString)) { _options.DatabaseConnectionString = "mongodb://localhost:27017"; } // Setup the database connection _databaseConnection = new DatabaseConnection(_options.DatabaseConnectionString); Util.Permissions.Init(_databaseConnection); // Setup the Discord client _discord = new DiscordClient(new DiscordConfiguration { Token = apiSecret, TokenType = TokenType.Bot }); _config = new CommandsNextConfiguration(); _config.StringPrefixes = _options.Prefixes; _commands = _discord.UseCommandsNext(_config); // Hooks _commands.CommandExecuted += (commandExecutionEventArgs) => { var ctx = commandExecutionEventArgs.Context; ctx.Message.DeleteAsync(); return(null); }; _discord.MessageCreated += (messageCreatedEventArgs) => { var isThisBot = messageCreatedEventArgs.Author.Id == _discord.CurrentUser.Id; if (isThisBot) { new Task(() => { Task.Delay(_options.DeletionDelayInSeconds * 1000).GetAwaiter().GetResult(); messageCreatedEventArgs.Message.DeleteAsync(); }).Start(); } return(null); }; // Add all commands _commands.RegisterCommands <Commands.Notes>(); _commands.RegisterCommands <Commands.Administration>(); }
//{ // MainAsync(args).ConfigureAwait(false).GetAwaiter().GetResult(); //} public async Task MainAsync(string[] args) { SettingsManager.LoadSettings(); discord = new DiscordClient(new DiscordConfiguration { Token = SettingsManager.Cfg.Token, TokenType = TokenType.Bot, MinimumLogLevel = LogLevel.Information }); var deps = new ServiceCollection() .AddSingleton(DeathGames) .AddSingleton(WatchedGameMessages) .BuildServiceProvider(); cmd = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefixes = SettingsManager.Cfg.CommandPrefixes, EnableDms = true, EnableMentionPrefix = true, Services = deps }); interactivity = discord.UseInteractivity(new InteractivityConfiguration { PaginationBehaviour = DSharpPlus.Interactivity.Enums.PaginationBehaviour.Ignore, // default timeout for other actions to 2 minutes Timeout = TimeSpan.FromMinutes(2) }); discord.Ready += async e => { LogToConsole(LogLevel.Info, "Assistant Ready"); }; cmd.CommandExecuted += Commands_CommandExecuted; cmd.CommandErrored += Commands_CommandErrored; discord.MessageReactionAdded += DeathGame_StartMsg_MessageReactionAdded; discord.MessageReactionRemoved += DeathGame_StartMsg_MessageReactionRemoved; discord.GuildCreated += Discord_GuildCreated; cmd.RegisterCommands <DeathGameCommands>(); cmd.RegisterCommands <ConfigCommands>(); cmd.RegisterCommands <CharacterCommands>(); await discord.ConnectAsync(); await Task.Delay(-1); }
public Bot(IServiceProvider Services) { var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = sr.ReadToEnd(); var configJson = JsonConvert.DeserializeObject <Configjson>(json); var config = new DiscordConfiguration { Token = configJson.token, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true }; Client = new DiscordClient(config); Client.Ready += OnClientReady; Client.GuildMemberAdded += GuildMemberAdd; Client.UseInteractivity(new InteractivityConfiguration { Timeout = TimeSpan.FromMinutes(2) }); var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.prefix }, EnableDms = true, EnableMentionPrefix = true, DmHelp = false, Services = Services }; Commands = Client.UseCommandsNext(commandsConfig); Commands.CommandErrored += OnCommandError; Commands.RegisterCommands <FunCommands>(); Commands.RegisterCommands <Moderation>(); Commands.RegisterCommands <Memes>(); Client.ConnectAsync(); }
public async void RunAsync() { var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = await sr.ReadToEndAsync().ConfigureAwait(false); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); var config = new DiscordConfiguration { Token = configJson.Token, TokenType = TokenType.Bot, AutoReconnect = true, MinimumLogLevel = LogLevel.Debug, //UseInternalLoggingHandler = true }; Client = new DiscordClient(config); //listens to events Client.Ready += OnClientReady; Client.UseInteractivity(new InteractivityConfiguration { Timeout = TimeSpan.FromSeconds(60) }); var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.Prefix }, EnableMentionPrefix = true, EnableDms = true, }; Commands = Client.UseCommandsNext(commandsConfig); Commands.RegisterCommands <FunCommands>(); Commands.RegisterCommands <RoomCommands>(); Commands.RegisterCommands <PlayerOnlyCommands>(); Commands.RegisterCommands <MechCustomizationCommands>(); Commands.RegisterCommands <InformationCommands>(); //Commands.RegisterCommands<GameCommands>(); //Commands.RegisterCommands<GameOperatorCommands>(); //Commands.RegisterCommands<GameSettingsCommands>(); await Client.ConnectAsync(); await Task.Delay(-1); }
public async Task RunAsync() { var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = sr.ReadToEnd(); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); //convert json to string var config = new DiscordConfiguration() { Token = configJson.Token, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true }; Client = new DiscordClient(config); Client.Ready += OnClientReady; Client.UseInteractivity(new InteractivityConfiguration { Timeout = TimeSpan.FromDays(1) }); var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.Prefix }, EnableDms = false, EnableMentionPrefix = true, DmHelp = true //EnableDefaultHelp = false, //IgnoreExtraArguments = true, //UseDefaultCommandHandler = true }; Commands = Client.UseCommandsNext(commandsConfig); Commands.RegisterCommands <FlareCommands>(); Commands.RegisterCommands <AdminCommands>(); Commands.RegisterCommands <UserCommands>(); await Client.ConnectAsync(); await Task.Delay(-1); }
public async Task RodarBotAsync() { var json = ""; using (var inhau = File.OpenRead("corno.json")) using (var yay = new StreamReader(inhau, new UTF8Encoding(false))) json = await yay.ReadToEndAsync(); var cfgjson = JsonConvert.DeserializeObject <ConfigJson>(json); Console.WriteAscii("Gabriel Tenma White", Color.Cyan); DiscordConfiguration cfg = new DiscordConfiguration { Token = cfgjson.Token, TokenType = TokenType.Bot, ReconnectIndefinitely = true, GatewayCompressionLevel = GatewayCompressionLevel.Stream, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true, }; _client = new DiscordClient(cfg); _client.Ready += Client_Ready; _client.ClientErrored += Client_ClientError; string[] prefix = new string[1]; prefix[0] = cfgjson.CommandPrefix; CommandsNextExtension cnt = _client.UseCommandsNext(new CommandsNextConfiguration() { StringPrefixes = prefix, EnableDms = true, CaseSensitive = false, EnableDefaultHelp = true, EnableMentionPrefix = true, IgnoreExtraArguments = true, }); cnt.CommandExecuted += Cnt_CommandExecuted; cnt.RegisterCommands <Comandos_Foda_se>(); cnt.RegisterCommands <NSFW>(); cnt.RegisterCommands <Kt>(); cnt.RegisterCommands <Coisa_de_fudido>(); await _client.ConnectAsync(); await Task.Delay(-1); }
private CommandsNextExtension SetCommands() { _logger.LogInformation(DockordEventId.BotCmdModuleConfig, "Configuring bot commands..."); CommandsNextExtension commands = Client.UseCommandsNext(_discordConfig.CommandsNext) ?? throw new InvalidOperationException("Failed to configure bot commands."); _eventService.SetupCommandEventHandlers(commands); commands.RegisterCommands <BasicCommands>(); commands.RegisterCommands <ConfirmOrDeny>(); return(commands); }
/// <summary>Start this shit up!</summary> public async Task RunAsync() { // Load shit. string authKey = LoadConfig(); DiscordConfiguration botConfig = new DiscordConfiguration { Token = authKey, TokenType = TokenType.Bot, AutoReconnect = true, UseInternalLogHandler = true, LogLevel = LogLevel.Critical | LogLevel.Debug | LogLevel.Error | LogLevel.Info | LogLevel.Warning, }; BotClient = new DiscordClient(botConfig); var commandConfig = new CommandsNextConfiguration() { CaseSensitive = false, EnableMentionPrefix = true, EnableDefaultHelp = false, EnableDms = true }; Commands = BotClient.UseCommandsNext(commandConfig); Commands.CommandExecuted += Commands_CommandExecuted; Commands.CommandErrored += Commands_CommandErrored; Commands.RegisterCommands <Commands.ConfigCommands>(); Commands.RegisterCommands <Commands.FilterCommands>(); Commands.RegisterCommands <Commands.ReminderCommands>(); Commands.RegisterCommands <Commands.RequestedCommands>(); BotClient.MessageCreated += FilterSystem.BotClient_MessageCreated; BotClient.MessageCreated += FROZEN.BotClient_MessageCreated; BotClient.MessageUpdated += FilterSystem.BotClient_MessageUpdated; BotClient.ClientErrored += BotClient_ClientErrored; BotClient.Heartbeated += ReminderSystem.BotClient_Heartbeated; BotClient.Ready += BotClient_Ready; FilterSystem.FilterTriggered += BotClient_FilterTriggered; await BotClient.ConnectAsync(); await Task.Delay(-1); }
public async Task RunAsync() { var json = string.Empty; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = await sr.ReadToEndAsync().ConfigureAwait(false); var configJson = JsonConvert.DeserializeObject <ConfigJson>(json); var config = new DiscordConfiguration { Token = configJson.Token, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true }; Client = new DiscordClient(config); Client.Ready += ClientReady; Client.VoiceStateUpdated += SeriousCommands.MemberJoin; Client.UseInteractivity(new InteractivityConfiguration { Timeout = TimeSpan.FromMinutes(2) });; var commandsConfig = new CommandsNextConfiguration { StringPrefixes = new string[] { configJson.Prefix }, EnableDms = true, EnableMentionPrefix = true, DmHelp = true }; Commands = Client.UseCommandsNext(commandsConfig); Commands.RegisterCommands <FunCommands>(); Commands.RegisterCommands <SeriousCommands>(); voice = Client.UseVoiceNext(); await Client.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { var config = await Config.Get(); discord = new DiscordClient(new DiscordConfiguration { Token = config.Token, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); // thingy for game status discord.Ready += OnReady; Interactivity = discord.UseInteractivity(new InteractivityConfiguration()); Lavalink = discord.UseLavalink(); // services shit // mostly for lavaplayer Services = new ServiceCollection() .AddSingleton <MusicService>() .AddSingleton(new LavalinkService(discord)) .BuildServiceProvider(true); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefixes = new string[] { config.Dev?config.Devfix: config.Prefix }, EnableDefaultHelp = false, IgnoreExtraArguments = true, Services = Services }); commands.CommandErrored += HandleError; commands.RegisterCommands <OtherCommands>(); commands.RegisterCommands <TestCommands>(); commands.RegisterCommands <HelpCmd>(); commands.RegisterCommands <MoneyCommands>(); commands.RegisterCommands <FunCommands>(); commands.RegisterCommands <OwnerCommands>(); commands.RegisterCommands <ShopGroup>(); commands.RegisterCommands <ImageCommands>(); commands.RegisterCommands <MusicCommands>(); commands.RegisterCommands <LootboxGroup>(); await discord.ConnectAsync(); await Task.Delay(-1); }