Ejemplo n.º 1
0
    //private functions handler;

    public async Task MainAsync()
    {
        if (!File.Exists("data.sqlite"))
        {
            SQLiteConnection.CreateFile("data.sqlite");
            using (SQLiteConnection con = DataModules.DBConnection())
            {
                con.Open();
                new SQLiteCommand("CREATE TABLE USERS (Id INTEGER NOT NULL PRIMARY KEY, DiscordId INTEGER NOT NULL UNIQUE, Waifu varchar(100), Gender varchar(10), WaifuGender varchar(10))", con).ExecuteNonQuery();
                new SQLiteCommand("CREATE TABLE COMFORT (Text varchar(2000), Type varchar(50))", con).ExecuteNonQuery();
                new SQLiteCommand("CREATE TABLE LEWD (Text varchar(2000), Type varchar(50))", con).ExecuteNonQuery();
                con.Close();
            }
        }

        string token;
        var    filestream = new FileStream("token.txt", FileMode.Open, FileAccess.Read);

        using (var streamreader = new StreamReader(filestream, Encoding.UTF8))
        {
            token = streamreader.ReadLine();
        }

        _client  = new DiscordSocketClient();
        _config  = BuildConfig();
        commands = new CommandService();

        await _client.LoginAsync(TokenType.Bot, token);

        await _client.StartAsync();

        services = new ServiceCollection()
                   .AddSingleton(_client)
                   .AddSingleton <InteractiveService>()
                   .BuildServiceProvider();

        await InstallCommands();

        await Task.Delay(-1);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据当前用户信息获取模块信息
        /// </summary>
        /// <returns></returns>
        public List <ModuleModel> GetModule()
        {
            DataModules.Clear();
            //CheckDesingModel.IsDebug &&
            if (Loginer.CurrentLoginer.IsSysAdmin)
            {
                DataModules = GetModuleALL();
            }
            else
            {
                DataModules = GetModuleConfig();
            }
            DataFunctions.Clear();
            foreach (var m in DataModules)
            {
                foreach (var f in m.functions)
                {
                    DataFunctions.Add(f.FunctionID, f);
                }
            }

            return(DataModules);
        }