How to get the creator of a channel on event channelCreate in discord.js

断了今生、忘了曾经 提交于 2021-01-29 19:55:40

问题


Would it be possible to find the creator of a channel when the channelCreate event triggers? I've tried looking at the documentation of channels & channelCreate and to log the channel object to my console but there doesn't seem to be a parameter that clearly states "This ID created the channel". I know it has to be somewhere since Discord uses it in the audit logs.


回答1:


You can try listening to the channelCreate event and then fetch the GuildAuditLogs with Guild.fetchAuditLogs(). Then you can look for the most recent AuditLogEntry who's AuditLogAction is CHANNEL_CREATE. From that you can get the .executor to see who triggered the event




回答2:


If you try to get the channelCreator of an command, ex:

!channelcreate

you just need to get the author of the message.

else idk



来源:https://stackoverflow.com/questions/64502363/how-to-get-the-creator-of-a-channel-on-event-channelcreate-in-discord-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!