usage -> botstatus <GAME, STREAMING, LISTENING, WATCHING,COMPETING> <ONLINE, DND, IDLE, INVISIBLE> (Whatever you want ) \n
// use command **botstatus** to change
// if you try this command like ( botstatus WATCHING IDLE Happy to Help you )
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const owner_id = `${process.env.owner_id}`; //to getting Owner id
const sleep = async (ms) => new Promise((r) => setTimeout(r, ms)); //sleep
module.exports = async (event, context) => {
if (context.params.event.author.id === `${process.env.owner_id}`) {
let content = event.content.split(' ');
let activity_type = content[1].toUpperCase();
let status = content[2].toUpperCase();
let activity_name = content.slice(3).join(' ');
let valid_activity_type = [
`GAME`,
`STREAMING`,
`LISTENING`,
`WATCHING`,
`COMPETING`,
];
let valid_status = [`ONLINE`, `DND`, `IDLE`, `INVISIBLE`];
if (activity_type === `STREAMING`) {
//if you're using the activity type as STREAMING you must give twich live url or youtube live url
let url = content[3];
let activity_name = content.slice(4).join(' ');
if (url.startsWith(`https`)) {
await lib.discord.users['@0.1.4'].me.status.update({
activity_name: `${activity_name}`, // happy to help you
activity_type: `${activity_type}`, // wheather its STREAMING
url: `${url}`, //stream url
status: `${status}`, // ONLINE , DND, INVISIBLE
});
message = await lib.discord.channels['@0.1.2'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
embed: {
type: `rich`,
title: `:white_check_mark: | Successfully updated my status !!`,
description: `**Activity Type**\n \`\`\`js\n${activity_type}\`\`\`\n**Activity Status**\n \`\`\`js\n${status}\`\`\`\n**Activity Name**\n \`\`\`js\n${activity_name}\`\`\`\n**(Streaming Link)[${url}]**`,
color: 0x9bfc07, //greem color
},
//Result
//:tick: Successfully updated my status
// Activity type [STEAMING]
// Activity status [ONLINE,DND,IDLE,INVISBLE]
// Activity name [happy to help you]
// Streaming link
});
await sleep(1000);
await lib.discord.channels['@0.2.0'].messages.destroy({
channel_id: context.params.event.channel_id,
message_id: context.params.event.id,
});
} else {
message = await lib.discord.channels['@0.1.2'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
embed: {
type: `rich`,
description: `:x: | ** you need to provide a link for STREAMING **`,
color: 0xff0000,
},
});
await sleep(1000);
await lib.discord.channels['@0.2.0'].messages.destroy({
channel_id: context.params.event.channel_id,
message_id: context.params.event.id,
});
}
} else {
if (!valid_activity_type.includes(activity_type)) {
message = await lib.discord.channels['@0.1.2'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
embed: {
type: `rich`,
description: `:x: | ** Invalid activity type provided! **`,
color: 0xff0000, //red
},
});
await sleep(1000);
await lib.discord.channels['@0.2.0'].messages.destroy({
channel_id: context.params.event.channel_id,
message_id: context.params.event.id,
});
} else if (!valid_status.includes(status)) {
message = await lib.discord.channels['@0.1.2'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
embed: {
type: `rich`,
description: `:x: | **Invalid status provided!**`,
color: 0xff0000, //red
},
});
await sleep(1000);
await lib.discord.channels['@0.2.0'].messages.destroy({
channel_id: context.params.event.channel_id,
message_id: context.params.event.id,
});
} else if (!activity_name) {
message = await lib.discord.channels['@0.1.2'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
embed: {
type: `rich`,
description: ` :x: | **You did not give a message to display!**`,
color: 0xff0000, //red
},
});
await sleep(1000);
await lib.discord.channels['@0.2.0'].messages.destroy({
channel_id: context.params.event.channel_id,
message_id: context.params.event.id,
});
} else {
await lib.discord.users['@0.1.4'].me.status.update({
activity_name: `${activity_name}`,
activity_type: `${activity_type}`,
status: `${status}`,
});
message = await lib.discord.channels['@0.2.0'].messages.create({
channel_id: context.params.event.channel_id,
content: ``,
embed: {
type: `rich`,
title: `:white_check_mark: | Successfully updated my status !!`,
description: `**Activity Type**\n \`\`\`js\n${activity_type}\`\`\`\n**Activity Status**\n \`\`\`js\n${status}\`\`\`\n**Activity Name**\n \`\`\`js\n${activity_name}\`\`\`\n`,
color: 0x9bfc07, //green
},
//Result
//:tick: Successfully updated my status
// Activity type [Except STREAMING]
// Activity status [ONLINE,DND,IDLE,INVISBLE]
// Activity name [happy to help you]
});
await sleep(1000);
await lib.discord.channels['@0.2.0'].messages.destroy({
channel_id: context.params.event.channel_id,
message_id: context.params.event.id,
});
}
}
}
};