static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { AutoReconnect = true, UseInternalLogHandler = true, LogLevel = LogLevel.Debug, Token = "***", TokenType = TokenType.Bot }); discord.MessageCreated += async e => { if (e.Message.Content.ToLower().StartsWith("ping")) { await e.Message.RespondAsync("Pong!"); } }; commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "~" }); commands.RegisterCommands <MyCommands>(); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { ulong choreChannelID = 0; ulong.TryParse(args[1], out choreChannelID); discord = new DiscordClient(new DiscordConfiguration { Token = args[0], TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); commands.RegisterCommands <Chorecommand>(); await discord.ConnectAsync(); choreChannel = await discord.GetChannelAsync(choreChannelID); //Wait forever, all work should be done before this point await Task.Delay(-1); }
static async Task MainAsync(string[] args) { //Настройка базовой конфигурации бота DiscordConfiguration DiscordConfig = new DiscordConfiguration { Token = DiscordToken, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }; discord = new DiscordClient(DiscordConfig); //Настройка списка комманд CommandsNextConfiguration commandsConfig = new CommandsNextConfiguration { StringPrefix = "!!", EnableMentionPrefix = true, EnableDms = false }; commands = discord.UseCommandsNext(commandsConfig); commands.RegisterCommands <MyCommands> (); Console.WriteLine("Bot staterted 2.0"); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { _client = new DiscordClient(new DiscordConfiguration { Token = File.ReadLines(TOKEN_PATH).First(), TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); _client.SetWebSocketClient <WebSocket4NetCoreClient>(); _commands = _client.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "+" }); _commands.RegisterCommands <Commands>(); await _client.ConnectAsync(); await Task.Delay(-1); }
public Bot(Settings settings) { this.Settings = settings; ProgramStart = DateTimeOffset.Now; Client = new DiscordClient(new DiscordConfiguration { AutoReconnect = true, EnableCompression = true, LogLevel = LogLevel.Debug, Token = settings.Token, TokenType = TokenType.Bot, UseInternalLogHandler = true }); Interactivity = Client.UseInteractivity(); var deps = new DependencyCollectionBuilder().AddInstance(this).Build(); Commands = Client.UseCommandsNext(new CommandsNextConfiguration { CaseSensitive = false, EnableDefaultHelp = true, EnableDms = false, EnableMentionPrefix = true, StringPrefix = settings.Prefix, Dependencies = deps }); Commands.RegisterCommands <Main>(); Commands.RegisterCommands <Owner>(); CTS = new CancellationTokenSource(); Client.SocketOpened += async() => { await Task.Yield(); SocketStart = DateTimeOffset.Now; }; Commands.CommandErrored += async e => { e.Context.Client.DebugLogger.LogMessage(LogLevel.Critical, "Commands", e.Exception.ToString(), DateTime.Now); }; AsyncListenerHandler.InstallListeners(Client, this); }
async Task InitBot(string[] args) { try { Console.WriteLine("[info] David is starting"); _cts = new CancellationTokenSource(); Console.WriteLine("[info] Loading config file.."); _config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("config.json", optional: false, reloadOnChange: true) .Build(); Console.WriteLine("[info] Creating discord client.."); _discord = new DiscordClient(new DiscordConfiguration { Token = _config.GetValue <string>("discord:token"), TokenType = TokenType.Bot }); _interactivity = _discord.UseInteractivity(new InteractivityConfiguration() { PaginationBehaviour = TimeoutBehaviour.Delete, PaginationTimeout = TimeSpan.FromSeconds(30), Timeout = TimeSpan.FromSeconds(30) }); var deps = BuildDeps(); _commands = _discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = _config.GetValue <string>("discord:CommandPrefix"), Dependencies = deps }); Console.WriteLine("[info] Loading command modules.."); var type = typeof(IModule); var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => type.IsAssignableFrom(p) && !p.IsInterface); var typeList = types as Type[] ?? types.ToArray(); foreach (var t in typeList) { _commands.RegisterCommands(t); } Console.WriteLine($"[info] Loaded {typeList.Count()} modules."); RunAsync(args).Wait(); } catch (Exception ex) { Console.Error.WriteLine(ex.ToString()); } }
public void Configure() { CommandsNext = Client.UseCommandsNext(new CommandsNextConfiguration() { StringPrefix = _account.DiscordBotSettings.CommandCharacter, EnableMentionPrefix = true }); CommandsNext.CommandExecuted += CommandsNextOnCommandExecuted; CommandsNext.CommandErrored += CommandsNextOnCommandErrored; CommandsNext.RegisterCommands <DungeonMasterCommands>(); CommandsNext.RegisterCommands <TwitchCommands>(); CommandsNext.RegisterCommands <DiscJockeyCommands>(); CommandsNext.RegisterCommands <HumbleBundleCommands>(); CommandsNext.RegisterCommands <JanitorCommands>(); }
static async Task Main() { Commands.RegisterCommands <GoTCommands>(); await DiscordClient.ConnectAsync(); await Task.Delay(-1); }
public async Task Start() { _discordClient = new DiscordClient(GetDiscordConfiguration()); _discordClient.UseInteractivity(GetInteractivityConfiguration()); _commandsNextModule = _discordClient.UseCommandsNext(GetCommandsNextConfiguration()); _commandsNextModule.RegisterCommands <TestController>(); _commandsNextModule.RegisterCommands <PollController>(); _commandsNextModule.RegisterCommands <RoleController>(); _commandsNextModule.SetHelpFormatter <MazeHelpFormatter>(); await _discordClient.ConnectAsync(); await Task.Delay(-1); }
public async Task RunBotAsync() { var cfg = new DiscordConfiguration { Token = _config.Token, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true }; Client = new DiscordClient(cfg); Client.Ready += Client_Ready; Client.GuildAvailable += Client_GuildAvailable; Client.ClientErrored += Client_ClientError; Client.MessageCreated += Client_MessageCreated; Client.MessageUpdated += Client_MessageUpdated; Client.MessageDeleted += Client_MessageDeleted; Client.GuildMemberAdded += Client_GuildMemberAdded; var ccfg = new CommandsNextConfiguration { StringPrefix = _config.CommandPrefix, EnableDms = true, EnableMentionPrefix = true, }; Commands = Client.UseCommandsNext(ccfg); Commands.CommandExecuted += Commands_CommandExecuted; Commands.CommandErrored += Commands_CommandErrored; Commands.RegisterCommands <AdminCommands>(); Commands.RegisterCommands <ModeratorCommands>(); Commands.RegisterCommands <ProfileCommands>(); Client.UseInteractivity(new InteractivityConfiguration() { Timeout = TimeSpan.FromMinutes(2) }); await Client.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { Strix.CBot.DoInitClient(out _pClient, out _pCommands); _pCommands.RegisterCommands <Command_Search>(); await _pClient.ConnectAsync(); await Task.Delay(-1); }
private static void RegisterAll() { commands.RegisterCommands <ModCommands>(); commands.RegisterCommands <Misc>(); commands.RegisterCommands <Tag>(); commands.RegisterCommands <Tickets>(); commands.RegisterCommands <Applications>(); commands.RegisterCommands <Suggestions>(); commands.RegisterCommands <Warnings>(); commands.RegisterCommands <Experience>(); }
public async Task RunBotAsync() { // first, let's load our configuration 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(); // next, let's load the values from that file // to our client's configuration var cfgjson = JsonConvert.DeserializeObject <ConfigJson>(json); //TODO: overrite help to be more verbose, example in one of samples #region Client Client = new DiscordClient(new DiscordConfiguration { Token = cfgjson.Token, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true }); Client.ClientErrored += Client_ClientErrored; #endregion #region Commands Commands = Client.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = cfgjson.CommandPrefix, EnableDms = false, EnableMentionPrefix = true }); Commands.CommandExecuted += Commands_CommandExecuted; Commands.CommandErrored += Commands_CommandErrored; Commands.RegisterCommands <Commands>(); CommandsNextUtilities.RegisterConverter(new CommandConverters.NullableBoolConverter()); CommandsNextUtilities.RegisterConverter(new CommandConverters.NullableIntConverter()); #endregion #region Voice Voice = Client.UseVoiceNext(new VoiceNextConfiguration { VoiceApplication = VoiceApplication.Music }); #endregion await Client.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] arg) { discord = new DiscordClient(new DiscordConfiguration //initializes the bot! { Token = "", TokenType = TokenType.Bot, UseInternalLogHandler = true, //output all state and doings in console LogLevel = LogLevel.Debug, }); discord.MessageCreated += async e => // MessageCreated is the event, += is subscribing the method to the event. When a MessageCreate event triggers, our method will run // async e is an async method. Async will run non blocking // e => is a lambda expression. It takes in input parameter e and returns with the statement { if (e.Message.Content.ToLower().StartsWith("ping")) { // await suspends execution of this method until the task is complete. // In this example, we suspend this method and wait for our message to parse. // control resumes here when e.message.content.tolower().startswith is complete //got em await e.Message.RespondAsync("pong!"); } }; commands = discord.UseCommandsNext(new CommandsNextConfiguration //configure the prefix with the commands { StringPrefix = ".", EnableDms = false }); commands.RegisterCommands <MyCommands>(); interactivity = discord.UseInteractivity(new InteractivityConfiguration //default configurations { // set default to delete reactions PaginationBehaviour = TimeoutBehaviour.Delete, // default pagination timeout to 5 minutes PaginationTimeout = TimeSpan.FromMinutes(1), // default timeout for other actions to 2 minutes Timeout = TimeSpan.FromMinutes(1) }); voice = discord.UseVoiceNext(); await discord.ConnectAsync(); //Have to await an async method (Also why we had to make an async main task) await Task.Delay(-1); // Prevent the bot from flashing and quitting immediately }
private static async Task <int> MainAsync() { var token = ConfigurationManager.AppSettings["Token"]; _discord = new DiscordClient(new DiscordConfiguration { Token = token, TokenType = TokenType.Bot, LogLevel = LogLevel.Debug, UseInternalLogHandler = false }); _discord.Ready += DiscordOnReady; _discord.GuildAvailable += DiscordOnGuildAvailable; _discord.ClientErrored += DiscordOnClientErrored; _discord.DebugLogger.LogMessageReceived += DebugLoggerOnMessageReceived; _discord.Heartbeated += DiscordHeartbeated; var prefix = ConfigurationManager.AppSettings["Prefix"]; var ccfg = new CommandsNextConfiguration { StringPrefix = prefix, CaseSensitive = false }; _commands = _discord.UseCommandsNext(ccfg); _commands.CommandExecuted += CommandsOnCommandExecuted; _commands.CommandErrored += CommandsOnCommandErrored; _commands.RegisterCommands <GeneralCommands>(); _commands.RegisterCommands <GameCommands>(); _commands.RegisterCommands <ClanCommands>(); _commands.RegisterCommands <TankCommands>(); _commands.RegisterCommands <PlayerCommands>(); _commands.RegisterCommands <CoderCommands>(); _commands.RegisterCommands <AdminCommands>(); await _discord.ConnectAsync(); Log.Info("Connected. Waiting..."); while (true) { await Task.Delay(TimeSpan.FromMinutes(1.0)); var heartBeatAge = DateTime.UtcNow - _lastHeartBeat; if (heartBeatAge.TotalMinutes > 5) { break; } } Log.Fatal("5 minutes without a heart beat. He is dead, Jin!"); return(1); }
static async Task MainAsync(string[] args) { string CurrentToken; string CurrentPrefix; if (DevMode) { CurrentToken = "token"; CurrentPrefix = "no1test/"; } else { CurrentToken = "token"; CurrentPrefix = "no1/"; } discord = new DiscordClient(new DiscordConfiguration { Token = $"{CurrentToken}", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Error, }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { CaseSensitive = false, StringPrefix = $"{CurrentPrefix}", }); commands.RegisterCommands <StandardCommands>(); commands.RegisterCommands <AdminCommands>(); if (DevMode) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("[WARNING]: Running in DevMode! NOT FOR PRODUCTION!"); Console.ResetColor(); } Console.ResetColor(); Console.WriteLine("Bot is now online!"); await discord.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; var commandsConfig = new CommandsNextConfiguration { StringPrefix = configJson.Prefix, EnableDms = false, EnableMentionPrefix = false, EnableDefaultHelp = true }; _commands = _client.UseCommandsNext(commandsConfig); _commands.RegisterCommands <GameCommand>(); _commands.RegisterCommands <TimerCommand>(); _commands.RegisterCommands <WeatherCommand>(); _commands.RegisterCommands <BaisicCommands>(); await _client.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { AutoReconnect = true, Token = "Token", TokenType = TokenType.Bot }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); discord.MessageCreated += async e => { if (Scam.censoredWords.Any(x => e.Message.Content.ToLower().Contains(x))) { var scamlink = new DiscordEmbedBuilder() .WithColor(new DiscordColor("#f03434")) .WithAuthor("🚫 Scam link found! 🚫") .AddField("📩 Sent by:", $"{e.Message.Author.Username}#{e.Message.Author.Discriminator}", false) .AddField("📝 Message contained:", $"{e.Message.Content}", false) .AddField("🗑️ Message was deleted", $"In, {e.Message.Channel}", false) .WithTimestamp(DateTime.Now); await e.Guild.GetChannel(427905802553262080).SendMessageAsync(null, false, scamlink); await e.Message.DeleteAsync(); //Removed strike system for now. var reason = ""; var amount = 0; reason = "Scam link."; amount = 2; await e.Guild.GetChannel(427905843535675401).SendMessageAsync($"{e.Message.Author.Username}#{e.Message.Author.Discriminator}" + "\n" + $"- {reason}" + "\n" + "Strikes: " + $"{amount}/3"); } //bad words if (Curse.censoredWords.Any(x => e.Message.Content.ToLower().Contains(x))) { var curse = new DiscordEmbedBuilder() .WithColor(new DiscordColor("#f03434")) .WithAuthor("🚫 Curse word found! 🚫") .AddField("📩 Sent by:", $"{e.Message.Author.Username}#{e.Message.Author.Discriminator}", false) .AddField("📝 Message contained:", $"{e.Message.Content}", false) .AddField("🗑️ Message was deleted", $"In, {e.Message.Channel}", false) .WithTimestamp(DateTime.Now); await e.Message.DeleteAsync(); await e.Guild.GetChannel(427905802553262080).SendMessageAsync(null, false, curse); } }; commands.RegisterCommands <Commands>(); await discord.ConnectAsync(); await Task.Delay(-1); }
private void SetupDiscordCommands() { var commandConfig = new CommandsNextConfiguration { StringPrefix = "~", EnableDms = true, EnableMentionPrefix = false }; Commands = _discordClient.UseCommandsNext(commandConfig); Commands.RegisterCommands <UtilityCommands>(); // Discord only commands }
public async Task Start() { _client = new DiscordClient(GetDiscordConfiguration()); _commandsNext = _client.UseCommandsNext(GetCommandsNextConfiguration()); _commandsNext.RegisterCommands <TestController>(); await _client.ConnectAsync(); await Task.Delay(-1); }
static async Task Main(string[] args) { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", false, true) .AddJsonFile("secrets.json", true, true); Configuration = builder.Build(); // Use this if you want App_Data off your project root folder string baseDir = Directory.GetCurrentDirectory(); AppDomain.CurrentDomain.SetData("DataDirectory", System.IO.Path.Combine(baseDir, "DataFiles")); discord = new DiscordClient(new DiscordConfiguration { Token = Environment.GetEnvironmentVariable("DiscordAPIKey") ?? Configuration["token"], TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = Configuration["commandPrefix"], CaseSensitive = false }); commands.RegisterCommands <Commands.CypherCommands>(); interactivity = discord.UseInteractivity(new InteractivityConfiguration() { }); //Initialize the database and migrate on start. var db = new CypherContext(); db.Database.Migrate(); if (Configuration["appInitialize"].ToLower() == "true") { Console.WriteLine("Initializing the database."); await Utilities.DatabaseHelper.InitializeDatabaseAsync(); Console.WriteLine("Database Initialized, please set the appInitialize flag in appsettings.json to false in order to stop the database from being overridden again."); System.Threading.Thread.Sleep(3000); } await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { var json = ""; using (var fs = File.OpenRead("config.json")) using (var sr = new StreamReader(fs, new UTF8Encoding(false))) json = await sr.ReadToEndAsync(); var cfgjson = JsonConvert.DeserializeObject <ConfigJson>(json); discord = new DiscordClient(new DiscordConfiguration { Token = cfgjson.Token, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Error }); discord.SetWebSocketClient <WebSocketSharpClient>(); discord.GuildCreated += async e => { var defaultChannel = e.Guild.GetDefaultChannel(); Console.Write($"Joined: {defaultChannel}"); await discord.SendMessageAsync(defaultChannel, "Bonzi in da HOUSE"); }; discord.Ready += async e => { await Task.Run(() => { Console.WriteLine("Initialized SharpBonzi!"); Console.WriteLine($"Connected to {discord.Guilds.Count} Guilds"); }); //Init Playing var playingGame = new DiscordGame(); playingGame.Name = "Windows 95"; await discord.UpdateStatusAsync(playingGame); }; commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = cfgjson.CommandPrefix, EnableMentionPrefix = true }); commands.RegisterCommands <MyCommands>(); commands.SetHelpFormatter <SimpleHelpFormatter>(); await discord.ConnectAsync(); await Task.Delay(-1); }
public async Task MainAsync(string[] args) { discordBot = new DiscordClient(new DiscordConfiguration { UseInternalLogHandler = true, LogLevel = LogLevel.Debug, TokenType = TokenType.Bot, Token = token }); commands = discordBot.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!", EnableDefaultHelp = false }); commands.RegisterCommands <HelpCommand>(); commands.RegisterCommands <CrazyEightsCommand>(); await discordBot.ConnectAsync(); await Task.Delay(-1); }
private void SetupCommands() { var cncfg = new CommandsNextConfiguration { StringPrefix = Config.bot.cmdPrefix, EnableDms = true, EnableMentionPrefix = true, EnableDefaultHelp = false }; _commands = Client.UseCommandsNext(cncfg); _commands.RegisterCommands <NormalCommands>(); }
static async Task MainAsync(string[] args) { _pRoomManager = XML_RoomManage.Load(); Strix.CBot.DoInitClient(out _pClient, out _pCommands); _pClient.GuildMemberAdded += _pClient_GuildMemberAdded; _pCommands.RegisterCommands <Command_RoomManage>(); await _pClient.ConnectAsync(); await Task.Delay(-1); }
// The Bot's main execution loop is an Async Task with infinite Delay, ensuring it won't time out under normal circumstances. static async Task MainAsync(string[] args) { // We need a secure way to hold token data var json = ""; // Unpack the token data into our struct. using (var configFile = File.OpenRead("config.json")) using (var configReader = new StreamReader(configFile, new UTF8Encoding(false))) json = await configReader.ReadToEndAsync(); var jsonConfig = JsonConvert.DeserializeObject <ConfigJson>(json); // Init a variable to hold our config struct, so it's easy to change later. var config = new DiscordConfiguration { Token = jsonConfig.Token, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true }; // Initialize the variable holding our Discord Client. discord = new DiscordClient(config); // Basic ping/pong functionality, essentially a debug function early on. discord.MessageCreated += async e => { if (e.Message.Content.ToLower().StartsWith("ping")) { await e.Message.RespondAsync("pong!"); } }; // Set up the string prefix for commands. In this case, because it's convention, we're using "!". // the space is important for presentability reasons. commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!", EnableDms = true, EnableMentionPrefix = true }); // Register our commands from Commands.cs. commands.RegisterCommands <Commands>(); // Connect to the service. await discord.ConnectAsync(); // Make sure the await has infinite delay, so that the bot won't naturally time out! await Task.Delay(-1); }
static async Task MainAsyn() { string _Token = ""; string url = @"C:\Users\stepa\OneDrive\Рабочий стол\TokenBot.txt"; using (StreamReader sr = new StreamReader(url)) { _Token = sr.ReadToEnd(); } discord = new DiscordClient(new DiscordConfiguration { Token = _Token, TokenType = TokenType.Bot, }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); commands.RegisterCommands <MyCommands>(); discord.MessageCreated += async e => { DiscordGame game = new DiscordGame(); var html = @"https://topcraft.ru/servers/308/servers/"; HtmlWeb web = new HtmlWeb(); var htmlDoc = web.Load(html); string[] OnlServers = new string[15]; string OnlServersStr = ""; var nodes = htmlDoc.DocumentNode.SelectNodes("//span[@class='online']"); int count = 0; foreach (var node in nodes) { OnlServers[count] = node.InnerText; OnlServersStr += OnlServers[count] + "\n"; count++; } game.Name = "TM (" + OnlServers[3] + ")"; await discord.UpdateStatusAsync(game); }; await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { //magic to prevent OperationNotSupportedException var proxy = WebRequest.DefaultWebProxy; WebRequest.DefaultWebProxy = null; KomoLogger logger = new KomoLogger(); try { config = new JsonParser().Config; } catch (Exception e) { logger.Fatal("Loading configuration", e); Console.ReadKey(); return; } ServiceContainer.Container.RegisterType <ITwitchService, TwitchService>(new InjectionConstructor(config.twitchClientID, config.twitchAccessToken, config.twitchChannelsToMonitor)); ServiceContainer.Container.RegisterType <IWoWService, WoWService>(new InjectionConstructor(config.blizzardCharInfoEndpoint, config.blizzardOauthAccessTokenEndpoint, config.blizzardOauthCheckTokenEndpoint, config.client_id, config.client_secret)); ServiceContainer.Container.RegisterType <ILeagueService, LeagueService>(new InjectionConstructor(config.lolApiKey)); ServiceContainer.Container.RegisterType <ICoronaService, CoronaService>(new InjectionConstructor(config.coronaUrl)); DiscordClient client = new DiscordClient(new DiscordConfiguration() { TokenType = TokenType.Bot, Token = config.DiscordAPIKey, UseInternalLogHandler = true, LogLevel = LogLevel.Debug, }); commands = client.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!", EnableDms = true, CaseSensitive = false, EnableDefaultHelp = true, }); commands.RegisterCommands <Commands>(); logger.Debug("Connecting..."); await client.ConnectAsync(); logger.Debug("Connected, waiting for client initialization."); await Task.Delay(5000); logger.Debug("Starting initialization."); await Initialize(client, config); logger.Debug("Initialized"); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = Environment.GetEnvironmentVariable("BotToken"), TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = Environment.GetEnvironmentVariable("Prefix") }); commands.RegisterCommands <CommandModule>(); commands.RegisterCommands <APIConnectModule>(); commands.RegisterCommands <ImageSendModule>(); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = "NDIxNzY1MjA5NzU4MjM2Njky.DpoxbA.gdPDqOHDKjBbo530XRm65KsCd_A", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "." }); commands.RegisterCommands <Commands>(); commands.RegisterCommands <SettingsCommands>(); commands.RegisterCommands <AdminCommands>(); commands.RegisterCommands <UtilityCommands>(); await discord.ConnectAsync(); await Task.Delay(-1); }