Bir kişi listesine özel mesaj gönder
Aug 16 2020
Botum, kabul edilen kişilerin listesine özel bir mesaj gönderecek. .json
Dosyadaki herkese mesaj gönderen bir komut yazmak istiyorum . Bir döngü ile denedim ama işe yaramadı.
Bunun json dosyası olduğunu düşünüyorum:
{
"1": "Name#0001",
"2": "Guy#0001",
"3": "Person#0001"
}
Bu benim index.js veya main.js:
var ytLinks = JSON.parse(fs.readFileSync('./ytvids.json', 'utf8'));
if (args[1] === 'send') {
const userValues = Object.values(acceptedUsers);
var userList = '';
var i;
for (i = 0; i < userValues.length; i++) {
userList += userValues[i];
}
}
Yanıtlar
4 Lioness100 Aug 16 2020 at 20:08
something.json:
{
"1": "Name#0001",
"2": "Guy#0001",
"3": "Person#0001"
}
index.js:
const obj = require('./something.json') // require object from file
// execute function on each entry (user tag)
Object.values(obj).forEach((tag) => {
// find each user via tag and send DM
client.users.cache.find(user => user.tag === tag).send('This is a DM')
});
- Object.values() yöntem
- Array.prototype.forEach() yöntem
- Array.prototype.find() yöntem
Dikkatli olun, çok fazla toplu mesaj gönderme Discord'un Hizmet Koşullarında sorunlara yol açabilir
Nicole Kidman, Michael Keaton ve Val Kilmer'in Batman Olarak Paylaştığı Bu 1 Çekici Özelliğe Bayıldı
Gene Simmons, KISS Çizgi Romanlarının Potansiyel Olarak "İnsanlığı Yeniden Yaratabileceğini" Söyledi
Kevin Jonas'ın Kızı Alena, Doğum Günü Fotoğrafında Büyümüş Görünüyor: '9 Yaşında Gerçek Hissetmiyor'