Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.

Commit 198fbb9

Browse files
committed
dep update. Changed how the queue works, slowly working on a rewrite.
1 parent fee66a2 commit 198fbb9

File tree

6 files changed

+55
-92
lines changed

6 files changed

+55
-92
lines changed

SysBot.Pokemon.Discord/Commands/General/TradeModule.cs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public async Task Trade([Summary("PokemonText","put your copied showdown text he
3030
await DeferAsync();
3131
if (ShowdownSet != "")
3232
{
33-
if (LetsGoTrades.discordID.Contains(Context.User.Id))
33+
if (LetsGoTrades.TheQ.Any(z=>z.discordcontext.User == Context.User))
3434
{
3535
await FollowupAsync("you are already in queue",ephemeral:true);
3636
return;
@@ -73,12 +73,9 @@ public async Task Trade([Summary("PokemonText","put your copied showdown text he
7373
pkm.ResetPartyStats();
7474
try { await Context.User.SendMessageAsync("I've added you to the queue! I'll message you here when your trade is starting."); }
7575
catch { await FollowupAsync("Please enable direct messages from server members to be queued",ephemeral:true); return; };
76-
LetsGoTrades.discordname.Enqueue(Context.User);
77-
LetsGoTrades.discordID.Enqueue(Context.User.Id);
78-
LetsGoTrades.Channel.Enqueue(Context.Channel);
79-
LetsGoTrades.tradepkm.Enqueue(pkm);
80-
LetsGoTrades.Commandtypequ.Enqueue(LetsGoTrades.commandtype.trade);
81-
await FollowupAsync($"{Context.User.Username} - Added to the LGPE Link Trade Queue. Current Position: {LetsGoTrades.discordID.Count}. Receiving: {(pkm.IsShiny ? "Shiny" : "")} {(Species)pkm.Species}{(pkm.Form == 0 ? "" : "-" + ShowdownParsing.GetStringFromForm(pkm.Form, GameInfo.Strings, pkm.Species, pkm.Context))}");
76+
var queueitem = new TheQobject { commandtype = LetsGoTrades.commandtype.trade, discordcontext = Context, tradepkm = (PB7)pkm };
77+
LetsGoTrades.TheQ.Enqueue(queueitem);
78+
await FollowupAsync($"{Context.User.Username} - Added to the LGPE Link Trade Queue. Current Position: {LetsGoTrades.TheQ.Count}. Receiving: {(pkm.IsShiny ? "Shiny" : "")} {(Species)pkm.Species}{(pkm.Form == 0 ? "" : "-" + ShowdownParsing.GetStringFromForm(pkm.Form, GameInfo.Strings, pkm.Species, pkm.Context))}");
8279

8380
}
8481
catch
@@ -89,7 +86,7 @@ public async Task Trade([Summary("PokemonText","put your copied showdown text he
8986
}
9087
if(Pb7 != default)
9188
{
92-
if (LetsGoTrades.discordID.Contains(Context.User.Id))
89+
if (LetsGoTrades.TheQ.Any(z => z.discordcontext.User == Context.User))
9390
{
9491
await FollowupAsync("you are already in queue",ephemeral:true);
9592
return;
@@ -128,13 +125,10 @@ public async Task Trade([Summary("PokemonText","put your copied showdown text he
128125
}
129126
try { await Context.User.SendMessageAsync("I've added you to the queue! I'll message you here when your trade is starting."); }
130127
catch { await FollowupAsync("Please enable direct messages from server members to be queued",ephemeral:true); return; };
131-
LetsGoTrades.discordname.Enqueue(Context.User);
132-
LetsGoTrades.discordID.Enqueue(Context.User.Id);
133-
LetsGoTrades.Channel.Enqueue(Context.Channel);
134-
LetsGoTrades.tradepkm.Enqueue(pkm);
135-
LetsGoTrades.Commandtypequ.Enqueue(LetsGoTrades.commandtype.trade);
136-
137-
await FollowupAsync($"{Context.User.Username} - Added to the LGPE Link Trade Queue. Current Position: {LetsGoTrades.discordID.Count}. Receiving: {(pkm.IsShiny ? "Shiny" : "")} {(Species)pkm.Species}{(pkm.Form == 0 ? "" : "-" + ShowdownParsing.GetStringFromForm(pkm.Form, GameInfo.Strings, pkm.Species, pkm.Context))}");
128+
var queueitem = new TheQobject { commandtype = LetsGoTrades.commandtype.trade, discordcontext = Context, tradepkm = (PB7)pkm };
129+
LetsGoTrades.TheQ.Enqueue(queueitem);
130+
131+
await FollowupAsync($"{Context.User.Username} - Added to the LGPE Link Trade Queue. Current Position: {LetsGoTrades.TheQ.Count}. Receiving: {(pkm.IsShiny ? "Shiny" : "")} {(Species)pkm.Species}{(pkm.Form == 0 ? "" : "-" + ShowdownParsing.GetStringFromForm(pkm.Form, GameInfo.Strings, pkm.Species, pkm.Context))}");
138132

139133

140134
}
@@ -159,21 +153,18 @@ public async Task dump()
159153
await DeferAsync();
160154
try { await Context.User.SendMessageAsync("I've added you to the queue! I'll message you here when your trade is starting."); }
161155
catch { await FollowupAsync("Please enable direct messages from server members to be queued", ephemeral: true); return; };
162-
LetsGoTrades.discordname.Enqueue(Context.User);
163-
LetsGoTrades.discordID.Enqueue(Context.User.Id);
164-
LetsGoTrades.Channel.Enqueue(Context.Channel);
165-
LetsGoTrades.tradepkm.Enqueue(null);
166-
LetsGoTrades.Commandtypequ.Enqueue(LetsGoTrades.commandtype.dump);
156+
var queueitem = new TheQobject { commandtype = LetsGoTrades.commandtype.trade, discordcontext = Context, tradepkm = null };
157+
LetsGoTrades.TheQ.Enqueue(queueitem);
167158

168-
await FollowupAsync($"{Context.User.Username} - Added to the LGPE Dump Queue. Current Position: {LetsGoTrades.discordID.Count}.");
159+
await FollowupAsync($"{Context.User.Username} - Added to the LGPE Dump Queue. Current Position: {LetsGoTrades.TheQ}.");
169160

170161
}
171162
[SlashCommand("queue","shows the queue")]
172163

173164
public async Task queue()
174165
{
175166
await DeferAsync();
176-
Object[] arr = LetsGoTrades.discordname.ToArray();
167+
var arr = LetsGoTrades.TheQ.ToArray();
177168
var sb = new System.Text.StringBuilder();
178169
var embed = new EmbedBuilder();
179170
if (arr.Length == 0)
@@ -184,7 +175,7 @@ public async Task queue()
184175
foreach (object i in arr)
185176
{
186177

187-
sb.AppendLine((r + 1).ToString() + ". " + arr[r].ToString());
178+
sb.AppendLine((r + 1).ToString() + ". " + arr[r].discordcontext.User.Username);
188179
r++;
189180
}
190181
embed.AddField(x =>

SysBot.Pokemon.Discord/Commands/General/WTPSB.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,11 @@ public static async Task WhoseThatPokemon()
9696
pk.SetMoves(sugmov);
9797
int natue = random.Next(24);
9898
pk.Nature = natue;
99-
10099

101-
LetsGoTrades.discordname.Enqueue(con.User);
102-
LetsGoTrades.discordID.Enqueue(con.User.Id);
103-
LetsGoTrades.Channel.Enqueue(con.Channel);
104-
LetsGoTrades.tradepkm.Enqueue(pk);
105-
LetsGoTrades.Commandtypequ.Enqueue(LetsGoTrades.commandtype.trade);
106-
await con.Interaction.ModifyOriginalResponseAsync(x => x.Content = $"{con.User.Username} - Added to the LGPE Link Trade Queue. Current Position: {LetsGoTrades.discordID.Count}. Receiving: {(pk.IsShiny ? "Shiny" : "")} {(Species)pk.Species}{(pk.Form == 0 ? "" : "-" + ShowdownParsing.GetStringFromForm(pk.Form, GameInfo.Strings, pk.Species, pk.Context))}");
100+
101+
var queueitem = new TheQobject { commandtype = LetsGoTrades.commandtype.trade, discordcontext = con, tradepkm = (PB7)pk };
102+
LetsGoTrades.TheQ.Enqueue(queueitem);
103+
await con.Interaction.ModifyOriginalResponseAsync(x => x.Content = $"{con.User.Username} - Added to the LGPE Link Trade Queue. Current Position: {LetsGoTrades.TheQ.Count}. Receiving: {(pk.IsShiny ? "Shiny" : "")} {(Species)pk.Species}{(pk.Form == 0 ? "" : "-" + ShowdownParsing.GetStringFromForm(pk.Form, GameInfo.Strings, pk.Species, pk.Context))}");
107104
}
108105
usr = null;
109106
guess = "";
@@ -120,7 +117,7 @@ public static async Task WhoseThatPokemon()
120117
public async Task WTPguess([Summary("pokemon","put the pokemon name here")]string userguess)
121118
{
122119
await DeferAsync();
123-
if (LetsGoTrades.discordID.Contains(Context.User.Id))
120+
if (LetsGoTrades.TheQ.Any(z => z.discordcontext.User == Context.User))
124121
{
125122
await FollowupAsync("please wait until you are out of queue to guess to avoid double queueing.");
126123
return;

0 commit comments

Comments
 (0)