Exemplo 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.");
            }
        }
Exemplo n.º 2
0
 public async Task CallEventInfo()
 {
     if (IsEventActive())
     {
         await ReplyAsync("", embed : EmbedTool.EventInfoEmbed(GetActiveEvent()));
     }
 }
Exemplo n.º 3
0
        public async Task CreateEventAsync([Remainder] string EventName)
        {//TODO: Add an Alias for additional commands, add this to HelpModule.
            // 1. Check to see if an event is already active.
            if (IsEventActive())
            {
                await ReplyAsync("", embed : EmbedTool.CommandError("An event is already active and a new one cannot be created."));
            }
            else
            {
                // 2. Check to see if the caller is an Event Organizer.
                var caller = Context.User as IGuildUser;
                if (IsEventOrganizer(caller, Context.Guild))
                {
                    // 3. Create the Event.
                    Event newEvent = new Event(Context.User.Id, EventName);
                    newEvent.Description      = "Not yet configured.";
                    newEvent.RulesURL         = "Not yet configured.";
                    newEvent.StartDate        = "Not yet configured.";
                    newEvent.RegistrationOpen = false;
                    newEvent.AcceptingSetups  = false;

                    // 4. Serialize the event into a JSON.
                    File.WriteAllText($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Data{Path.DirectorySeparatorChar}Event.json", JsonConvert.SerializeObject(newEvent));
                    File.WriteAllText($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Data{Path.DirectorySeparatorChar}Registration.json", JsonConvert.SerializeObject(ParticipantList));
                    Directory.CreateDirectory($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Setups");
                    // 5. Confirm.
                    await ReplyAsync($"The event, {EventName}, has been created.");
                }
                else
                {
                    await ReplyAsync("You are not authorized to create events.");
                }
            }
        }
Exemplo n.º 4
0
        public async Task MessageReceivedAsync(SocketMessage rawMessage)
        {
            // Ignore system messages, or messages from other bots
            if (!(rawMessage is SocketUserMessage message))
            {
                return;
            }
            if (message.Source != MessageSource.User)
            {
                return;
            }
            var context = new SocketCommandContext(_discord, message);


            //Save Game Importing
            if (message.Attachments.Count == 1) //The message contains an attachment.
            {
                if (IsEventActive())
                {         //An event is active.
                    if (EventModule.IsParticipantRegistered(message.Author.Id))
                    {     //Check to see if the user is registered.
                        if (rawMessage.Attachments.FirstOrDefault <Attachment>().Filename.ToUpper().Contains("SA1"))
                        { //The message contains a save file. Download and process it.
                            string url            = rawMessage.Attachments.FirstOrDefault <Attachment>().Url;
                            string CacheDirectory = $"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Cache{Path.DirectorySeparatorChar}";
                            var    Client         = new WebClient();
                            Client.DownloadFile(new Uri(url), $"{CacheDirectory}{rawMessage.Author.Id}{rawMessage.Attachments.FirstOrDefault<Attachment>().Filename}");
                            Tools.BN6.SaveTool.ProcessSave($"{CacheDirectory}{rawMessage.Author.Id}{rawMessage.Attachments.FirstOrDefault<Attachment>().Filename}", rawMessage.Author.Id, EventModule.GetParticipant(rawMessage.Author).NetbattlerName);
                            EventModule.MarkAsSubmitted(rawMessage.Author);
                            await rawMessage.DeleteAsync();

                            await context.Channel.SendMessageAsync("Save file accepted.");
                        }
                        else if (rawMessage.Attachments.FirstOrDefault <Attachment>().Filename.ToUpper().Contains("SAV") || rawMessage.Attachments.FirstOrDefault <Attachment>().Filename.ToUpper().Contains(".SG"))
                        {
                            await rawMessage.DeleteAsync();

                            await context.Channel.SendMessageAsync("", false, EmbedTool.CommandError("I can only accept Save Files that are *.SA1 format. Please upload the correct save file."));
                        }
                    }
                }
            }


            // This value holds the offset where the prefix ends
            var argPos = 0;

            if (!(message.HasMentionPrefix(_discord.CurrentUser, ref argPos) || message.HasStringPrefix("!", ref argPos)))
            {
                return;
            }

            var result = await _commands.ExecuteAsync(context, argPos, _services);

            if (result.IsSuccess == false)
            {
                //The command failed?
            }
        }
Exemplo n.º 5
0
            [RequireUserPermission(GuildPermission.ViewAuditLog)] //Admin-Only.
            public async Task UpdateOnedriveAsync([Remainder] string newOnedriveLink)
            {
                dynamic BotConfiguration = JsonConvert.DeserializeObject(System.IO.File.ReadAllText($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}config.json"));

                BotConfiguration.OneDriveLink = newOnedriveLink;
                System.IO.File.WriteAllText($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}config.json", JsonConvert.SerializeObject(BotConfiguration, Formatting.Indented));
                await ReplyAsync("", false, EmbedTool.ChannelMessage("The drive Link has been updated."));
            }
Exemplo n.º 6
0
 public async Task CloseEventAsync()
 {//Closes the event and delets the Participant JSON and the Event JSON.
     if (IsEventActive())
     {
         File.Delete($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Data{Path.DirectorySeparatorChar}Event.json");
         File.Delete($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Data{Path.DirectorySeparatorChar}Registration.json");
         Directory.Delete($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}Setups");
         await ReplyAsync("", embed : EmbedTool.ChannelMessage("The Event has concluded."));
     }
 }
Exemplo n.º 7
0
        public async Task ReplyGuides()
        {
            dynamic BotConfiguration = JsonConvert.DeserializeObject(System.IO.File.ReadAllText($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}config.json"));
            String  drivelink        = BotConfiguration.DriveLink;
            await Context.User.SendMessageAsync("", false, EmbedTool.GuidesEmbed(drivelink));

            if (!Context.IsPrivate)
            {
                await ReplyAsync($"You have e-mail, {Context.User.Username}");
            }
        }
Exemplo n.º 8
0
 public async Task UpdateEventDateAsync([Remainder] string Date)
 {
     if (IsEventActive() && IsEventOrganizer(Context.User as IGuildUser, Context.Guild))
     {
         UpdateEventData(EventFields.StartDate, Date);
         await ReplyAsync("The Event date has been upated.");
     }
     else
     {
         await ReplyAsync("", embed : EmbedTool.CommandError("There is not an active event or you are not authorized to make changes to the event."));
     }
 }
Exemplo n.º 9
0
 public async Task UpdateEventTitleAsync([Remainder] string EventTitle)
 {
     if (IsEventActive() && IsEventOrganizer(Context.User as IGuildUser, Context.Guild))
     {//The event is active and the caller is an authorized user.
         UpdateEventData(EventFields.Title, EventTitle);
         await ReplyAsync($"The event title has been updated to {EventTitle}.");
     }
     else
     {
         await ReplyAsync("", embed : EmbedTool.CommandError("There is not an active event or you are not authorized to make changes to the event."));
     }
 }
Exemplo n.º 10
0
 [RequireUserPermission(GuildPermission.ViewAuditLog)] //Admin-only.
 public async Task AdminQuoteRemove([Remainder] int QuoteID)
 {
     ResyncQuotesList();
     for (int i = 0; i < MasterQuoteList.Count; i++)
     {
         if (MasterQuoteList[i].QuoteID == QuoteID)
         {                                //The Quote ID is located.
             MasterQuoteList.RemoveAt(i); //Remove the quote from the library.
             WriteQuoteList();            //Write the list to the JSON.
             await ReplyAsync("", embed : EmbedTool.ChannelMessage($"Quote {QuoteID.ToString()} removed from the library by a moderator."));
         }
     }
 }
Exemplo n.º 11
0
        public async Task EventListAsync()
        {
            //Builds a list of participants to send to the organizer.
            if (IsEventOrganizer(Context.User as IGuildUser, Context.Guild))
            {
                SyncParticipantList(); //Ensure the List is up to date.
                string Result = $"**{GetActiveEvent().EventName} Participant List**\n\n";

                for (int i = 0; i < ParticipantList.Count; i++)
                {
                    Result += $"{ParticipantList[i].NetbattlerName} ({ParticipantList[i].UserID}) - Setup Submitted: {ParticipantList[i].SetupSubmitted.ToString()}\n";
                }
                await Context.User.SendMessageAsync(Result);
            }
            else
            {
                await ReplyAsync("", embed : EmbedTool.CommandError("You are not authorized to obtain the participant list."));
            }
        }
Exemplo n.º 12
0
 public async Task CloseRegistrationAsync()
 {
     if (IsEventActive() && IsEventOrganizer(Context.User as IGuildUser, Context.Guild))
     {//Is the event active?
         Event activeEvent = GetActiveEvent();
         if (activeEvent.RegistrationOpen == true)
         {//Is registration closed?
             UpdateEventData(EventFields.RegistrationOpen, "false");
             await ReplyAsync("Registration is now closed.");
         }
         else //No changes necessary.
         {
             await ReplyAsync("", embed : EmbedTool.CommandError("The event's registration is already closed."));
         }
     }
     else
     {
         await ReplyAsync("", embed : EmbedTool.CommandError("There is not an active event or you are not authorized to make changes to the event."));
     }
 }
Exemplo n.º 13
0
            public async Task LookupDefaultAsync([Remainder] string rndr)
            {//!lookup <chipname> -
                Chip locatedChip;

                if (rndr.Length == 1)
                {
                    await ReplyAsync(ObtainCodeResults(rndr));
                }
                else if (TryFindChipByName(rndr, out locatedChip))
                {
                    await ReplyAsync("", embed : EmbedTool.ChipEmbed(locatedChip));
                }
                else if (TryFindChipByAlias(rndr, out locatedChip))
                {
                    await ReplyAsync("", embed : EmbedTool.ChipEmbed(locatedChip));
                }
                else
                {
                    await ReplyAsync(ObtainSuggestions(rndr));
                }
            }
Exemplo n.º 14
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."));
     }
 }
Exemplo n.º 15
0
        public async Task UpdateNetbattlerNameAsync([Remainder] string NewName)
        {
            SyncParticipantList();
            var caller = Context.User as IGuildUser;

            if (IsEventActive())
            {
                if (IsParticipantRegistered(caller.Id))
                {
                    GetParticipant(caller).NetbattlerName = NewName.Replace('@', ' ');
                    WriteParticipantList();
                    await ReplyAsync("Updated your Netbattler Name successfully.");
                }
                else
                {
                    await ReplyAsync("", embed : EmbedTool.CommandError($"You are not registered for {GetActiveEvent().EventName}."));
                }
            }
            else
            {
                await ReplyAsync("", embed : EmbedTool.CommandError("There currently isn't an active event."));
            }
        }
Exemplo n.º 16
0
        public async Task QuoteSpecificAsync([Remainder] uint quoteID)
        {
            //1. Update the local list for Quotes.
            ResyncQuotesList();

            //2. Locate the quote.
            Quote selectedQuote = null;

            try
            {
                selectedQuote = MasterQuoteList.Find(x => x.QuoteID == quoteID);
            }
            catch (Exception ex)
            {
                await ReplyAsync(ex.Message);

                throw;
            }


            //3. Respond with said quote.
            if (selectedQuote != null)
            {
                if (selectedQuote.QuoteAuthorNickname == null)
                {
                    await ReplyAsync($"Quote { selectedQuote.QuoteID.ToString()} by Library Export: {selectedQuote.QuoteContents}");
                }
                else
                {
                    await ReplyAsync($"Quote { selectedQuote.QuoteID.ToString()} by {selectedQuote.QuoteAuthorNickname}: {selectedQuote.QuoteContents}");
                }
            }
            else
            {
                await ReplyAsync("", embed : EmbedTool.ChannelMessage("The quote you specified is not in the library."));
            }
        }
Exemplo n.º 17
0
        public async Task RemoveQuoteAsync([Remainder] int quoteid)
        {
            //1. Pull down the deserialized list.
            ResyncQuotesList();

            //2. Locate the quote in question for verification by enumeration.
            bool QuoteExists = false; //False by default

            for (int i = 0; i < MasterQuoteList.Count; i++)
            {
                if (MasterQuoteList[i].QuoteID == quoteid)
                {//The Quote ID is located.
                    QuoteExists = true;
                    if (MasterQuoteList[i].QuoteAuthor == Context.User.Id)
                    {                                //The requestor is the author of the quote.
                        MasterQuoteList.RemoveAt(i); //Remove the quote from the library.
                        WriteQuoteList();            //Write the list to the JSON.
                        QuoteExists = true;          //Quote was found and deleted.
                    }
                    else                             //The requestor is not the author of the quote.
                    {
                        await ReplyAsync("", embed : EmbedTool.ChannelMessage("You are not the author of the quote."));
                    }
                }
            }

            //3. Respond based on what was or wasn't found.
            if (QuoteExists == false)
            {
                await ReplyAsync("", embed : EmbedTool.ChannelMessage("The quote does not exist in the library."));
            }
            else
            {
                await ReplyAsync("", embed : EmbedTool.ChannelMessage($"Quote {quoteid.ToString()} removed from the library."));
            }
        }
Exemplo n.º 18
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.");
            }
        }
Exemplo n.º 19
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."));
     }
 }
Exemplo n.º 20
0
 [Command("join")] //!help event join
 public async Task EventJoinHelp()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!event join <Netbattler Name>", "Joins the event with the netbattler name specified if the event is accepting registrations. Example: !event join MidniteW"));
 }
