even better pk handling
This commit is contained in:
parent
1199521e40
commit
8acf38fd5a
1 changed files with 16 additions and 26 deletions
42
src/main.rs
42
src/main.rs
|
@ -55,13 +55,26 @@ impl EventHandler for Handler {
|
|||
let mut msgs = channel
|
||||
.messages(&ctx, |messages| messages.after(after))
|
||||
.await
|
||||
.unwrap();
|
||||
.unwrap()
|
||||
.into_iter()
|
||||
.filter(|message| message.id <= msg.id)
|
||||
.rev()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
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
|
||||
.clone()
|
||||
|
@ -220,27 +233,4 @@ async fn main() {
|
|||
if let Err(why) = client.start().await {
|
||||
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);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue