This discord unlock slash command will make it so that people can talk in your channel. It is very simple to setup, requiring that you input a log channel id and you 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}`,
allow: `${1 << 11}`,
type: 0,
});
await lib.discord.interactions['@1.0.1'].responses.ephemeral.create({
token: `${context.params.event.token}`,
content: `Successfully unlocked <#${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 unlocked!`,
description: '',
color: 0x2fcc71,
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',
});
}