uses a slash command and my trovo connector api to get the streamer profile of the selected user
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
/*Command definition
await lib.discord.commands['@release'].create({
guild_id: '836159657705603094',
name: 'trovo_share',
description: 'shares the profile of a streamer on Trovo',
default_permission: false,
options: [
{
type: 3,
name: 'name',
description: 'Please enter your streamer name',
required: true,
},
],
});
*/
await shareStreamer(context.params.event.data.options[0].value);
async function shareStreamer(name) {
streamer = await lib.Akanixon.trovo['@release'].main.get.channel_info({
username: `${name}`,
});
if (streamer.status == 1002)
return await lib.discord.interactions['@1.0.1'].responses.ephemeral.create({
token: `${context.params.event.token}`,
content: `π User \`${name}\` not found!`,
response_type: 'CHANNEL_MESSAGE_WITH_SOURCE',
});
categories = await lib.Akanixon.trovo['@release'].main.get.game_categories(
{}
);
category = categories.category_info.find((c) => c.id == streamer.category_id);
category = categories.category_info.find((c) => c.id == streamer.category_id);
let components = [
{
type: 1,
components: [
{
style: 5,
label: `ππ
°ππ
²π
·`,
url: `${streamer.channel_url}`,
disabled: false,
type: 2,
},
],
},
];
if (streamer.is_live) {
components[0].components.push({
style: 5,
label: `ποΈ ${streamer.current_viewers}`,
url: `${streamer.channel_url}`,
disabled: false,
type: 2,
});
}
if (streamer.streamer_info) {
streamer.streamer_info = streamer.streamer_info.replace(
/\! (?!\!)/g,
'!\n'
);
streamer.streamer_info = streamer.streamer_info.replace(/\, /g, ',\n');
streamer.streamer_info = streamer.streamer_info.replace(
/(?