예제 #1
0
        public async Task AddToGang(IGuildUser user)
        {
            if (GangRepository.InGang(user.Id, Context.Guild.Id))
            {
                throw new Exception("This user is already in a gang.");
            }
            if (GangRepository.IsFull(Context.User.Id, Context.Guild.Id))
            {
                throw new Exception("Your gang is already full!");
            }
            GangRepository.AddMember(Context.User.Id, Context.Guild.Id, user.Id);
            await ReplyAsync($"{user} is now a new member of your gang!");

            var channel = await user.CreateDMChannelAsync();

            await channel.SendMessageAsync($"Congrats! You are now a member of {GangRepository.FetchGang(Context).Name}!");
        }
예제 #2
0
파일: Gangs.cs 프로젝트: txhawkeye/DEA
        public async Task AddToGang(IGuildUser user)
        {
            using (var db = new SQLite.Models.DbContext())
            {
                var gangRepo = new GangRepository(db);
                if (await gangRepo.InGangAsync(user.Id, Context.Guild.Id))
                {
                    throw new Exception("This user is already in a gang.");
                }
                if (await gangRepo.IsFull(Context.User.Id, Context.Guild.Id))
                {
                    throw new Exception("Your gang is already full!");
                }
                await gangRepo.AddMemberAsync(Context.User.Id, Context.Guild.Id, user.Id);
                await ReplyAsync($"{user} is now a new member of your gang!");

                var channel = await user.CreateDMChannelAsync();

                await channel.SendMessageAsync($"Congrats! You are now a member of {(await gangRepo.FetchGangAsync(user.Id, Context.Guild.Id)).Name}!");
            }
        }