Esempio n. 1
0
        private async Task MainAsync()
        {
            var json = JsonConvert.DeserializeObject <JObject>(File.ReadAllText("Keys/Credentials.json"));

            if (json["botToken"] == null)
            {
                throw new NullReferenceException("Invalid Credentials file");
            }

            P = this;

            await _commands.AddModuleAsync <Communication>(null);

            await _commands.AddModuleAsync <Gacha>(null);

            await _commands.AddModuleAsync <Debug>(null);

            Client.MessageReceived += HandleCommandAsync;

            StartTime = DateTime.Now;
            await Client.LoginAsync(TokenType.Bot, json["botToken"].Value <string>());

            await Client.StartAsync();

            await Task.Delay(-1);
        }
Esempio n. 2
0
        private async Task MainAsync()
        {
            Client = new DiscordSocketClient(new DiscordSocketConfig
            {
                LogLevel = LogSeverity.Debug
            });

            Command = new CommandService(new CommandServiceConfig
            {
                CaseSensitiveCommands = true,
                DefaultRunMode        = RunMode.Async,
                LogLevel = LogSeverity.Debug
            });

            Client.MessageReceived += Client_MessageReceived;
            await Command.AddModuleAsync(typeof(Helloworld));

            await Command.AddModuleAsync(typeof(kocka));

            await Command.AddModuleAsync(typeof(mentes));

            await Command.AddModuleAsync(typeof(szabad));

            Client.Ready += Client_Ready;
            Client.Log   += Client_Log;

            string Token = "NTM5MDI3MDM4MDE1NzE3Mzk1.Dy8kDw.SLBNqOlq1M4BiDo96qstGCeJ3x8";
            await Client.LoginAsync(TokenType.Bot, Token);

            await Client.StartAsync();

            await Task.Delay(-1);
        }
Esempio n. 3
0
        public async Task InstallCommandAsync()
        {
            _client.MessageReceived += HandleCommandAsync;
            await _commandService.AddModuleAsync <InfoModule>(_services);

            await _commandService.AddModuleAsync <AdminModule>(_services);
        }
Esempio n. 4
0
        public async Task InstallCommandsAsync()
        {
            // Hook the MessageReceived event into our command handler
            _client.MessageReceived += HandleCommandAsync;

            _client.MessageDeleted  += _client_MessageDeleted;
            _client.MessageUpdated  += _client_MessageUpdated;
            _client.ReactionAdded   += _client_ReactionAdded;
            _client.ReactionRemoved += _client_ReactionRemoved;

            _commands.AddTypeReader(typeof(System.Numerics.BigInteger), new BigIntegerTypeReader());
            _commands.AddTypeReader(typeof(IEmote), new EmojiTypereader());

            // Here we discover all of the command modules in the entry
            // assembly and load them. Starting from Discord.NET 2.0, a
            // service provider is required to be passed into the
            // module registration method to inject the
            // required dependencies.
            //
            // If you do not use Dependency Injection, pass null.
            // See Dependency Injection guide for more information.

            await _commands.AddModuleAsync <BasicModule>(null);

            await _commands.AddModuleAsync <ListSortModule>(null);

            await _commands.AddModuleAsync <BotServerManagmentModule>(null);

            await _commands.AddModuleAsync <MiscCommandsModlue>(null);

            await _commands.AddModuleAsync <ReminderModule>(null);

            //await _commands.AddModulesAsync(assembly: Assembly.GetEntryAssembly(),
            //                                services: null);
        }
Esempio n. 5
0
        private async Task MainAsync()
        {
            var json = JsonConvert.DeserializeObject <JObject>(File.ReadAllText("Keys/Credentials.json"));

            if (json["botToken"] == null)
            {
                throw new NullReferenceException("Invalid Credentials file");
            }

            Db = new Db();
            await Db.InitAsync("Natsuri");

            await _commands.AddModuleAsync <Communication>(null);

            await _commands.AddModuleAsync <Information>(null);

            await _commands.AddModuleAsync <Entertainment>(null);

            Client.MessageReceived += HandleCommandAsync;
            Client.GuildAvailable  += GuildJoined;
            Client.JoinedGuild     += GuildJoined;

            StartTime = DateTime.Now;
            await Client.LoginAsync(TokenType.Bot, json["botToken"].Value <string>());

            await Client.StartAsync();

            await Task.Delay(-1);
        }
