Beispiel #1
0
        public async Task TradeAsync([Summary("Showdown Set")][Remainder] string content)
        {
            const int gen = 8;

            content = ReusableActions.StripCodeBlock(content);
            var set = new ShowdownSet(content);
            var sav = AutoLegalityExtensions.GetTrainerInfo(gen);

            var pkm  = sav.GetLegal(set, out var result);
            var la   = new LegalityAnalysis(pkm);
            var spec = GameInfo.Strings.Species[set.Species];
            var msg  = la.Valid
                ? $"Here's your ({result}) legalized PKM for {spec} ({la.EncounterOriginal.Name})!"
                : $"Oops! I wasn't able to create something from that. Here's my best attempt for that {spec}!";

            if (!la.Valid || !(pkm is PK8 pk8))
            {
                await ReplyAsync(msg).ConfigureAwait(false);

                return;
            }

            pk8.ResetPartyStats();

            var code = Info.GetRandomTradeCode();
            var sudo = Context.User.GetIsSudo();

            await AddTradeToQueueAsync(code, Context.User.Username, pk8, sudo).ConfigureAwait(false);
        }
Beispiel #2
0
        public SysCord(PokeTradeHub <PK8> hub)
        {
            Hub = hub;
            SysCordInstance.Self = this; // hack
            AutoLegalityExtensions.EnsureInitialized(Hub.Config);

            _client = new DiscordSocketClient(new DiscordSocketConfig
            {
                // How much logging do you want to see?
                LogLevel = LogSeverity.Info,

                // If you or another service needs to do anything with messages
                // (eg. checking Reactions, checking the content of edited/deleted messages),
                // you must set the MessageCacheSize. You may adjust the number as needed.
                //MessageCacheSize = 50,
            });

            _commands = new CommandService(new CommandServiceConfig
            {
                // Again, log level:
                LogLevel = LogSeverity.Info,

                // There's a few more properties you can set,
                // for example, case-insensitive commands.
                CaseSensitiveCommands = false,
            });

            // Subscribe the logging handler to both the client and the CommandService.
            _client.Log   += Log;
            _commands.Log += Log;

            // Setup your DI container.
            _services = ConfigureServices();
        }
Beispiel #3
0
 public static async Task ReplyWithLegalizedSetAsync(this ISocketMessageChannel channel, string content)
 {
     content = ReusableActions.StripCodeBlock(content);
     var set = new ShowdownSet(content);
     var sav = AutoLegalityExtensions.GetTrainerInfo(set.Format);
     await channel.ReplyWithLegalizedSetAsync(sav, set).ConfigureAwait(false);
 }
        public async Task TradeAsync([Summary("Showdown Set")][Remainder] string content)
        {
            var cfg     = Info.Hub.Config;
            var sudo    = Context.GetIsSudo(cfg);
            var allowed = sudo || (Context.GetHasRole(cfg.DiscordRoleCanTrade) && Info.CanQueue);

            if (!sudo && !Info.CanQueue)
            {
                await ReplyAsync("Sorry, I am not currently accepting queue requests!").ConfigureAwait(false);

                return;
            }

            if (!allowed)
            {
                await ReplyAsync("Sorry, you are not permitted to use this command!").ConfigureAwait(false);

                return;
            }

            const int gen = 8;

            content = ReusableActions.StripCodeBlock(content);
            var set = new ShowdownSet(content);
            var sav = AutoLegalityExtensions.GetTrainerInfo(gen);

            var pkm  = sav.GetLegal(set, out var result);
            var la   = new LegalityAnalysis(pkm);
            var spec = GameInfo.Strings.Species[set.Species];
            var msg  = la.Valid
                ? $"Here's your ({result}) legalized PKM for {spec} ({la.EncounterOriginal.Name})!"
                : $"Oops! I wasn't able to create something from that. Here's my best attempt for that {spec}!";

            if (!la.Valid || !(pkm is PK8 pk8))
            {
                await ReplyAsync(msg).ConfigureAwait(false);

                return;
            }

            pk8.ResetPartyStats();

            var code = Info.GetRandomTradeCode();

            await AddTradeToQueueAsync(code, Context.User.Username, pk8, sudo).ConfigureAwait(false);
        }