#TS Issue
1 messages · Page 1 of 1 (latest)
here lemme make this more clear:
const logsChannel = await message.guild.channels.create("watchdog-logs", {
permissionOverwrites: [
{
id: message.guild.roles.everyone,
deny: ["VIEW_CHANNEL", "SEND_MESSAGES", "MANAGE_MESSAGES"],
}
],
reason: "Setup. Creating a logs channel."
//then later on:
message.channel.send(`Setup has completed successfully in ${console.timeLog}. Watchdog will log to ${logsChannel.toString}. Please now **read the documentation and go over the settings.**`).
this would give the error Property 'toString' does not exist on type 'void | TextChannel'. Property 'toString' does not exist on type 'void'.
I kinda feel like somewhere in the discord.js code it should be TextChannel | void not the opposite
wait yea
Returns: Promise <GuildChannel>
also why is it typed as a text channel?
¯_(ツ)_/¯
yes, that is what it should return
hover over .create
lemme try that
thats a question actially
Can you show the full code
sure one sec
const logsChannel = await message.guild.channels
.create("watchdog-logs", {
type: "GUILD_TEXT",
permissionOverwrites: [
{
id: message.guild.roles.everyone,
deny: ["VIEW_CHANNEL", "SEND_MESSAGES", "MANAGE_MESSAGES"],
},
],
reason: "Setup. Creating a logs channel.",
})
.catch((err) => {
console.log(
error(
`Setup in guild ${message?.guild?.id} failed to create a logs channel with the error: \n${err}`
)
);
setupIssue(`Failed to create logs channel. ${err}`);
return;
});
const successfulSetup = new Discord.MessageEmbed()
.setTitle("Setup")
.setDescription(
`${emoji.check} Setup has completed successfully in ${console.timeLog}. Watchdog will log to ${logsChannel.toString}. Please now **read the documentation and go over the settings.**`
)
.addField("Support Server", "[Click here](https://discord.gg/NhxUWBHCjH)")
.addField("Documentation", "[Click here](https://docs.watchdogbot.co/)")
.setColor(green);
emsg.edit({ embeds: [successfulSetup], components: [] });
damn that formatted weird in discord but ok
you have a .catch
yeah
that returns undefined (void)
I would just do .create(..).catch(() => null)
and then check if the channel is null
and if it is, log it or whatever, and then return out of the function/scope
alright, thanks!