Esempio n. 6
0
        public async Task InstallCommandsAsync()
        {
            // Hook the MessageReceived event into our command handler
            _client.MessageReceived += HandleCommandAsync;

            // Here we discover all of the command modules in the entry
            // assembly and load them. Starting from Discord.NET 2.0, a
            // service provider is required to be passed into the
            // module registration method to inject the
            // required dependencies.
            //
            // If you do not use Dependency Injection, pass null.
            // See Dependency Injection guide for more information.
            await _commands.AddModuleAsync <HelpModule>(null);

            await _commands.AddModuleAsync <ModerationModule>(null);

            await _commands.AddModuleAsync <RoleModule>(null);

            await _commands.AddModuleAsync <SettingsModule>(null);

            await _commands.AddModuleAsync <PollModule>(null);

            await _commands.AddModulesAsync(assembly : Assembly.GetEntryAssembly(),
                                            services : null);
        }
Esempio n. 7
0
        public async Task InitializeAsync()
        {
            _client.MessageReceived     += HandleCommandAsync;
            _client.MessageDeleted      += MessageDelete;
            _client.MessageUpdated      += MessageUpdated;
            _client.MessagesBulkDeleted += MessageBulkUpdated;
            _client.Ready += BotReady;
            _client.Log   += Log;

            _commands.CommandExecuted += OnCommandExecutedAsync;
            //await _commands.AddModulesAsync(Assembly.GetAssembly(typeof(InfoModule)), _services);

            await _commands.AddModuleAsync <InfoModule>(_services);

            await _commands.AddModuleAsync <SongRequestModule>(_services);

            await _commands.AddModuleAsync <AdminModule>(_services);

            await _commands.AddModuleAsync <WorldConfigModule>(_services);

            await _commands.AddModuleAsync <SIDModule>(_services);

            await _client.LoginAsync(TokenType.Bot, "NTgwMzgzNDY2MTE0MzgzOTA2.XjQo7g.1WzoyHlIloKarGHVzcoT4FOBHVA");

            await _client.StartAsync();

            _client.GuildAvailable += OnClientGuildAvailable;
        }
Esempio n. 8
0
        public async Task MainAsync()
        {
            await Loggers.LogEventAsync(new LogMessage(LogSeverity.Info, "Init...", "Stating Iyoku")).ConfigureAwait(false);

            Globals.InitConfig();
            await Globals.Db.InitAsync();

            await Loggers.LogEventAsync(new LogMessage(LogSeverity.Info, "Setup", "Initializing Modules...")).ConfigureAwait(false);

            await commands.AddModuleAsync <CommunicationModule>(null);

            await commands.AddModuleAsync <CollectionModule>(null);

            await commands.AddModuleAsync <CollectionManagementModule>(null);

            await commands.AddModuleAsync <SourceUploaderModule>(null);

            Globals.Client.MessageReceived += SourceCheck;
            Globals.Client.MessageReceived += HandleMessageAsync;
            Globals.Client.Ready           += InitJailChannels;
            Globals.Client.ReactionAdded   += CheckLikeReactions;

            Globals.Client.ChannelCreated += CheckNewJailChannel;

            commands.Log += Loggers.LogEventAsync;

            await Globals.Client.LoginAsync(TokenType.Bot, Globals.BotToken);

            await Globals.Client.StartAsync();

            await Task.Delay(-1).ConfigureAwait(false);
        }
Esempio n. 9
0
        public async Task InitializeAsnyc()
        {
            await _commands.AddModuleAsync <PublicModule>(_services);

            await _commands.AddModuleAsync <ChannelSpecificModule>(_services);

            await _commands.AddModuleAsync <DMSpecificModule>(_services);
        }
