Exemplo n.º 1
0
        public static ServidorCore GetServidor(ulong id)
        {
            ServidorCore server = ColecaoServidor.Find(x => x.Id == id).FirstOrDefault();

            if (server == null)
            {
                server = new ServidorCore()
                {
                    Id = id,
                };
                ColecaoServidor.InsertOne(server);
            }
            return(server);
        }
Exemplo n.º 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));
        }
Exemplo n.º 3
0
        public async Task ComandoPrefixoAb(CommandContext ctx, string prefix = null)
        {
            ServidorCore server = ModuloBanco.GetServidor(ctx.Guild.Id);

            if (string.IsNullOrWhiteSpace(prefix))
            {
                server.Prefix = "";
                server.Salvar();
                await ctx.RespondAsync("Prefix removido!").ConfigureAwait(false);
            }
            else
            {
                if (prefix.Length > 3)
                {
                    await ctx.RespondAsync("O prefixo não pode passar de 3 caracteres!").ConfigureAwait(false);

                    return;
                }
                server.Prefix = prefix;
                server.Salvar();
                await ctx.RespondAsync("Prefixo alterado!").ConfigureAwait(false);
            }
        }
Exemplo n.º 4
0
 public static void EditServidor(ServidorCore server) => ColecaoServidor.ReplaceOne(x => x.Id == server.Id, server);