Skip to content

Commit d9a705b

Browse files
committed
command permissions are no longer managed by bots
1 parent c10f231 commit d9a705b

File tree

1 file changed

+0
-42
lines changed

1 file changed

+0
-42
lines changed

src/discordBot/services/command.js

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -68,47 +68,6 @@ const updateDynamicChoices = async (client, commandNames, Course) => {
6868
});
6969
};
7070

71-
const setCommandPermissions = async (client) => {
72-
const loadedCommands = await client.guilds.cache.get(guildId)?.commands.fetch();
73-
const createCommandsWithPermission = loadedCommands.filter((command) => !command.defaultPermission && client.slashCommands.has(command.name));
74-
const fullPermissions = createCommandsWithPermission.map((command) => {
75-
const commandObj = client.slashCommands.get(command.name);
76-
const perms = [];
77-
commandObj.roles
78-
.forEach((commandRole) => {
79-
client.guild.roles.cache
80-
.filter((role) => role.name.includes(commandRole))
81-
.map((r) => perms.push({ id: r.id, type: "ROLE", permission: true }));
82-
});
83-
return {
84-
id: command.id,
85-
permissions: perms,
86-
};
87-
});
88-
89-
for (let fIndex = 0, fullLength = fullPermissions.length; fIndex < fullLength; fIndex++) {
90-
91-
if (fullPermissions[fIndex].permissions.length > 10) {
92-
93-
for (let pIndex = 0, permissionLength = fullPermissions[fIndex].permissions.length; pIndex <= permissionLength; pIndex += 10) {
94-
const slicedList = fullPermissions[fIndex].permissions.slice(pIndex, pIndex + 10);
95-
fullPermissions.push(
96-
{
97-
id: fullPermissions[fIndex].id,
98-
permissions: slicedList,
99-
},
100-
);
101-
}
102-
fullPermissions.splice(fIndex, 1);
103-
fIndex--;
104-
fullLength--;
105-
}
106-
}
107-
108-
await client.guilds.cache.get(guildId)?.commands.permissions.set({ fullPermissions });
109-
console.log("Successfully loaded all command permissions.");
110-
};
111-
11271
const deployCommands = async (commands) => {
11372
const rest = new REST({ version: "9" }).setToken(token);
11473

@@ -156,7 +115,6 @@ const loadCommands = (client) => {
156115
const setUpCommands = async (client, Course) => {
157116
const commands = loadCommands(client);
158117
if (process.env.NODE_ENV === "production") await deployCommands(commands);
159-
await setCommandPermissions(client);
160118
await updateDynamicChoices(client, ["join", "leave", "hide_course", "unhide_course", "lock_chat", "unlock_chat"], Course);
161119
};
162120

0 commit comments

Comments
 (0)