Jump to content

Discord bot, 1 hour timer reminder thingy

bomberblyat
Go to solution Solved by bomberblyat,
36 minutes ago, vorticalbox said:

I would assume that your clinet.channels.cache.get() is returning nothing. if you remove the timeout do you get the same error?

I think i solved my issue 

Quote
client.on('ready', () => {
    setInterval(() => {
        client.channels.cache.get('ChannelID').send('Test');
    },  3600000);
},);

that should be on 1 hour timer now, ill see in a hour if it works as i want it to work

Hi, i started making discord bot today just for fun mainly, but also to learn js.

 

So ive been trying to make a thing for this bot that notify's ppl every hour but i keep getting some odd error, also i really dont know how to do the "pause/sleep"

client.on('ready', () => {

    var testChannel = client.channels.cache.get(channel => channel.id === ('*channel id here*'))
    setInterval(() => {
        testChannel.send("TestMessage");
    },  3600);
});

thats my code so far, it should post Test message but i just keep getting this error, "TypeError: Cannot read property 'send' of undefined"

 

All help is appreciated.

Link to comment
Share on other sites

Link to post
Share on other sites

I would assume that your clinet.channels.cache.get() is returning nothing. if you remove the timeout do you get the same error?

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, vorticalbox said:

I would assume that your clinet.channels.cache.get() is returning nothing. if you remove the timeout do you get the same error?

i removed the code, it still complains about the send thingy

Link to comment
Share on other sites

Link to post
Share on other sites

15 minutes ago, vorticalbox said:

I would assume that your clinet.channels.cache.get() is returning nothing. if you remove the timeout do you get the same error?

 client.channels.cache.get('channel id').send('Test'); this works, but i dont know implement the 1 hour time to it, like i get the timer right but it just keeps spamming it
 
Link to comment
Share on other sites

Link to post
Share on other sites

36 minutes ago, vorticalbox said:

I would assume that your clinet.channels.cache.get() is returning nothing. if you remove the timeout do you get the same error?

I think i solved my issue 

Quote
client.on('ready', () => {
    setInterval(() => {
        client.channels.cache.get('ChannelID').send('Test');
    },  3600000);
},);

that should be on 1 hour timer now, ill see in a hour if it works as i want it to work

Link to comment
Share on other sites

Link to post
Share on other sites

I've never used the library, but do you not want:

// this:
var testChannel = client.channels.cache.get('channel id')

// instead of this?
var testChannel = client.channels.cache.get(channel => channel.id === ('*channel id here*'))
Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Serjeant said:

I've never used the library, but do you not want:


// this:
var testChannel = client.channels.cache.get('channel id')

// instead of this?
var testChannel = client.channels.cache.get(channel => channel.id === ('*channel id here*'))

Well, the upper one works for now atleast,im testing it more, ill let you know if i need more help or if something goes wrong 😀

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×