This code allows use to lock a channel from sending messages with one simple command. All it requires that you do is input a channel id which will log the action and to register the command on the command builder!
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let channelID = context.params.event.data.options[0].value;
const now = new Date();
let time = Math.round(new Date(now).getTime() / 1000);
console.log(time);
if (context.params.event.member.permission_names.includes('MANAGE_CHANNELS')) {
await lib.discord.channels['@0.3.2'].permissions.update({
overwrite_id: `${context.params.event.guild_id}`,
channel_id: `${channelID}`,
deny: `${1 << 11}`,
type: 0
});
await lib.discord.interactions['@1.0.1'].responses.ephemeral.create({
token: `${context.params.event.token}`,
content: `Successfully locked <#${context.params.event.channel_id}>`,
response_type: 'CHANNEL_MESSAGE_WITH_SOURCE'
});
await lib.discord.channels['@0.3.2'].messages.create({
channel_id: `${process.env.LOG_CHANNEL}`,
content: ``,
embeds: [
{
'title': `New channel locked!`,
'description': '',
'color': 0xe64d3d,
'fields': [
{
name: 'Authorizer',
value: '<@'+context.params.event.member.user.id+'>',
},
{
name: 'Channel',
value: '<#'+channelID+'>',
},
{
name: 'Time',
value: '',
}
]
}
]
});
} else {
await lib.discord.interactions['@1.0.1'].responses.ephemeral.create({
token: `${context.params.event.token}`,
content: `You must have manage channel perms to use this command!`,
response_type: 'CHANNEL_MESSAGE_WITH_SOURCE'
});
}