Esempio n. 1
0
        [RequireContext(ContextType.Guild)] //Cannot be requested via DM.
        public async Task GiveHamachiAsync()
        {
            //Log the caller.
            string LogEntry      = $"{DateTime.Now.ToString()} requested by {Context.User.Id} - {Context.User.Username}";
            var    ReportChannel = Context.Guild.GetTextChannel(BotTools.GetReportingChannelUlong());
            var    Requestor     = Context.User as SocketGuildUser;
            var    caller        = Context.User as IGuildUser;

            //Check the Netbattler Role.
            if (caller.RoleIds.Contains(RoleModule.GetRole("Netbattler", Context.Guild).Id))
            {
                //Check to see if the user can accept DMs.
                try
                {
                    string HamachiServer = BotTools.GetSettingString(BotTools.ConfigurationEntries.HamachiServer);
                    string HamachiPass   = BotTools.GetSettingString(BotTools.ConfigurationEntries.HamachiPassword);

                    await Context.User.SendMessageAsync($"**N1 Grand Prix Hamachi Server**\n```\nServer: {HamachiServer}\nPassword: {HamachiPass}\n```\n\nPlease ensure that your PC name on Hamachi matches your Nickname on the N1GP Discord to help make matchmaking easier.\n\n**DO NOT provide the N1 Grand Prix Hamachi server credentials to anyone outside the N1GP.**");

                    await ReportChannel.SendMessageAsync("", embed : EmbedTool.UserHamachiRequest(Requestor));

                    await ReplyAsync("You have e-mail.");
                }
                catch (Exception)
                {
                    await ReplyAsync("You currently have DMs disabled. Please enable DMs from users on the server to obtain the Hamachi credentials.");

                    throw;
                }
            }
            else
            {
                await ReplyAsync("You are not authorized to obtain Hamachi credentials. Use `!license` before attempting to use this command.");
            }
        }
Esempio n. 2
0
 public async Task JoinEventAsync([Remainder] string NetbattlerName)
 {
     SyncParticipantList();
     if (IsEventActive())
     {         //Is the event active?
         if (GetActiveEvent().RegistrationOpen == true)
         {     //Is registration open?
             if (IsParticipantRegistered(Context.User.Id) == true)
             { //The user is already registered.
                 await ReplyAsync("", embed : EmbedTool.CommandError($"You are already registered for the {GetActiveEvent().EventName} event."));
             }
             else
             {
                 if (VerifyNetbattlerName(NetbattlerName) == true)
                 { //Completing Task 56
                     //The Netbattler Name the user is attempting to use is already registered.
                     await ReplyAsync("The Netbattler Name you've selected is already in use. Please register with a different name.");
                 }
                 else
                 {  //The Netbattler Name is not registered.
                     EventParticipant newParticipant = new EventParticipant(NetbattlerName.Replace('@', ' '), Context.User.Id);
                     ParticipantList.Add(newParticipant);
                     WriteParticipantList();
                     await ToggleRole(Context.User as IGuildUser, RoleModule.GetRole("Official Netbattler", Context.Guild));//Add the Official Netbattler role to the user.
                     await ReplyAsync("", embed : EmbedTool.ChannelMessage($"You have registered for the event {GetActiveEvent().EventName} sucessfully!"));
                 }
             }
         }
         else //registration is closed.
         {
             await ReplyAsync("", embed : EmbedTool.CommandError($"{GetActiveEvent().EventName} is currently not accepting registrations."));
         }
     }
     else
     {
         await ReplyAsync("", embed : EmbedTool.CommandError("There currently isn't an active event."));
     }
 }
Esempio n. 3
0
 public async Task DropEventAsync()
 {
     SyncParticipantList();
     if (IsEventActive())
     {
         //We don't need to check for open registration to drop.
         var caller = Context.User as IGuildUser;
         if (IsParticipantRegistered(Context.User.Id) == true)
         {//The user is already registered.
             ParticipantList.Remove(GetParticipant(caller));
             WriteParticipantList();
             await ToggleRole(Context.User as IGuildUser, RoleModule.GetRole("Official Netbattler", Context.Guild)); //Remove the Official Netbattler role.
             await ReplyAsync("", embed : EmbedTool.ChannelMessage($"You have dropped from {GetActiveEvent().EventName}"));
         }
         else
         {
             await ReplyAsync("", embed : EmbedTool.CommandError($"You are not registered for the {GetActiveEvent().EventName} event."));
         }
     }
     else
     {
         await ReplyAsync("", embed : EmbedTool.CommandError("There currently isn't an active event."));
     }
 }
