コード例 #1
0
        private async Task HandleJoinAsync(SocketGuildUser s)
        {
            Console.WriteLine("New user joined: " + s.Guild);

            //await s.Guild.DefaultChannel.SendMessageAsync("Joined the Server!");

            foreach (SocketGuild guild in _client.Guilds)
            {
                Console.WriteLine("Guild: " + guild.Name);

                foreach (RestInviteMetadata invite in await guild.GetInvitesAsync())
                {
                    Console.WriteLine(invite.Code + " -> " + invite.Uses + " Guild: " + guild.Name);

                    CommandHandler.invitelog.Add(new InviteLog(invite, guild));
                }
            }

            List <InviteLog> templog = new List <InviteLog>();

            foreach (RestInviteMetadata invite in await s.Guild.GetInvitesAsync())
            {
                Console.WriteLine(invite.Code + " -> " + invite.Uses);

                templog.Add(new InviteLog(invite, s.Guild));
            }

            await Iterations.FindChannel(s.Guild, "bot-spam").SendMessageAsync(s.Mention + " joined using " + InviteLog.FindInvite(templog, invitelog).Code);

            templog = new List <InviteLog>();
            foreach (SocketGuild guild in _client.Guilds)
            {
                Console.WriteLine("Guild: " + guild.Name);

                foreach (RestInviteMetadata invite in await guild.GetInvitesAsync())
                {
                    Console.WriteLine(invite.Code + " -> " + invite.Uses + " Guild: " + guild.Name);

                    templog.Add(new InviteLog(invite, guild));
                }
            }

            invitelog = templog;
        }
コード例 #2
0
        public async Task StartPoll()
        {
            if (Context.Message.Author.Id != 193255051807031296 &&
                (!Iterations.HasRole((SocketGuildUser)Context.User, "Mod") &&
                 !Iterations.HasRole((SocketGuildUser)Context.User, "Admin") &&
                 !Iterations.HasRole((SocketGuildUser)Context.User, "Junior Dev") &&
                 !Iterations.HasRole((SocketGuildUser)Context.User, "Supervisor") &&
                 !Iterations.HasRole((SocketGuildUser)Context.User, "Owner")))
            {
                await Context.Message.Channel.SendMessageAsync("Permission Denied.");

                return;
            }

            Console.WriteLine("Starting Poll");

            Poll LastPoll = polls.Last();

            Console.WriteLine(LastPoll.PollName);

            string MessageBuilder = "";

            int index = 1;

            foreach (string options in LastPoll.PollOptions)
            {
                MessageBuilder += index + ": " + "[" + options + "]" + "\n";

                index++;
            }

            Console.WriteLine(MessageBuilder);

            await Iterations.FindChannel(Context.Guild, "news").SendMessageAsync(Context.Guild.EveryoneRole.Mention + "\nPoll " + LastPoll.PollName + " has been started by " + Context.User.Mention + ".\n"
                                                                                 + "To vote now, type $vote with the number thats next to the option you're voting for like this `$vote 1`" + "\n\n"
                                                                                 + MessageBuilder
                                                                                 );


            Console.WriteLine("Sent");
        }