Question about "repositories" #1077
-
How can I iterate all elements of a repository? I want to archive (save to local files) all the messages in a channel. To do this, I must iterate over all messages in a channel. ChatGTP suggested this code: $channel = $discord->getChannel($channel_id);
$limit = 100;
$before = null;
do {
$messages = $channel->messages->all([
'limit' => $limit,
'before' => $before,
]);
foreach ($messages as $message) {
echo $message->content . PHP_EOL;
$before = $message->id;
}
} while (count($messages) == $limit); But alas, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
getMessageHistory() with a promise should work |
Beta Was this translation helpful? Give feedback.
getMessageHistory() with a promise should work
(You must have the
MESSAGE_CONTENT
intent enabled)