Update the topic of a channel using '!settopic <topic>' command. You can easily use custom emoji, or mentions any user/role/channel in the channel topic, using this command.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const message = context.params.event;
if (message.content.startsWith('!settopic')) {
const args = message.content.split(' ').slice(1);
const topic = args.join(' ');
if (!args.length) {
await lib.discord.channels['@0.2.0'].messages.create({
content: 'Please provide a topic.',
channel_id: message.channel_id,
});
return;
}
try {
await lib.discord.channels['@0.2.0'].update({
channel_id: `${context.params.event.channel_id}`,
topic: topic,
});
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Channel topic updated!`,
});
} catch (e) {
await lib.discord.channels['@0.2.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Bot is being rate limited. Don't change channel topic continuously`,
});
}
}