even better pk handling

This commit is contained in:
Skye 2023-03-18 11:15:39 +09:00
parent 1199521e40
commit 8acf38fd5a
Signed by: me
GPG key ID: 0104BC05F41B77B8

View file

@ -55,13 +55,26 @@ impl EventHandler for Handler {
let mut msgs = channel let mut msgs = channel
.messages(&ctx, |messages| messages.after(after)) .messages(&ctx, |messages| messages.after(after))
.await .await
.unwrap(); .unwrap()
.into_iter()
.filter(|message| message.id <= msg.id)
.rev()
.collect::<Vec<_>>();
tokio::time::sleep(Duration::from_millis(250)).await; tokio::time::sleep(Duration::from_millis(250)).await;
let current_id = ctx.http.get_current_user().await.unwrap().id; msgs.append(
&mut channel
.messages(&ctx, |messages| messages.after(msg.id))
.await
.unwrap()
.into_iter()
.filter(|message| message.webhook_id.is_some())
.rev()
.collect::<Vec<_>>(),
);
msgs.reverse(); let current_id = ctx.http.get_current_user().await.unwrap().id;
for pk_msg in msgs for pk_msg in msgs
.clone() .clone()
@ -220,27 +233,4 @@ async fn main() {
if let Err(why) = client.start().await { if let Err(why) = client.start().await {
println!("Client error: {:?}", why); println!("Client error: {:?}", why);
} }
// let messages = vec![openai::Message {
// role: openai::Role::User,
// content: String::from("Say this is a test!"),
// }];
// let chat_completion = openai::ChatCompletion {
// model: String::from("gpt-3.5-turbo"),
// messages,
// ..Default::default()
// };
// match client.create_chat_completion(chat_completion).await {
// Ok(response) => {
// println!(
// "Chat completion response: {:?}",
// response.choices.first().unwrap().message.content
// );
// }
// Err(error) => {
// eprintln!("Error: {}", error);
// }
// }
} }