Пример #1
0
        public async Task Create()
        {
            var client = DiscordRestClient.ClientCredentialsGrantAsync(SECRET.CLIENT_ID, SECRET.CLIENT_SECRET, DefaultScopes);


            //Cleanup
            client.Dispose();
        }
Пример #2
0
        public async Task GetCache()
        {
            var client = await DiscordRestClient.ClientCredentialsGrantAsync(SECRET.CLIENT_ID, SECRET.CLIENT_SECRET, DefaultScopes);

            await client.InitializeCacheAsync();

            //Cleanup
            client.Dispose();
        }
Пример #3
0
        public async Task AddUserToGuild()
        {
            var client = await DiscordRestClient.ClientCredentialsGrantAsync(SECRET.CLIENT_ID, SECRET.CLIENT_SECRET, DefaultScopes);

            await client.InitializeCacheAsync();

            var bot = new DiscordClient(new DiscordConfiguration()
            {
                TokenType          = TokenType.Bot,
                Token              = SECRET.BotToken,
                AutomaticGuildSync = true,
                AutoReconnect      = true
            });

            bot.Ready += this.Bot_Ready;
            await bot.ConnectAsync();

            Ready.WaitOne();
            Ready.Reset();

            if (bot.Guilds.Count >= 5) //Technically 10, but we limit to 5
            {
                while (bot.Guilds.Count != 0)
                {
                    bot.Guilds.First().Value.DeleteAsync().Wait();
                }
            }

            var testG = await bot.CreateGuildAsync("Test Guild");

            var user      = client.CurrentUser;
            var adminrole = await testG.CreateRoleAsync("Admin", Permissions.Administrator, DiscordColor.DarkRed);

            await testG.AddMemberAsync(user, client.Token);

            var member = await testG.GetMemberAsync(user.Id);

            await member.GrantRoleAsync(adminrole, "Cause i can");

            //Just Leave it for the User :)
            //await testG.DeleteAsync();

            //Cleanup
            client.Dispose();
            await bot.DisconnectAsync();

            bot.Dispose();
        }
Пример #4
0
        public async Task GetToken()
        {
            var s = await DiscordRestClient.ClientCredentialsGrantAsync(SECRET.CLIENT_ID, SECRET.CLIENT_SECRET, DefaultScopes);

            Assert.True(s != null && !string.IsNullOrWhiteSpace(s.Token));
        }