Esempio n. 10
0
        public async Task InstallCommandsAsync()
        {
            _discordClient.MessageReceived += HandleCommandAsync;

            await _commands.AddModuleAsync <PublicModule>(_services);

            await _commands.AddModuleAsync <AdminModule>(_services);
        }
        public async Task InitializeAsync()
        {
            // Register modules that are public and inherit ModuleBase<T>.
            await _commands.AddModuleAsync <DebugCommands>(_services);

            await _commands.AddModuleAsync <PlaylistCommands>(_services);

            //await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services);
        }
Esempio n. 12
0
        public async Task InstallCommands()
        {
            client.MessageReceived += HandleCommandAsync;
            await commands.AddModuleAsync <MathModule>();

            await commands.AddModuleAsync <HelpModule>();

            await commands.AddModuleAsync <TestModule>();
        }
Esempio n. 13
0
        public async Task AddModulesAsync()
        {
            if (environment.IsDevelopment())
            {
                await innerService.AddModuleAsync <TestingBotModule>(services);
            }

            await Task.WhenAll(innerService.AddModuleAsync <FoldingBotModule>(services),
                               innerService.AddModuleAsync <BaseModule>(services));
        }
Esempio n. 14
0
        public async Task InstallCommandsAsync()
        {
            _client.MessageReceived += HandleCommandAsync;
            await _commands.AddModuleAsync <Miscellaneous>();

            await _commands.AddModuleAsync <LastFm>();

            await _commands.AddModuleAsync <Help>();

            await _commands.AddModuleAsync <Admin>();
        }
Esempio n. 15
0
        public async Task InstallCommands()
        {
            serviceMap.AddSingleton(logger);

            services = serviceMap.BuildServiceProvider();
            // Hook the MessageReceived Event into our Command Handler
            client.MessageReceived += HandleCommand;
            await commands.AddModuleAsync <MOTD>();

            await commands.AddModuleAsync <Memeconomy>();
        }
Esempio n. 16
0
        private async Task RegisterCommands()
        {
            _client.MessageReceived += HandleCommandAsync;
            await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services);

            await _commands.AddModuleAsync <PublicMessageModule>(_services);

            await _commands.AddModuleAsync <VoteRestart>(_services);

            await _commands.AddModuleAsync <RestartServer>(_services);
        }
Esempio n. 17
0
        private async Task MainAsync()
        {
            await BotDb.InitAsync("SkytaleBot");

            client.MessageReceived += HandleCommandAsync;
            client.Connected       += Connected;
            client.GuildAvailable  += GuildUpdate;
            client.JoinedGuild     += GuildUpdate;
            client.ReactionAdded   += ReactionAdded;

            await commands.AddModuleAsync <Modules.Settings>(null);

            await commands.AddModuleAsync <Modules.Information>(null);

            await commands.AddModuleAsync <Modules.Moderation>(null);

            await commands.AddModuleAsync <Modules.Leveling>(null);

            if (!File.Exists("Keys/Credentials.json"))
            {
                throw new FileNotFoundException("You must have a Credentials.json located in a 'Keys' folder near your executable.\nIt must contains a KeyValue botToken containing the token of your bot");
            }
            dynamic json = JsonConvert.DeserializeObject(File.ReadAllText("Keys/Credentials.json"));

            if (json.botToken == null)
            {
                throw new FileNotFoundException("You must have a Credentials.json located in a 'Keys' folder near your executable.\nIt must contains a KeyValue botToken containing the token of your bot");
            }
            if (json.websiteUrl != null && json.websiteToken != null)
            {
                websiteCredentials = new Tuple <string, string>((string)json.websiteUrl, (string)json.websiteToken);
            }
            else
            {
                websiteCredentials = null;
            }
            PerspectiveApi = json.perspectiveToken;
            if (json.googleAPIJson != null)
            {
                TClient = TranslationClient.Create(GoogleCredential.FromFile((string)json.googleAPIJson));
            }
            else
            {
                TClient = null;
            }

            await client.LoginAsync(TokenType.Bot, (string)json.botToken);

            StartTime = DateTime.Now;
            await client.StartAsync();

            await Task.Delay(-1);
        }
