#TS Issue

1 messages · Page 1 of 1 (latest)

light topaz
#

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

north quest
#

what is in-between

#

might be some if-statement shenanigans

vapid harbor
#

wait yea
Returns: Promise <GuildChannel>

north quest
#

also why is it typed as a text channel?

light topaz
north quest
north quest
light topaz
#

wait no that .create ^

vapid harbor
#

also
logschannel.toString()
its a method..

#

you set type:"GUILD_TEXT" ?

light topaz
vapid harbor
#

thats a question actially

north quest
light topaz
#

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

north quest
#

you have a .catch

light topaz
#

yeah

north quest
#

that returns undefined (void)

light topaz
#

oh

#

any way to keep .catch?

north quest
#

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

light topaz
#

alright, thanks!