-
Notifications
You must be signed in to change notification settings - Fork 4
/
title.js
21 lines (20 loc) · 866 Bytes
/
title.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
async function command(chatClient, apiClient, channel, user, args) {
const broadcaster = await apiClient.users.getUserByName(channel);
const u = await apiClient.users.getUserByName(user);
const ch = await apiClient.channels.getChannelInfoById(broadcaster);
if (args.length == 0) {
chatClient.say(channel, `The current title is ${ch.title}`);
} else {
const mod = await apiClient.moderation.checkUserMod(broadcaster.id, u.id);
if (!mod && broadcaster.id != u.id) {
chatClient.say(channel, `Sorry, ${user}, only mods may perform this action`);
return;
}
const title = args.join(' ');
await apiClient.channels.updateChannelInfo(broadcaster.id, {
title,
});
chatClient.say(channel, `Title set to ${title}`);
}
}
module.exports = { command };