Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
171
rated 0 times [  172] [ 1]  / answers: 1 / hits: 8049  / 3 Years ago, mon, may 17, 2021, 12:00:00

I'm having a problem with TypeScript compiler that expects a : in 17, 5 but I can't understand why and where to put it, my code:


import { Client , TextChannel } from "discord.js";

module.exports = {
name: "ready",
run: async(client: Client) => {
client.user.setPresence({
activities: [{
name: "Aun en beta!"
}],
status: "idle"
})

let str = `-- censored --`
let channel: TextChannel;
channel = client.channels.cache.get('-- censored --')?
channel.send (str)
}
}

More From » typescript

 Answers
5

the problem was with a ? as mentioned in the comment.
also you forgot many semicolons in your code that I added.


I edited your hole code and here it is:


if you meant a null check by that ? then you had to place it somewhere else... see this below


import { Client , TextChannel } from "discord.js";

module.exports = {
name: "ready",
run: async (client: Client) => {
client.user.setPresence({
activities: [{
name: "Aun en beta!"
}],
status: "idle"
});

let str = `-- censored --`;
let channel: TextChannel;
channel = client.channels.cache?.get('-- censored --');
// ^^ ^
// problem was here
channel.send(str);
}
};

[#1351] Monday, May 10, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kelleyamiahk

Total Points: 216
Total Questions: 113
Total Answers: 119

Location: Serbia
Member since Tue, Jul 26, 2022
2 Years ago
kelleyamiahk questions
Mon, Apr 5, 21, 00:00, 3 Years ago
Mon, Feb 22, 21, 00:00, 3 Years ago
Sun, Dec 27, 20, 00:00, 4 Years ago
Fri, Nov 27, 20, 00:00, 4 Years ago
;