So, as I see in documentation , i can call tc.send("foo");
but it's not working in my code:
client.on('ready', () => {
var tc = client.guilds.get('547536528533094401').channels.get('547537490651774987')
console.log(tc.name) // Squad 1
tc.send('foo') // tc.send us not a function
})
In the console, I'm getting the right channel name (Squad 1), but I'm also getting
TypeError: tc.send is not a function
I guess It is not a casting problem as
client.guilds.get('547536528533094401').channels.get('547537490651774987').send('foo')
doesn't work either.
When i do console.log(Object.getOwnPropertyNames(client.guilds.get('577240924162359312').channels.get('577240924162359321')))
i get:
[
'client',
'type',
'deleted',
'id',
'name',
'position',
'parentID',
'permissionOverwrites',
'bitrate',
'userLimit',
'guild',
'members'
]
I'm useing discord.js@11.5.0
So, It was a foolish mistake. I was copying the id of the voice general channel ( General
) instead of the text general channel ( #general
).
So, when trying to access the TextChannel.send()
method it was not finding any because it was a VoiceChannel
. (Both extending GuildChannel
, which in turn extends Channel
).
I am still wondering why tc.type returned Object instead of GuildChannel as I am not very into javascript's weak typing, but at least now it works.
Special thanks to @slothiful .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.