Exemplo n.º 21
0
 public async Task EventDropHelp()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!event drop", "Removes you from the current active event. This can be done even if the event is not accepting registration."));
 }
Exemplo n.º 22
0
 public async Task EventHelp()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!event <join/drop/update/admin/create>", "Event commands.  Only usable when there is an active event."));
 }
Exemplo n.º 23
0
 public async Task EventCreateHelp()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!event create <Event Name>", "Creates an event with the specified name."));
 }
Exemplo n.º 24
0
 public async Task QuoteAdminHelpAsync()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!quote admin <Edit/Remove> <Quote ID>", "Moderator-only command. Removes or edits a quote regardless of the quote author."));
 }
Exemplo n.º 25
0
 public async Task QuoteLibraryHelpAsync()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!quote library", "Replys with a HTML file containing the quotes library."));
 }
Exemplo n.º 26
0
 public async Task QuoteRemoveHelpAsync()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!quote remove <Quote ID>", "If you are the author of a quote, remove it from the library."));
 }
Exemplo n.º 27
0
 public async Task QuoteAddHelpAsync()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!quote add <quote contents>", "Adds a quote to the library. For disclosure, this records your Discord ID as well as the date/time the quote was added"));
 }
Exemplo n.º 28
0
 public async Task QuoteHelpAsync()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!quote", "Calls a random quote from the library.\n**Additional Commands:** *!quote add <text>, !quote remove <quote number>, !quote library*"));
 }
Exemplo n.º 29
0
 public async Task UnavHelpAsync()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!unav, !unavailable", "Removes the Available to Battle role from you."));
 }
Exemplo n.º 30
0
 public async Task DeckmasterHelp()
 {
     await ReplyAsync("", false, EmbedTool.HelpMessage("!deckmaster", "Adds a pingable role so active players of the MegaMan TCG can matchmake. Call the command again to remove the role."));
 }