Esempio n. 18
0
        public async Task InstallCommands()
        {
            client.Log             += Log;
            client.MessageReceived += HandleCommandAsync;

            //add modules
            await commands.AddModuleAsync <AdminFunModule>(null);

            await commands.AddModuleAsync <FunModule>(null);

            await commands.AddModuleAsync <HelpModule>(null);
        }
Esempio n. 19
0
        /// <summary>
        /// Subscribe to received messages and register all of the commands
        /// </summary>
        /// <returns></returns>
        public async Task RegisterCommandsAsync()
        {
            // Add Commands to this by adding a new line with the Class between the <>
            await _commands.AddModuleAsync <Commands.Ping>(_services);

            await _commands.AddModuleAsync <Utilities.Voice>(_services);

            await _commands.AddModuleAsync <Commands.JoinEsportsRoles>(_services);

            await _commands.AddModuleAsync <Commands.Help>(_services);

            await _commands.AddModuleAsync <Utilities.VoiceHelp>(_services);
        }
Esempio n. 20
0
        public async Task InstallCommands()
        {
            client.MessageReceived += HandleCommand;
            await commands.AddModuleAsync <VotingModule>(services);

            await commands.AddModuleAsync <NominationsModule>(services);

            await commands.AddModuleAsync <ViewModule>(services);

            await commands.AddModuleAsync <InfoModule>(services);

            await commands.AddModuleAsync <HelpModule>(services);
        }
Esempio n. 21
0
        public async Task InstallCommandsAsync()
        {
            await _commands.AddModuleAsync <MalarkeyModule>(_services);

            await _commands.AddModuleAsync <HelpModule>(_services);

            await _commands.AddModuleAsync <IndecisionModule>(_services);

            await _commands.AddModuleAsync <BotModule>(_services);


            _client.MessageReceived += HandleCommandAsync;
        }
Esempio n. 22
0
        public async Task AddModuleAsync <T>() where T : SaltyModuleBase
        {
            await _commands.AddModuleAsync <T>();

            IReadOnlyList <Command> readOnlyList = _commands.GetAllModules().FirstOrDefault(s => s.Type == typeof(T))?.Commands;

            if (readOnlyList != null)
            {
                foreach (Command command in readOnlyList)
                {
                    _logger.Info($"[ADD_COMMAND] {command}");
                }
            }
        }
Esempio n. 23
0
        private async Task <CommandService> ConfigureCommandsAsync()
        {
            var commands = new CommandService(new CommandServiceConfig
            {
                LogLevel = LogSeverity.Info,
                CaseSensitiveCommands = false,
            });
            await commands.AddModuleAsync <FronterCommands>(services);

            await commands.AddModuleAsync <BasicCommands>(services);

            commands.Log += msg => LegacyLog <CommandService>(msg);
            return(commands);
        }
Esempio n. 24
0
        public async Task InitializeAsync()
        {
            await _Commands.AddModuleAsync <Commands.Blacklist>(_Services);

            await _Commands.AddModuleAsync <Commands.FakeChat>(_Services);

            await _Commands.AddModuleAsync <Commands.Help>(_Services);

            await _Commands.AddModuleAsync <Commands.RaidRecovery>(_Services);

            await _Commands.AddModuleAsync <Commands.Tools>(_Services);

            CommandList = _Commands.Commands.ToList().AsReadOnly();
        }
