public static async Task RepostPKMAsShowdownAsync(this ISocketMessageChannel channel, IAttachment att) { if (!PKX.IsPKM(att.Size)) { return; } var result = await NetUtil.DownloadPKMAsync(att).ConfigureAwait(false); if (!result.Success) { return; } var pkm = result.Data !; await channel.SendPKMAsShowdownSetAsync(pkm).ConfigureAwait(false); }
public async Task TradeAsync([Summary("Trade Code")] int code, [Remainder][Summary("Trainer Name to trade to.")] string trainerName) { 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; } if ((uint)code > MaxTradeCode) { await ReplyAsync("Trade code should be 0000-9999!").ConfigureAwait(false); return; } var attachment = Context.Message.Attachments.FirstOrDefault(); if (attachment == default) { await ReplyAsync("No attachment provided!").ConfigureAwait(false); return; } var att = await NetUtil.DownloadPKMAsync(attachment).ConfigureAwait(false); if (!att.Success || !(att.Data is PK8 pk8)) { await ReplyAsync("No PK8 attachment provided!").ConfigureAwait(false); return; } await AddTradeToQueueAsync(code, trainerName, pk8, sudo).ConfigureAwait(false); }
private async Task TradeAsyncAttach(int code, RequestSignificance sig, SocketUser usr) { var attachment = Context.Message.Attachments.FirstOrDefault(); if (attachment == default) { await ReplyAsync("No attachment provided!").ConfigureAwait(false); return; } var att = await NetUtil.DownloadPKMAsync(attachment).ConfigureAwait(false); if (!att.Success || !(att.Data is PK8 pk8)) { await ReplyAsync("No PK8 attachment provided!").ConfigureAwait(false); return; } await AddTradeToQueueAsync(code, usr.Username, pk8, sig, usr).ConfigureAwait(false); }
public async Task TradeAsyncAttach([Summary("Trade Code")] int code) { var sudo = Context.User.GetIsSudo(); var attachment = Context.Message.Attachments.FirstOrDefault(); if (attachment == default) { await ReplyAsync("No attachment provided!").ConfigureAwait(false); return; } var att = await NetUtil.DownloadPKMAsync(attachment).ConfigureAwait(false); if (!att.Success || !(att.Data is PK8 pk8)) { await ReplyAsync("No PK8 attachment provided!").ConfigureAwait(false); return; } await AddTradeToQueueAsync(code, Context.User.Username, pk8, sudo).ConfigureAwait(false); }
private async Task TradeAsyncAttach(int code, RequestSignificance sig, SocketUser usr) { var attachment = Context.Message.Attachments.FirstOrDefault(); if (attachment == default) { await ReplyAsync("No attachment provided!").ConfigureAwait(false); return; } var att = await NetUtil.DownloadPKMAsync(attachment).ConfigureAwait(false); var pk8 = GetRequest(att); if (pk8 == null) { await ReplyAsync("Attachment provided is not compatible with this module!").ConfigureAwait(false); return; } await AddTradeToQueueAsync(code, usr.Username, pk8, sig, usr).ConfigureAwait(false); }