// async method to handle bot running private static async Task MainAsync(string[] args) { // create the acual DiscordClient object. _discordClient = new DiscordClient(new DiscordConfiguration { // enable internal logging, no need for log4net anymore UseInternalLogHandler = true, #if DEBUG LogLevel = LogLevel.Debug, #else LogLevel = LogLevel.Info, #endif Token = ConfigReader.TOKEN, TokenType = TokenType.Bot }); // enable the commands module _commands = _discordClient.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = ConfigReader.PREFIX }); // _commands.RegisterCommands <DiceCommands>(); // actually connect to the discord servers await _discordClient.ConnectAsync(); // await for a delay of -1ms so that this mehtod is never terminated await Task.Delay(-1); }
public async Task Start() { try { _discordClient = new DiscordClient(new DiscordConfiguration { TokenType = TokenType.Bot, Token = _configuration["Discord:Token"] }); _interactivity = _discordClient.UseInteractivity(new InteractivityConfiguration { PaginationBehaviour = TimeoutBehaviour.Delete, PaginationTimeout = TimeSpan.FromSeconds(30), Timeout = TimeSpan.FromSeconds(30) }); var deps = BuildDeps(); _commands = _discordClient.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = _configuration["Discord:CommandPrefix"], Dependencies = deps }); _commands.RegisterCommands <BotCommands>(); await RunAsync(); } catch (Exception exc) { Console.Error.WriteLine(exc.ToString()); } }
static async Task MainAsync(string[] args) { string jsonData = File.ReadAllText("appSettings.Debug.json"); JObject jsonObject = JObject.Parse(jsonData); JToken jsonConnString = jsonObject["connString"]; string connString = jsonConnString.ToString(); DataHandler.URepo = new UserRepo(connString); DataHandler.DiscordToken = jsonObject["disKey"].ToString(); DataHandler.MWKey = jsonObject["mwKey"].ToString(); DataHandler.OpenWeather = jsonObject["oWeather"].ToString(); DataHandler.Users = DataHandler.URepo.GetUsers(); discord = new DiscordClient(new DiscordConfiguration { Token = DataHandler.DiscordToken, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "<>", CaseSensitive = false }); commands.RegisterCommands <Commands>(); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { ulong peperonieChannelID = 0; ulong.TryParse(args[1], out peperonieChannelID); //ulong testChannelID = 0; //ulong.TryParse(args[2], out testChannelID); discord = new DiscordClient(new DiscordConfiguration { Token = args[0], TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); commands.RegisterCommands <MyBestCommands>(); discord.GuildMemberAdded += NewMemberRequiredReading; await discord.ConnectAsync(); choreChannel = await discord.GetChannelAsync(peperonieChannelID); //await discord.ConnectAsync(); //choreChannel = await discord.GetChannelAsync(testChannelID); //Wait forever, all work should be done before this point await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = "<paste token here>", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); voice = discord.UseVoiceNext(new VoiceNextConfiguration { EnableIncoming = true }); commands.RegisterCommands <MyCommands>(); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = "youknowicantputmytokenhere", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); 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) { discord = new DiscordClient(new DiscordConfiguration { Token = "NDA4NTQzNDEzNTAwMTE3MDAy.DVRlXw.KAWm5d2Gf5qr1gnCNBs2_9NLzJo", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); 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); }
//actual main LOL pranked. static async Task MainAsync(string[] args) { //create discord client. client = new DiscordClient(new DiscordConfiguration { Token = Const.Token, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); //create voice client. voice = client.UseVoiceNext(); //attach commands commands = client.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "elmar " }); commands.RegisterCommands <RadioCommands>(); //log onto discord. await client.ConnectAsync(); //never close, never choose to. await Task.Delay(-1); }
async Task MainAsync() { if (!System.IO.File.Exists("secret.txt")) { throw new Exception("secret.txt was not found. Create secret.txt and put your bot's token in there. https://discord.foxbot.me/stable/guides/getting_started/first-bot.html#creating-a-discord-bot"); } DiscordConfiguration discordConfiguration = new DiscordConfiguration() { Token = System.IO.File.ReadAllLines("secret.txt")[0], TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }; CommandsNextConfiguration commandsNext = new CommandsNextConfiguration() { StringPrefix = "!", CaseSensitive = false, }; DiscordClient = new DiscordClient(discordConfiguration); Commands = DiscordClient.UseCommandsNext(commandsNext); Commands.RegisterCommands <Commands>(); Commands.CommandErrored += Commands_CommandErrored; await DiscordClient.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = "token here", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "~" }); commands.RegisterCommands <Commands>(); interactivity = discord.UseInteractivity(new InteractivityConfiguration()); voice = discord.UseVoiceNext(); discord.SetWebSocketClient <WebSocket4NetCoreClient>(); await discord.ConnectAsync(); await Task.Delay(-1); }
public static async Task AsyncMain(string[] args) { if (args.Length < 2) { Console.WriteLine("You must pass at minimum 2 arguments: -t \"Token\""); return; } if (args[0].Equals("-t")) { discord = new DiscordClient(new DiscordConfiguration { Token = args[1], TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); interactivity = discord.UseInteractivity(new InteractivityConfiguration()); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "::", }); /* * Code below this line must be left intact. */ commands.RegisterCommands <Commands>(); await discord.ConnectAsync(); await Task.Delay(-1); } else { Console.Write("Invalid Arugment"); } }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = "NDEwNTk2MTYzNzM4MTQwNjg0.DVvdBA.Bd0Fe0shsW3GRujTY7WvpZcjeiA", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = ".", EnableDms = false }); commands.RegisterCommands <Commands>(); voice = discord.UseVoiceNext(); await discord.ConnectAsync(); await Task.Delay(1000); await discord.UpdateStatusAsync(new DSharpPlus.Entities.DiscordGame(".all")); 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 = "?" }); /*discord.MessageCreated += async e => * { * if (e.Message.Content.ToLower().StartsWith("ping")) * await e.Message.RespondAsync("pong!"); * };*/ commands.RegisterCommands <BasicCommands>(); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = DiscordoBotToken.myBotToken, TokenType = TokenType.Bot }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); commands.RegisterCommands <DiscordoCommands>(); VoiceNextConfiguration vNextConfiguration = new VoiceNextConfiguration { VoiceApplication = VoiceApplication.Music }; voiceNextClient = discord.UseVoiceNext(vNextConfiguration); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { Config config = new Config("config.json"); // Instantiates Discord Client discord = new DiscordClient(new DiscordConfiguration { Token = config.GetToken(), // Whatever the path to your config file is goes here TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); discord.MessageCreated += async e => { if (e.Message.Content.ToLower().StartsWith("ping")) { await e.Message.RespondAsync("Pong!"); } }; commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); commands.RegisterCommands <RockPaperScissors>(); await discord.ConnectAsync(); await Task.Delay(-1); }
private void SetupCommands(ConfigJson config) { // Setup command configuration Client.DebugLogger.LogMessage(LogLevel.Debug, "SetupCommands", $"Configuring commands", DateTime.Now); CommandsNextConfiguration ccfg = new CommandsNextConfiguration { StringPrefix = config.CommandPrefix, CaseSensitive = false, EnableDms = true, EnableMentionPrefix = true }; this.Commands = this.Client.UseCommandsNext(ccfg); // Hook up some command events Client.DebugLogger.LogMessage(LogLevel.Debug, "SetupCommands", $"Hooking up events", DateTime.Now); this.Commands.CommandExecuted += StaticEvents.Command_Executed; this.Commands.CommandErrored += StaticEvents.Command_Errored; // Next, load/register our commands Client.DebugLogger.LogMessage(LogLevel.Debug, "SetupCommands", $"Registering commands", DateTime.Now); this.Commands.RegisterCommands <Fun>(); this.Commands.RegisterCommands <Utility>(); this.Commands.RegisterCommands <Searches>(); this.Commands.RegisterCommands <Games>(); this.Commands.RegisterCommands <Emotes>(); // Setup our help command formatter Client.DebugLogger.LogMessage(LogLevel.Debug, "SetupCommands", $"Setting up HelpFormatter", DateTime.Now); this.Commands.SetHelpFormatter <HelpFormatter>(); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { //Searches the Windows Environement Variables for the token Token = Environment.GetEnvironmentVariable("TOKEN"), TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); discord.SetWebSocketClient <WebSocketSharpClient>(); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" });; commands.RegisterCommands <Commands>(); interactivity = discord.UseInteractivity(new InteractivityConfiguration { // default pagination behaviour to just ignore the reactions PaginationBehaviour = TimeoutBehaviour.Ignore, // default pagination timeout to 5 minutes PaginationTimeout = TimeSpan.FromMinutes(5), // default timeout for other actions to 2 minutes Timeout = TimeSpan.FromMinutes(2) }); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = "placeholder", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); discord.MessageCreated += async e => { List <String> listStrLineElements = e.Message.Content.Split(' ').ToList(); if (string.Equals(listStrLineElements.ElementAt(0), "ping", StringComparison.OrdinalIgnoreCase)) { await e.Message.RespondAsync("pong!"); } if (string.Equals(listStrLineElements.ElementAt(0), "hello", StringComparison.OrdinalIgnoreCase)) { await e.Message.RespondAsync("Hi " + e.Message.Author.Username + "!"); } }; commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); commands.RegisterCommands <MyCommands>(); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = BotSettings.Token, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); discord.MessageCreated += async e => { if (e.Message.Content.ToLower().StartsWith("ping")) { await e.Message.RespondAsync("Dropping Database.....(type 'pretty pony' to cancel within specified timeframe)"); } }; commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "." }); interactivity = discord.UseInteractivity(new InteractivityConfiguration { }); commands.RegisterCommands <MyCommands>(); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration { Token = "NDM5NDc1MjA5Mjk3MzMwMTgw.DcTtBA.w1MhM-5h-s1ZjYilzizNVwJ0hQw", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); discord.MessageCreated += async e => { if (e.Message.Content.ToLower().StartsWith("ping")) { await e.Message.RespondAsync("pong!"); } }; commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = ";;" }); commands.RegisterCommands <Commands>(); interactivity = discord.UseInteractivity(new InteractivityConfiguration()); await discord.ConnectAsync(); await Task.Delay(-1); }
public async Task Start() { this.TwitchCommands = CommandHelper.GetCommands(_twitch_client); _discordClient = new DiscordClient(new DiscordConfiguration { Token = Environment.GetEnvironmentVariable("DiscordToken"), TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Error }); _discordClient.MessageCreated += async e => { if (e.Message.Content.ToLower().StartsWith("!ping")) { await e.Message.RespondAsync("pong!"); } }; commands = _discordClient.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); commands.RegisterCommands <ChatBot.DiscordBot.DiscordCommands>(); await _discordClient.ConnectAsync(); }
static async Task MainAsync(string[] args) { try { discord = new DiscordClient(new DiscordConfiguration { Token = BotConfig.GetContext.Token, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = BotConfig.GetContext.DebugMode, }); discord.ClientErrored += async delegate { Console.WriteLine("Error Triggered"); await discord.ReconnectAsync(); }; discord.VoiceStateUpdated += VoiceStateUpdatedEvent; discord.Ready += GetReady; discord.Heartbeated += HeartBeatedEvent; discord.MessageCreated += MessageCreateEvent; commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "!" }); commands.RegisterCommands <Commands>(); await discord.ConnectAsync(); await Task.Delay(-1); } catch { Console.WriteLine($@"Please config your bot credential at {AppDomain.CurrentDomain.BaseDirectory}preferences\config.json first before attempt to launch this application."); } }
public void Dispose() { _client.Dispose(); _interactivity = null; _cnext = null; _config = null; }
static async Task MainAsync(string[] args) { discord = new DiscordClient(new DiscordConfiguration() { Token = "",//TODO insert your bot token here TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); discord.MessageCreated += async e => { if (e.Message.Content.ToLower().Contains("ping")) { await e.Message.RespondAsync("pong!"); } }; commands = discord.UseCommandsNext(new CommandsNextConfiguration() { StringPrefix = ";;", CaseSensitive = false }); commands.RegisterCommands <MyCommands>(); interactivity = discord.UseInteractivity(new InteractivityConfiguration()); await discord.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { string envToken = Environment.GetEnvironmentVariable("APP_TOKEN"); string token = envToken == null?File.ReadAllText(DISCORD_TOKEN_FILE).Trim() : envToken; if (token == DEFAULT_INVALID_TOKEN) { Console.WriteLine("Please specify your discord app developer token in `discord-token.txt` or via the environment variable `APP_TOKEN`!"); return; } discord = new DiscordClient(new DiscordConfiguration() { Token = token, TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration() { StringPrefix = "~" }); commands.RegisterCommands <KrytheraCommands>(); await discord.ConnectAsync(); await Task.Delay(-1); }
public void Dispose() { this._client.Dispose(); this._interactivity = null; this._cnext = null; this._config = null; }
public async Task RunAsync() { var config = new DiscordConfiguration() { Token = Constants.API_TOKEN, TokenType = TokenType.Bot, AutoReconnect = true, LogLevel = LogLevel.Debug, UseInternalLogHandler = true, }; Client = new DiscordClient(config); Client.Ready += OnClientReady; var commandConfig = new CommandsNextConfiguration() { StringPrefix = Constants.PREFIX, EnableMentionPrefix = true, EnableDms = false, CaseSensitive = false, }; Commands = Client.UseCommandsNext(commandConfig); Commands.RegisterCommands <SlothCommands>(); await Client.ConnectAsync(); await Task.Delay(-1); }
static async Task MainAsync(string[] args) { //Initialize the Discord client. discord = new DiscordClient(new DiscordConfiguration { Token = "TOKEN_GOES_HERE", TokenType = TokenType.Bot, //Output debug information about the discord bot. UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); //Initialize the CommandsNextModule for this bot. commands = discord.UseCommandsNext(new CommandsNextConfiguration { //Set the bots command prefix to "$". StringPrefix = "$" }); //Get/Enable commands from custom Command Module (i.e BotCommands.cs). commands.RegisterCommands <BotCommands>(); await discord.ConnectAsync(); //Keep the console application running. await Task.Delay(-1); }
#pragma warning disable IDE0060 // Remove unused parameter static async Task Main(String[] args) #pragma warning restore IDE0060 // Remove unused parameter { discord = new DiscordClient(new DiscordConfiguration { Token = "", TokenType = TokenType.Bot, UseInternalLogHandler = true, LogLevel = LogLevel.Debug }); commands = discord.UseCommandsNext(new CommandsNextConfiguration { StringPrefix = "i.", CaseSensitive = false }); discord.MessageCreated += PingMessages; discord.MessageCreated += Automod; discord.MessageDeleted += MessageDeleteLogger; discord.GuildMemberAdded += Discord_GuildMemberAdded; discord.MessageReactionAdded += Discord_MessageReactionAdded; insanitynetworkguild = await discord.GetGuildAsync(693508439929782332); RegisterAll(); Experience.Initialize(); _ = discord.ConnectAsync(); _ = HandleTCP(); await Task.Delay(-1); }
public Drifter(DiscordClient client) { _instance = this; this._discord = client; this.redis = new CSRedisClient("localhost"); this.redis.SetDatabase(1).Wait(); this._rolemap = new RoleMap(this.redis); _interactivity = Discord.UseInteractivity(new InteractivityConfiguration() { }); _commands = Discord.UseCommandsNext(new CommandsNextConfiguration() { StringPrefix = ";" }); Commands.RegisterCommands <Commands.AdminCommands>(); Commands.RegisterCommands <Commands.MemeCommands>(); Commands.RegisterCommands <Commands.UtilityCommands>(); //Commands.RegisterCommands<Commands.VoiceCommand>(); Commands.RegisterCommands <Commands.ReactionRoleCommands>(); client.MessageReactionAdded += OnReactionAdded; client.MessageReactionRemoved += OnReactionRemoved; //client.VoiceStateUpdated += OnVoiceChange; }