Esempio n. 25
0
        private async Task MainAsync()
        {
            db = new Db();
            await db.InitAsync();

            P    = this;
            rand = new Random();

            if (File.Exists("Keys/websiteToken.dat"))
            {
                string[] website = File.ReadAllLines("Keys/websiteToken.dat");
                websiteUrl   = website[0];
                websiteToken = website[1];
            }
            else
            {
                websiteUrl   = null;
                websiteToken = null;
            }

            client.MessageReceived += HandleCommandAsync;
            client.ReactionAdded   += ReactionAdded;

            await commands.AddModuleAsync <CommunicationModule>(null);

            await commands.AddModuleAsync <TicketModule>(null);

            await client.LoginAsync(TokenType.Bot, File.ReadAllText("Keys/token.dat"));

            StartTime = DateTime.Now;
            await client.StartAsync();

            var task = Task.Run(async() => {
                for (;;)
                {
                    await Task.Delay(60000);
                    UpdateStatus();
                    foreach (var chan in client.GetGuild(413302581968896000).GetCategoryChannel(585811641648807936).Channels)
                    {
                        if (chan.CreatedAt.AddMinutes(5).CompareTo(DateTime.Now) < 0)
                        {
                            await chan.DeleteAsync();
                        }
                    }
                }
            });

            await Task.Delay(-1);
        }
Esempio n. 26
0
        private async Task MainAsync()
        {
            client.MessageReceived += HandleCommandAsync;

            await commands.AddModuleAsync <Modules.Communication>(null);

            await commands.AddModuleAsync <Modules.AzurLane>(null);

            await client.LoginAsync(TokenType.Bot, File.ReadAllText("Keys/token.txt"));

            StartTime = DateTime.Now;
            await client.StartAsync();

            await Task.Delay(-1);
        }
Esempio n. 27
0
        public async Task InitializeAsync()
        {
            await commandService.AddModuleAsync <GuildConfigurationModule>(services);

            await commandService.AddModuleAsync <GPT2ChatConfigModule>(services);

            await logger.Log(new LogMessage(
                                 LogSeverity.Info,
                                 "CommadHandler",
                                 $"Available commands: {string.Join(", ", commandService.Commands.Select((commandInfo) => commandInfo.Name))}"
                                 ));


            client.MessageReceived += HandleCommandAsync;
        }
Esempio n. 28
0
        public DefaultHandler(IDiscordClient client, ServiceProvider services)
        {
            Client   = client;
            Services = services;

            Commands = new CommandService(new CommandServiceConfig()
            {
                CaseSensitiveCommands = true,
                DefaultRunMode        = RunMode.Async,
                LogLevel = LogSeverity.Debug
            });

            Commands.AddModuleAsync(typeof(Ping), services).Wait();
            Commands.AddModuleAsync(typeof(Mafia), services).Wait();
        }
Esempio n. 29
0
        public async Task TestMultiple()
        {
            var commands = new CommandService();
            var module   = await commands.AddModuleAsync <TestModule>(null);

            Assert.NotNull(module);
            Assert.NotEmpty(module.Commands);

            var cmd = module.Commands[0];

            Assert.NotNull(cmd);
            Assert.NotEmpty(cmd.Parameters);

            var param = cmd.Parameters[0];

            Assert.NotNull(param);
            Assert.True(param.IsRemainder);

            var result = await param.ParseAsync(null, "manyints: \"1, 2, 3, 4, 5, 6, 7\"");

            Assert.True(result.IsSuccess);

            var m = result.BestMatch as ArgumentType;

            Assert.NotNull(m);
            Assert.Equal(expected: new int[] { 1, 2, 3, 4, 5, 6, 7 }, actual: m.ManyInts);
        }
Esempio n. 30
0
        public async Task TestQuotedArgumentValue()
        {
            var commands = new CommandService();
            var module   = await commands.AddModuleAsync <TestModule>(null);

            Assert.NotNull(module);
            Assert.NotEmpty(module.Commands);

            var cmd = module.Commands[0];

            Assert.NotNull(cmd);
            Assert.NotEmpty(cmd.Parameters);

            var param = cmd.Parameters[0];

            Assert.NotNull(param);
            Assert.True(param.IsRemainder);

            var result = await param.ParseAsync(null, "foo: 42 bar: 《hello》");

            Assert.True(result.IsSuccess);

            var m = result.BestMatch as ArgumentType;

            Assert.NotNull(m);
            Assert.Equal(expected: 42, actual: m.Foo);
            Assert.Equal(expected: "hello", actual: m.Bar);
        }