Skip to content

Commit 38be550

Browse files
change: outsource roles and channel ids #HSFDPMUW (#183)
* change: outsource roles and channel ids * fix: missing id replacement * change: env vars to const.ts * fix
1 parent fdba29f commit 38be550

File tree

5 files changed

+53
-25
lines changed

5 files changed

+53
-25
lines changed

const.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Roles
2+
3+
export const supportRole = "1120392307087261787" // Support role
4+
export const ownerRoleID = "757969277063266407" // Owner role ID
5+
6+
export const supportRoles = [ ownerRoleID, "815298088184446987", supportRole ] // Owner, Dev, Support
7+
8+
export const verified = "757983851032215673" // Verified role
9+
10+
// Channels
11+
12+
export const createTicketChannelID = "1081337337704886392" // Channel ID for creating tickets
13+
export const firstLevelSupportCategoryID = "1081347349462405221" // Category ID for first level support
14+
export const secondLevelSupportCategoryID = "1120395441138315345" // Category ID for second level support
15+
16+
export const getStartedChannelID = "1081326643928375306" // Channel ID for getting started
17+
export const logChannelID = "757970455700439100" // Log channel ID for bot actions
18+
export const showCaseChannelID = "1147821355362963458"
19+
20+
// Categories
21+
22+
export const linksCategoryID = "1128632114242392064" // Category ID for links
23+
24+
// Guild
25+
26+
export const guildID = "757966278936756345" // Guild ID for the bot

helper.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Client, TextChannel, GuildBan, GuildMember, PartialGuildMember, User, Message, VoiceState, EmbedBuilder, GuildTextBasedChannel } from 'npm:discord.js'
2+
import { logChannelID, showCaseChannelID } from './const.ts';
23

