fix async recursion

This commit is contained in:
oliver 2024-07-23 17:39:16 -06:00
parent 87267fb708
commit f433e0e4af

View File

@ -144,7 +144,7 @@ impl Server {
async fn walk_channels(all: &mut Vec<Channel>, cache: impl CacheHttp + Clone, settings: GetMessages) {
for channel in all {
// get the messages
match channel.this.messages(cache.clone(), settings).await {
match Box::pin(channel.this.messages(cache.clone(), settings)).await {
Ok(mesgs) => {
// store messages in our server object
channel.messages = mesgs;
@ -152,10 +152,12 @@ impl Server {
eprintln!("{} was empty - (Or incorrect permissions)", channel.this.name);
}
},
Err(_) => todo!(),
Err(e) => {
eprintln!("{}", e);
},
}
// Clone *should* be cheap - it's Arc under the hood
walk_channels(&mut channel.children, cache.clone(), settings).await;
Box::pin(walk_channels(&mut channel.children, cache.clone(), settings)).await;
}
}
}
@ -200,7 +202,6 @@ async fn index(map: HashMap<ChannelId, GuildChannel>) -> Server {
server
}
// NOTE!!! Make sure these names in quotes are lowercase!
#[poise::command(slash_command, rename = "index", guild_only)]
pub async fn index_cmd(ctx: Context<'_>) -> Result<(), Error> {