adding counting for ping
This commit is contained in:
@@ -79,9 +79,31 @@ client.on('interactionCreate', async (interaction) => {
|
||||
client.on(Events.MessageCreate, async (message) => {
|
||||
if (message.channelId == 1288954051261632532 && message.content.toLowerCase() == "ping") {
|
||||
message.reply("Pong!");
|
||||
var currentCount = parseInt(message.channel.topic.replace(" Pings | Schreibt \"Ping\" & der Bot schreibt \"Pong\"", ""));
|
||||
currentCount++;
|
||||
message.channel.setTopic(currentCount + " Pings | Schreibt \"Ping\" & der Bot schreibt \"Pong\"");
|
||||
//var currentCount = parseInt(message.channel.topic.replace(" Pings | Schreibt \"Ping\" & der Bot schreibt \"Pong\"", ""));
|
||||
//currentCount++;
|
||||
//message.channel.setTopic(currentCount + " Pings | Schreibt \"Ping\" & der Bot schreibt \"Pong\"");
|
||||
|
||||
let messageCount = 0;
|
||||
let lastMessageId;
|
||||
|
||||
while (true) {
|
||||
// Fetch messages in batches of 100
|
||||
const options = { limit: 100 };
|
||||
if (lastMessageId) {
|
||||
options.before = lastMessageId;
|
||||
}
|
||||
|
||||
const messages = await channel.messages.fetch(options);
|
||||
if (messages.size === 0) break;
|
||||
|
||||
// Filter messages by the user ID
|
||||
messageCount += messages.filter(msg => msg.author.id === 1288554103873736785).size;
|
||||
|
||||
// Update the last message ID for pagination
|
||||
lastMessageId = messages.last().id;
|
||||
}
|
||||
|
||||
message.channel.setTopic(messageCount + " Pings | Schreibt \"Ping\" & der Bot schreibt \"Pong\"");
|
||||
}
|
||||
if (message.channelId == 1288954051261632532 && message.content.toLowerCase() != "ping" && message.author.id != 241530175353782273 && message.author.bot == false) {
|
||||
message.delete();
|
||||
|
||||
Reference in New Issue
Block a user