Skip to content

Commit 57b188b

Browse files
committed
new command for essential discord
1 parent e780d29 commit 57b188b

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

languages/en-US.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,11 @@
18671867
"TAG_SLASH_ENABLED": "Slash command tags have been enabled! You should be able to see them now when you hit `/` (you may need to start typing a tag name for it to show)",
18681868
"TAG_SLASH_DISABLED": "Slash command tags have been disabled! It may take a little while for the commands to disappear and may require a client reload",
18691869
"TAG_LIST": "{{guild}}'s tags",
1870+
"TEMP_MEDIA_PERMS_COMMAND_DESCRIPTION": "Temporarily give a member permission to attach files & embed links",
1871+
"TEMP_MEDIA_PERMS_ARGUMENT_USER_DESCRIPTION": "The member to give permissions to",
1872+
"TEMP_MEDIA_PERMS_MISSING_USER": "you forgot to provide a user ya doofus",
1873+
"TEMP_MEDIA_PERMS_ALREADY_HAS": "that user already has permission to attach files & embed links",
1874+
"TEMP_MEDIA_PERMS_REASON": "Given temporary media permissions by {{author}}",
18701875
"THREADMEMBERUPDATELOG_AUTHOR": "Thread Members Update | {{thread}}",
18711876
"TICKET_COMMAND_DESCRIPTION": "Manage ticket configuration in the server",
18721877
"TICKET_MAIN_DESCRIPTION": "Here are all the ticket configuration commands",
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { ApplicationCommandMessage } from "@fire/lib/extensions/appcommandmessage";
2+
import { FireMember } from "@fire/lib/extensions/guildmember";
3+
import { Command } from "@fire/lib/util/command";
4+
import { Language } from "@fire/lib/util/language";
5+
import { PermissionFlagsBits } from "discord-api-types/v9";
6+
7+
export default class TempMediaPerms extends Command {
8+
constructor() {
9+
super("temp-media-perms", {
10+
description: (language: Language) =>
11+
language.get("TEMP_MEDIA_PERMS_COMMAND_DESCRIPTION"),
12+
args: [
13+
{
14+
id: "user",
15+
type: "member",
16+
description: (language: Language) =>
17+
language.get("TEMP_MEDIA_PERMS_ARGUMENT_USER_DESCRIPTION"),
18+
default: undefined,
19+
required: true,
20+
},
21+
],
22+
guilds: ["864592657572560958"],
23+
enableSlashCommand: true,
24+
restrictTo: "guild",
25+
moderatorOnly: true,
26+
slashOnly: true,
27+
ephemeral: true,
28+
});
29+
}
30+
31+
async run(command: ApplicationCommandMessage, args: { user: FireMember }) {
32+
if (!args.user) return await command.error("TEMP_MEDIA_PERMS_MISSING_USER");
33+
if (
34+
args.user.permissions.has(
35+
PermissionFlagsBits.AttachFiles | PermissionFlagsBits.EmbedLinks
36+
)
37+
)
38+
return await command.error("TEMP_MEDIA_PERMS_ALREADY_HAS");
39+
40+
const role = command.guild.roles.cache.find(
41+
(role) => role.name == "TEMP MEDIA PERMISSIONS"
42+
);
43+
const added = await args.user.roles
44+
.add(
45+
role,
46+
command.language.get("TEMP_MEDIA_PERMS_REASON", {
47+
author: `${command.author} (${command.author.id})`,
48+
})
49+
)
50+
.catch(() => {});
51+
if (!added) return await command.error("COMMAND_ERROR_500");
52+
else
53+
setTimeout(() => {
54+
args.user.roles.remove(
55+
role,
56+
command.language.get("TEMP_MEDIA_PERMS_REASON", {
57+
author: `${command.author} (${command.author.id})`,
58+
})
59+
);
60+
}, 120_000);
61+
}
62+
}

0 commit comments

Comments
 (0)