/// <summary> /// Entry point of the program. /// </summary> /// <param name="args">Input arguments.</param> static void Main(string[] args) { #region ninject init Container = new StandardKernel(); Container.Load(new NinjectBindings()); _commandScanner = Container.Get <CommandScanner>(); #endregion #region set up discord client var config = new DiscordConfigBuilder { LogLevel = LogSeverity.Debug, }.Build(); _client = new DiscordClient(config); _client.MessageReceived += HandleMessage; _commandScanner.SetDiscordClient(_client); #endregion string token = ConfigurationManager.AppSettings["BotToken"]; _client.ExecuteAndWait(async() => { await _client.Connect(token, TokenType.Bot); }); }
public AudioClient(DiscordClient client, Server server, int id) { Id = id; Service = client.GetService <AudioService>(); Config = Service.Config; Serializer = client.Serializer; _gatewayState = (int)ConnectionState.Disconnected; //Logging Logger = client.Log.CreateLogger($"AudioClient #{id}"); //Async _taskManager = new TaskManager(Cleanup, false); _connectionLock = new AsyncLock(); CancelToken = new CancellationToken(true); //Networking if (Config.EnableMultiserver) { //TODO: We can remove this hack when official API launches var baseConfig = client.Config; var builder = new DiscordConfigBuilder { AppName = baseConfig.AppName, AppUrl = baseConfig.AppUrl, AppVersion = baseConfig.AppVersion, CacheToken = baseConfig.CacheDir != null, ConnectionTimeout = baseConfig.ConnectionTimeout, EnablePreUpdateEvents = false, FailedReconnectDelay = baseConfig.FailedReconnectDelay, LargeThreshold = 1, LogLevel = baseConfig.LogLevel, MessageCacheSize = 0, ReconnectDelay = baseConfig.ReconnectDelay, UsePermissionsCache = false }; _config = builder.Build(); ClientAPI = new JsonRestClient(_config, DiscordConfig.ClientAPIUrl, client.Log.CreateLogger($"ClientAPI #{id}")); GatewaySocket = new GatewaySocket(_config, client.Serializer, client.Log.CreateLogger($"Gateway #{id}")); GatewaySocket.Connected += (s, e) => { if (_gatewayState == ConnectionState.Connecting) { EndGatewayConnect(); } }; } else { _config = client.Config; GatewaySocket = client.GatewaySocket; } GatewaySocket.ReceivedDispatch += (s, e) => OnReceivedEvent(e); VoiceSocket = new VoiceSocket(_config, Config, client.Serializer, client.Log.CreateLogger($"Voice #{id}")); VoiceSocket.Server = server; OutputStream = new OutStream(this); }
public LOIBCBot(LOIBCConfig config) { Config = config; var discordConfig = new DiscordConfigBuilder { AppName = "LOIBCBot" }.Build(); DiscordClient = new DiscordClient(discordConfig); }
static void Main(string[] args) { var options = new CliOptions(); if (CommandLine.Parser.Default.ParseArguments(args, options)) { var configBuilder = new DiscordConfigBuilder(); configBuilder.LogLevel = LogSeverity.Info; Console.WriteLine("Starting Bot... Press CTRL-c exit"); Run(options.LoginToken, configBuilder.Build()).Wait(); } else { Console.WriteLine("Press ENTER to exit"); Console.ReadLine(); } }
private void Init() { DiscordConfigBuilder ClientConfig = new DiscordConfigBuilder(); ClientConfig.AppName = "CrowBot"; ClientConfig.AppUrl = "https://github.com/Tic-Tac-Toc/DiscordCardBot"; ClientConfig.MessageCacheSize = 0; ClientConfig.AppVersion = "1.0"; ClientConfig.LogLevel = LogSeverity.Info; ClientConfig.LogHandler = OnLogMessage; Client = new DiscordClient(ClientConfig).UsingCommands(x => { x.PrefixChar = '+'; x.AllowMentionPrefix = true; x.HelpMode = HelpMode.Public; x.ErrorHandler = OnCommandError; }); SetCommands(); }
public Bot() { //initialize client DiscordConfigBuilder builder = new DiscordConfigBuilder(); builder.LogLevel = LogSeverity.Info; builder.LogHandler = new EventHandler <LogMessageEventArgs>(Bot_LogMessage); client = new DiscordClient(builder); //chat setting client.UsingCommands(input => { input.PrefixChar = '='; input.AllowMentionPrefix = true; }); //audio setting client.UsingAudio(x => // Opens an AudioConfigBuilder so we can configure our AudioService { x.Mode = AudioMode.Outgoing; // Tells the AudioService that we will only be sending audio }); musicHandler = new Music(client); textHandler = new Text(client, musicHandler); textHandler.Initialize(); client.ExecuteAndWait(async() => { await client.Connect("", TokenType.Bot); client.SetGame("Phantasy Star Online 2"); }); }
private void ConfigureClient(DiscordConfigBuilder cfg) { cfg.AppName = "LaberBot"; cfg.LogLevel = LogSeverity.Verbose; }
public DezClient(DiscordConfigBuilder builder) : base(builder) { _pmgr = new PluginManager(this); }