예제 #1
0
        public async Task RodarOBotAsync()
        {
            _config = ConfigCore.LoadFromFile(EntrarPasta("") + "config.json");
            if (_config == null)
            {
                Console.WriteLine("O arquivo config.json não existe!");
                Console.WriteLine("Coloque as informações necessarias no arquivo gerado!");
                Console.WriteLine("Aperte qualquer botão para sair...");
                Console.ReadKey();
                Environment.Exit(0);
            }
            DiscordConfiguration cfg = new DiscordConfiguration
            {
#if DEBUG
                Token = _config.TokenTeste,
#else
                Token = _config.Token,
#endif
                TokenType               = TokenType.Bot,
                ReconnectIndefinitely   = true,
                GatewayCompressionLevel = GatewayCompressionLevel.Stream,
                AutoReconnect           = true,
#if DEBUG
                LogLevel = LogLevel.Debug,
#else
                LogLevel = LogLevel.Info,
#endif
                UseInternalLogHandler = true,
            };
            ModuloCliente cliente = new ModuloCliente(cfg);

            string[] prefix = new string[1];
#if DEBUG
            prefix[0] = _config.PrefixTeste;
#else
            prefix[0] = _config.Prefix;
#endif
            ModuloComandos todosOsComandos = new ModuloComandos(new CommandsNextConfiguration
            {
                StringPrefixes       = prefix,
                EnableDms            = false,
                CaseSensitive        = false,
                EnableDefaultHelp    = false,
                EnableMentionPrefix  = true,
                IgnoreExtraArguments = true,
                PrefixResolver       = PrefixResolverCustomizado,
            }, ModuloCliente.Client);
            new ModuloBanco();
            await ModuloBanco.CarregarItensAsync();

            // await ModuloBanco.CarregarRegioesTrizbortAsync();
            await ModuloCliente.Client.ConnectAsync();

            await Task.Delay(-1);
        }
예제 #2
0
        public static Task <int> PrefixResolverCustomizado(DiscordMessage msg)
        {
            var gld = msg.Channel.Guild;

            if (gld == null)
            {
                return(Task.FromResult(-1));
            }
            ServidorCore slv = ModuloBanco.GetServidor(gld.Id);

            if (string.IsNullOrEmpty(slv.Prefix))
            {
                return(Task.FromResult(-1));
            }

            var pfixLocation = msg.GetStringPrefixLength(slv.Prefix);

            if (pfixLocation != -1)
            {
                return(Task.FromResult(pfixLocation));
            }
            return(Task.FromResult(-1));
        }