Ejemplo n.º 1
0
        public async Task <int> CountUwU(SocketGuildUser user, SocketCommandContext commandContext)
        {
            var           uwuCollection = MongoDbClient.kawaekoDatabase.GetCollection <UwURecord>("UwUCounter");
            UwURepository uwuCounterRepo;

            switch (user)
            {
            case null:
                uwuCounterRepo = new UwURepository(commandContext);
                return(await uwuCounterRepo.GetServerUwUCount());

            default:
                uwuCounterRepo = new UwURepository(user, commandContext);
                return(await uwuCounterRepo.GetUserUwUCount());
            }
        }
Ejemplo n.º 2
0
        public async Task HandleMessage(SocketMessage messageEvent)
        {
            var discordMessage = messageEvent as SocketUserMessage;

            if (MessageIsSystemMessage(discordMessage))
            {
                return; //Return and ignore if the message is a discord system message
            }
            if (discordMessage.Channel == null)
            {
                return; //Return and ignore if the message is not in a guild
            }
            if (discordMessage.Author.IsBot)
            {
                return; //Return and ignore if the message is from a bot
            }
            if (!discordMessage.Content.ToLower().Contains("uwu"))
            {
                return; //Return and ignore if the message doesn't even have uwu, don't waste time
            }
            var discordMessageChannel = messageEvent.Channel as SocketTextChannel;

            var uwuCounterRepo = new UwURepository(discordMessageChannel, messageEvent);
            var uwuList        = await uwuCounterRepo.GetUwURecord();

            if (uwuList == null)
            {
                return;
            }
            switch (uwuList.Count)
            {
            case 0:
                await uwuCounterRepo.InsertNewUwURecord();

                break;

            default:
                await uwuCounterRepo.IncrementUwURecord(uwuList.First());

                break;
            }
        }