![](/img/trans.png)
[英]How can I not get an error if the bot doesn't have the permission to send message?
[英]How to make bot send Direct Message To Someone that the bot don't have it in mutal servers and have his id
我想知道我可以得到用戶的代碼,機器人不在他的共同服務器中,我有他的id我希望機器人向他發送直接消息代碼是什么?
在學習中,我沒有嘗試過任何我是菜鳥的人
使用Client.fetchUser()
方法。
例1:
let ID = '123456789012345678';
client.fetchUser(ID)
.then(user => user.send('hello'))
.catch(console.error);
示例2 (必須在異步函數內) :
let ID = '123456789012345678';
try {
let user = await client.fetchUser(ID);
await user.send('hello');
} catch(err) {
console.error(err);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.