Esempio n. 4
0
        [RequireContext(ContextType.Guild)] //Cannot be requested via DM.
        public async Task GiveRadminAsync()
        {
            //Log the caller.
            string LogEntry      = $"{DateTime.Now.ToString()} requested by {Context.User.Id} - {Context.User.Username}";
            var    ReportChannel = Context.Guild.GetTextChannel(BotTools.GetReportingChannelUlong());
            var    Requestor     = Context.User as SocketGuildUser;
            var    caller        = Context.User as IGuildUser;

            //Check the Netbattler Role.
            if (caller.RoleIds.Contains(RoleModule.GetRole("Netbattler", Context.Guild).Id))
            {
                //Check to see if the user can accept DMs.
                try
                {
                    //Pivoting this to a complete message rather than


                    string RadminServer = BotTools.GetSettingString(BotTools.ConfigurationEntries.RadminCredentialString);

                    await Context.User.SendMessageAsync(RadminServer);              //Updated this to, instead of using a template, use a moderator-specified string in its entirety. -MMX 6/18/2021

                    await ReportChannel.SendMessageAsync("", embed : EmbedTool.UserRadminRequest(Requestor));
                    await ReplyAsync("You have e-mail.");
                }
                catch (Exception)
                {
                    await ReplyAsync("You currently have DMs disabled. Please enable DMs from users on the server to obtain the Radmin credentials.");

                    throw;
                }
            }
            else
            {
                await ReplyAsync("You are not authorized to obtain Radmin credentials. Use `!license` before attempting to use this command.");
            }
        }
Esempio n. 5
0
        public async Task GetAllNewMoonParticipantAvatarsAsync()
        {
            if (IsEventOrganizer(Context.User as IGuildUser, Context.Guild))
            {
                //pain peko -mmx
                CleanupCache();
                await Context.Guild.DownloadUsersAsync();

                List <SocketGuildUser> users = Context.Guild.Users.ToList <SocketGuildUser>();
                List <string>          MoonbattlerAvatarURLs = new List <string>();
                List <string>          MoonbattlerUsernames  = new List <string>();
                WebClient client = new WebClient();
                foreach (var item in users)
                {
                    if (item.Roles.Contains(RoleModule.GetRole("MOON BATTLER", Context.Guild)))
                    {
                        MoonbattlerAvatarURLs.Add(item.GetAvatarUrl());
                        MoonbattlerUsernames.Add($"{item.Username} - {item.Nickname}");
                    }
                }
                await ReplyAsync("Downloading user avatars. This may take a moment.");

                for (int i = 0; i < MoonbattlerAvatarURLs.Count; i++)
                {
                    bool retry   = false;
                    int  counter = 3;
                    do
                    {
                        // Try to catch all failures
                        retry = false;
                        try
                        {
                            client.DownloadFile(new Uri(MoonbattlerAvatarURLs[i]), $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Cache{Path.DirectorySeparatorChar}{MoonbattlerUsernames[i]}.png");
                        }
                        catch (Exception ex)
                        {
                            counter--;
                            retry = true;
                            await ReplyAsync($"{ex.Message} On Image {MoonbattlerAvatarURLs[i]} by user{MoonbattlerUsernames[i]}. {counter} Attempts left.");

                            Thread.Sleep(1000);
                            if (counter == 0)
                            {
                                retry   = false;
                                counter = 3;
                            }
                        }
                    }while(retry);
                }

                await ReplyAsync("Download completed. You have email.");

                string ZIPTarget = $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Cache{Path.DirectorySeparatorChar}MoonBattlerMugshots.zip";

                ZipFile.CreateFromDirectory($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Cache", $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}MoonbattlerMugshots.zip");

                await Context.User.SendFileAsync($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}MoonbattlerMugshots.zip", "");

                //string ThumbnailURL = usr.GetAvatarUrl();
            }
        }