#How to get all messages in channel?
1 messages · Page 1 of 1 (latest)
I'm trying to do the same thing at the moment, I've made a bit of headway
This is what I have so far
public static async Task Scrape(SocketSlashCommand cmd) {
SocketTextChannel channel = (SocketTextChannel)cmd.Data.Options.First().Value;
Console.WriteLine($"Scraping {channel}");
IMessage[] messages = (await channel.GetMessagesAsync()
.FlattenAsync()).ToArray();
for (int i = 0; i < messages.Length; i++) {
Console.WriteLine(messages[i]);
}
await cmd.RespondAsync($"Scraped {channel}", ephemeral: true);
}
The only caveats are 1. I have to tell it how many messages get (or scrape) and 2. I don't have any way of knowing if that command option corresponds to a VC or an actual text channel
Which means that cast is a bit unsafe
you can check for channel type afaik
yeah there's a type for text channels and vcs, i just haven't gotten around to it lol
I mean VCs are pretty much text channels now, so it doesn't really matter if all you want is to get their chat messages
true