Beispiel #1
0
        static void Main(string[] args)
        {
            var configurationFilename = (args.Length > 0) ? args[0] : DefaultConfigurationFilename;
            var configuration         = SoundboardBotConfiguration.FromFile(configurationFilename);
            var bot = new SoundboardBot(configuration);

            Console.Title = configuration.Name;

            bot.Connect();
        }
Beispiel #2
0
        public static SoundboardBotConfiguration FromFile(string filename)
        {
            var config = new SoundboardBotConfiguration();

            if (!File.Exists(filename))
            {
                return(config);
            }

            config.Load(Configuration.FromFile(filename));

            return(config);
        }
Beispiel #3
0
        public SoundboardBot(SoundboardBotConfiguration cfg)
        {
            Configuration         = cfg ?? new SoundboardBotConfiguration();
            SoundEffectRepository = new SoundboardEffectRepository();
            SoundEffectRepository.LoadFromDirectory(Configuration.EffectsPath);

            Database = new SoundboardDatabase(new SoundboardDatabaseConfiguration()
            {
                Path = Configuration.DatabasePath
            });

            Statistics = new SoundboardStatistics(Database);

            sending = new ManualResetEvent(true);
            save    = CreateSaveTask();

            client = new DiscordClient(x =>
            {
                x.AppName               = Configuration.Name;
                x.MessageCacheSize      = 0;
                x.UsePermissionsCache   = false;
                x.EnablePreUpdateEvents = true;
                x.LogLevel              = LogSeverity.Info;
            });

            client.MessageReceived += OnMessageReceived;
            client.UsingModules();
            client.UsingAudio(x =>
            {
                x.Mode              = AudioMode.Outgoing;
                x.EnableEncryption  = false;
                x.EnableMultiserver = false;
                x.Bitrate           = 128;
                x.BufferLength      = 10000;
            });
        }