34
export function sendBanMessage(ban: GuildBan, banned: boolean) {
4-
ban.client.channels.fetch(Deno.env.get("LOG_CHANNEL")!).then(channel => {
5+
ban.client.channels.fetch(logChannelID).then(channel => {
56
const embed = defaultEmbed(ban.user);
67
embed.setTitle(`${embed.data.title} ${banned ? '' : 'un'}banned`)
78
.addFields([ { name: 'Reason', value: ban.reason ?? 'Not specified' } ]);
@@ -11,7 +12,7 @@ export function sendBanMessage(ban: GuildBan, banned: boolean) {
1112
export function sendLeaveMessage(member: PartialGuildMember | GuildMember) {
1213
const embed = defaultEmbed(member.user);
1314
embed.setTitle(`${embed.data.title} left`)
14-
member.guild.channels.fetch(Deno.env.get("LOG_CHANNEL")!).then(channel => (channel as TextChannel).send({ embeds: [ embed ] }));
15+
member.guild.channels.fetch(logChannelID).then(channel => (channel as TextChannel).send({ embeds: [ embed ] }));
1516
member.guild.channels.fetch().then(channels => channels.filter(channel => channel?.isTextBased() && channel.name === "ticket-"+member.user.id).forEach(channel => (channel as GuildTextBasedChannel).send({ embeds: [ embed ] })));
1617
}
1718
export function sendPrivateMessage(message: Message, client: Client) {
@@ -26,12 +27,12 @@ export function sendPrivateMessage(message: Message, client: Client) {
2627
])
2728
.setDescription(`\`\`\`${message.content}\`\`\``)
2829
.setColor('#57F287');
29-
client.channels.fetch(Deno.env.get("LOG_CHANNEL")!).then(channel => (channel as TextChannel).send({ embeds: [ embed ], files: [ ...message.attachments.values() ] }))
30+
client.channels.fetch(logChannelID).then(channel => (channel as TextChannel).send({ embeds: [ embed ], files: [ ...message.attachments.values() ] }))
3031
}
3132
}
3233

3334
export async function handleShowcaseMessage(message: Message) {
34-
if (message.channel.id !== Deno.env.get("SHOWCASE_CHANNEL")! || message.author.bot) return;
35+
if (message.channel.id !== showCaseChannelID || message.author.bot) return;
3536
const domainPattern = /(?:https?:\/\/)?(?:www\.)?([a-zA-Z0-9.-]+(?:\.[a-zA-Z]{2,}))(?::([0-9]+))?/g;
3637
const match = Array.from(message.content.matchAll(domainPattern));
3738

interactions.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ActionRowBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, ChannelType, EmbedBuilder, GuildMember, GuildMemberRoleManager, Interaction, Message, MessageFlags, ModalBuilder, PermissionsBitField, TextChannel, TextInputBuilder, TextInputStyle, User, UserSelectMenuBuilder, VoiceChannel } from "npm:discord.js"
22
import { saveTranscript, findUser, lastLogin, getServerURLs, getLastDaily, addCoins, setLastDaily, getCoins, removeCoins, addPartner, removePartner, getPartners, getMemberFromBBNId } from "./db.ts";
3+
import { createTicketChannelID, firstLevelSupportCategoryID, getStartedChannelID, ownerRoleID, secondLevelSupportCategoryID, supportRole, supportRoles, verified } from "./const.ts";
34

45
export async function handleInteraction(interaction: Interaction) {
56
if (interaction.isButton()) {
@@ -86,7 +87,7 @@ export async function handleInteraction(interaction: Interaction) {
8687

8788
if (interaction.isUserSelectMenu() && interaction.guild && interaction.customId === 'verify_modal') {
8889
const member = interaction.guild.members.cache.get(interaction.values[ 0 ])
89-
const role = interaction.guild.roles.cache.get("757983851032215673")
90+
const role = interaction.guild.roles.cache.get(verified)
9091

9192
if (member && role) {
9293
if (member.roles.cache.has(role.id)) {
@@ -147,7 +148,7 @@ export async function handleInteraction(interaction: Interaction) {
147148
"ViewChannel": true
148149
});
149150
await possibleChannel.send({
150-
content: `${interaction.member} || <@&1120392307087261787>`,
151+
content: `${interaction.member} || <@&${supportRole}>`,
151152
embeds: [ embed ],
152153
components: [ btnrow ],
153154
});
@@ -161,7 +162,7 @@ export async function handleInteraction(interaction: Interaction) {
161162
name: ticketname,
162163
type: ChannelType.GuildText,
163164
topic: `ticket of ${interaction.user.tag}`,
164-
parent: "1081347349462405221",
165+
parent: firstLevelSupportCategoryID,
165166
});
166167

167168
setTimeout(() => {
@@ -171,7 +172,7 @@ export async function handleInteraction(interaction: Interaction) {
171172
}, 5000);
172173

173174
await ch.send({
174-
content: `${interaction.member} || <@&1120392307087261787>`,
175+
content: `${interaction.member} || <@&${supportRole}>`,
175176
embeds: [ embed ],
176177
components: [ btnrow ],
177178
});
@@ -221,7 +222,7 @@ export async function handleInteraction(interaction: Interaction) {
221222
// interaction.reply("message sent!")
222223

223224
// code
224-
const ticketChannel = interaction.guild!.channels.cache.get("1081337337704886392") as TextChannel;
225+
const ticketChannel = interaction.guild!.channels.cache.get(createTicketChannelID) as TextChannel;
225226
if (!ticketChannel) return;
226227

227228
const embed = new EmbedBuilder()
@@ -256,13 +257,13 @@ export async function handleInteraction(interaction: Interaction) {
256257
return;
257258
}
258259
// move to escalation category
259-
interaction.channel?.setParent("1120395441138315345", {
260+
interaction.channel?.setParent(secondLevelSupportCategoryID, {
260261
lockPermissions: false,
261262
reason: "Ticket escalated",
262263
});
263264
interaction.reply({
264-
allowedMentions: { roles: [ '757969277063266407' ] },
265-
content: "Ticket escalated. || <@&757969277063266407>"
265+
allowedMentions: { roles: [ ownerRoleID ] },
266+
content: `Ticket escalated. || <@&${ownerRoleID}>`
266267
});
267268
}
268269

@@ -272,18 +273,18 @@ export async function handleInteraction(interaction: Interaction) {
272273
return;
273274
}
274275
// check if ticket channel
275-
if (!(interaction.channel?.type === ChannelType.GuildText && interaction.channel?.parent?.id === "1120395441138315345")) {
276+
if (!(interaction.channel?.type === ChannelType.GuildText && interaction.channel?.parent?.id === secondLevelSupportCategoryID)) {
276277
interaction.reply("This command can only be used in a ticket channel.");
277278
return;
278279
}
279-
// move to escalation category
280-
interaction.channel?.setParent("1081347349462405221", {
280+
// move to first level category
281+
interaction.channel?.setParent(firstLevelSupportCategoryID, {
281282
lockPermissions: false,
282283
reason: "Ticket deescalated",
283284
});
284285
interaction.reply({
285-
allowedMentions: { roles: [ '1120392307087261787' ] },
286-
content: "Ticket deescalated. || <@&1120392307087261787>"
286+
allowedMentions: { roles: [ supportRole ] },
287+
content: `Ticket deescalated. || <@&${supportRole}>`
287288
});
288289
}
289290

@@ -306,7 +307,7 @@ export async function handleInteraction(interaction: Interaction) {
306307
}
307308

308309
let reward = 10 + (Math.floor(Math.random() * 10));
309-
if ((await interaction.guild!.members.fetch(interaction.user.id)).premiumSince || (await interaction.guild!.members.fetch(interaction.user.id)).roles.cache.has("1120392307087261787"))
310+
if ((await interaction.guild!.members.fetch(interaction.user.id)).premiumSince || (await interaction.guild!.members.fetch(interaction.user.id)).roles.cache.has(supportRole))
310311
reward *= 10;
311312
const res = await addCoins(interaction.user.id, reward);
312313
if (res === null) {
@@ -384,7 +385,7 @@ export async function handleInteraction(interaction: Interaction) {
384385
const ram = interaction.options.getInteger("ram", true);
385386
const storage = interaction.options.getInteger("storage", true);
386387
const slots = interaction.options.getInteger("slots", true);
387-
const invite = await interaction.guild?.invites.create(Deno.env.get("GETSTARTED_CHANNEL")!, {
388+
const invite = await interaction.guild?.invites.create(getStartedChannelID, {
388389
maxAge: 0,
389390
unique: true,
390391
reason: "Partner invite",
@@ -515,8 +516,6 @@ async function fetchSteamnames(web_token: string | null, owners: { sum: Record<s
515516
return owners;
516517
}
517518

518-
const supportRoles = [ "757969277063266407", "815298088184446987", "1120392307087261787" ] // Owner, Dev, Support
519-
520519
function lockVoice(interaction: ButtonInteraction, lock: boolean) {
521520
const channel = (interaction.member as GuildMember).voice.channel as VoiceChannel
522521

main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { handleShowcaseMessage, sendBanMessage, sendLeaveMessage, sendPrivateMes
33
import { handleInteraction } from "./interactions.ts";
44
import { PartnerManager } from './partner.ts';
55
import { findUser } from "./db.ts";
6+
import { linksCategoryID } from './const.ts';
67

78
const client = new Client({ intents: 3276799 });
89

@@ -207,7 +208,7 @@ client.on('guildMemberUpdate', async (oldMember, newMember) => {
207208

208209
const channel = await newMember.guild.channels.create({
209210
name: `link-${newMember.id}`,
210-
parent: await newMember.guild.channels.fetch(Deno.env.get("LINK_CATEGORY")!) as CategoryChannel,
211+
parent: await newMember.guild.channels.fetch(linksCategoryID) as CategoryChannel,
211212
});
212213
await channel.permissionOverwrites.create(newMember, { ViewChannel: true });
213214
await channel.send({ content: `<@${newMember.id}> Looks like you just boosted the server! Unfortunately, you are not linked to your BBN account yet. Please send your Email address to this channel to link your account. Our Team will respond as soon as possible.`, allowedMentions: { users: [ newMember.id ] } });

partner.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Client, Collection, GuildMember, Invite, TextChannel } from "npm:discord.js";
22
import { getMemberFromBBNId, getPartnerFromInvite, updateLastInvite } from "./db.ts";
33
import { defaultEmbed } from "./helper.ts";
4+
import { guildID, logChannelID } from "./const.ts";
45

56
export class PartnerManager {
67

@@ -11,7 +12,7 @@ export class PartnerManager {
1112

1213
invites: Collection<string, Invite> = new Collection();
1314
async cacheInvites() {
14-
const guild = await this.client.guilds.fetch(Deno.env.get("GUILD_ID")!);
15+
const guild = await this.client.guilds.fetch(guildID);
1516
const invites = await guild.invites.fetch({
1617
cache: false
1718
});
@@ -20,7 +21,7 @@ export class PartnerManager {
2021
}
2122

2223
async getLastInvite() {
23-
const guild = await this.client.guilds.fetch(Deno.env.get("GUILD_ID")!);
24+
const guild = await this.client.guilds.fetch(guildID);
2425
const invites = await guild.invites.fetch({
2526
cache: false
2627
});
@@ -47,6 +48,6 @@ export class PartnerManager {
4748
embed.setTitle(`${member.user.tag} ${action === 'join' ? 'joined' : 'left'}`)
4849
.setColor(action === 'join' ? '#FEE75C' : '#F57F7F')
4950
.setDescription(invitetext);
50-
member.guild.channels.fetch(Deno.env.get("LOG_CHANNEL")!).then(channel => (channel as TextChannel).send({ embeds: [ embed ] }));
51+
member.guild.channels.fetch(logChannelID).then(channel => (channel as TextChannel).send({ embeds: [ embed ] }));
5152
}
5253
}

0 commit comments

Comments
 (0)