Reputation: 403
I would like to try send medium's post links into discord channel. However i didn't find much resources online. I found some SDK library but that really seems to be outdated https://www.npmjs.com/package/medium-sdk
. It is possible to use Medium API somehow to send medium post from certain "user" as a medium post website link to the defined discord channel?
Not sure if someone ever did this. I only saw a posibility to create a medium post when a discord message is sent to the channel somehow. But that's not what I'm looking for.
Upvotes: 3
Views: 697
Reputation: 124
You can use this package: feed-watcher, and set the feed to https://medium.com/feed/@the_writer_name
.
Upvotes: 1
Reputation: 403
This way, you can get medium posts from the feed-watcher and then send link from the medium post to the discord channel. (Feed is updating approx each 15-20 minutes.) So there might be a delay once medium post is posted to receive data from feed to send link to the channel.
'use strict';
//define your medium link in the feed
var Watcher = require('feed-watcher'),
feed = "https://yourmedium.medium.com/feed?unit=second&interval=5",
interval = 10 // seconds
var watcher = new Watcher(feed, interval)
// Require the necessary discord.js classes
const { Client, Intents } = require('discord.js');
const config = require("./configtest.json");
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.on('ready', () => {
watcher.on('new entries', function (entries) {
entries.forEach(function (entry) {
const stringifylink = JSON.stringify(entry)
const link = JSON.parse(stringifylink)
console.log('FEED Call response:', link);
console.log('Link:', link.link)
//send new medium post link to the defined discord channel.
client.guilds.cache.forEach(guild => {
let channel = guild.channels.cache.get('ChannelID')
channel.send('Check out our new medium post! ' + link.link)
})
})
})
watcher
.start()
.then(function (entries) {
console.log(entries)
})
.catch(function(error) {
console.error(error)
})
})
// Login to Discord with your client's token
client.login(config.token);
Upvotes: 0