Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

439
Views
discord bot with twitter api, but on bot startup i get 403 error

the error as follows: Encountered an unrecoverable error, the stream is abort.
Reason: [ 403 ] The connecting account is not permitted to access this endpoint.

I have searched online for an answer but can't find one that helps or i don't understand what they mean so i posted this here in hopes i find the right solution

this is the code:

    console.clear();
    console.log(`[TWITTER] Starting Service`);
    
    // Packages
    const {Discord, Client, Collection, Message, MessageEmbed} = require("discord.js");
    const Twit = require("node-tweet-stream");
    const fs = require("fs");
    
    // Setup
    const config = JSON.parse(fs.readFileSync("./config.json", "utf8"));
    
    // Clients
    const t = new Twit({
        consumer_key: config.twitterConsumerKey,
        consumer_secret: config.twitterConsumerSecret,
        app_only_auth:true,
        //access_token_key:config.twitterAccessTokenKey,
        //access_token_secret:config.twitterAccessTokenSecret
        token: config.twitterAccessTokenKey,
        token_secret: config.twitterAccessTokenSecret
    });
    const dClient = new Client({intents: 32767});
    dClient.login(config.token);
    
    // Success
    dClient.on('ready', () => {
        console.log(`[TWITTER] Service Started`);
    });
    
    // Tweet Listener + Post
    t.on('tweet', function (tweet) {
        let media = tweet.entities.media;
        chatPost(tweet.text, tweet.user.screen_name, `https://twitter.com/${tweet.user.screen_name}/status/${tweet.id_str}`, tweet.created_at, tweet.user.profile_image_url, media);
    })
    t.on('error', function (err) {
        console.log('Oh no')
    })
    let track = config.following;
    for (var i = 0; i < track.length; i++) {
        t.follow(track[i]);
        console.log(`[TWITTER] Following Twitter User [ID]${track[i]}`)
        console.log(`For Support please join https://discord.gg/PrGCCWpDbP`)
    }
    
    
    // Functions
    function chatPost(content, author, url, time, authorPfp, media) {
        const message = new MessageEmbed().setTitle(config.title).setColor(config.colour).setDescription(content).setAuthor(`@${author}`, authorPfp, `https://twitter.com/${author}`).setFooter(`Twitter - ${time}`, "https://abs.twimg.com/favicons/twitter.ico").setURL(url);
    
        if (!!media) for (var j = 0; j < media.length; j++) message.setImage(media[j].media_url);
    
        for (const __channel of config.channelsToPost.map(x => dClient.channels.cache.get(x))) __channel.send({embeds: [message]});
    }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!