Esempio n. 1
0
 private async Task HandleReactionAsync(Cacheable <IUserMessage, ulong> cacheable, ISocketMessageChannel messageChannel, SocketReaction reaction)
 {
     if (!reaction.User.Value.IsBot && PollHelper.IsMessagePoll(reaction.MessageId))
     {
         await PollHelper.VoteOnPollAsync(reaction, client);
     }
 }
Esempio n. 2
0
        public async Task PollCreate([Remainder] string argsParam) //args will be seperated by commas
        {
            string[] args  = argsParam.Split(',');
            string   title = args[0];

            string[] options = args.Skip(1).ToArray();

            if (options.Length <= 1)
            {
                await ReplyAsync("Polls must have 2 options or more!");

                return;
            }

            if (options.Length > 9)
            {
                await ReplyAsync("Polls are limited to 9 options! Reduce the number of options.");

                return;
            }

            foreach (string arg in args)
            {
                if (arg.Length >= 40)
                {
                    await ReplyAsync("Please limit the amount of text in your title/options!");

                    return;
                }
            }

            var message = await ReplyAsync("Creating poll...");

            try
            {
                PollHelper.CreatePoll(message.Id, title, options);
            }
            catch (PollNameTakenException)
            {
                await message.ModifyAsync(c => c.Content = "A poll with this name is already active! Choose a different name.");

                return;
            }

            await message.ModifyAsync(e => e.Embed = PollHelper.GetPollEmbed(title).Build());

            await message.ModifyAsync(c => c.Content = $"**{title}**");

            IEmote[] reactions = new IEmote[options.Length];
            for (int i = 0; i < reactions.Length; i++)
            {
                reactions[i] = PollHelper.numToEmote[i + 1];
            }

            await message.AddReactionsAsync(reactions);
        }
Esempio n. 3
0
        async Task Loop()
        {
            do
            {
                await ReminderHelper.ScanForNewReminders(client);

                if ((DateTime.UtcNow.Hour == 0 && DateTime.UtcNow.Minute < 1) || firstRun) //if it is a new day
                {
                    PollHelper.ScanForOldPolls();

                    await CalendarHelper.UpdateCalendarMessage(client);

                    CalendarHelper.RemoveOldEvents();

                    firstRun = false;
                }

                await Task.Delay(60000); //every minute
            } while (true);
        }