Skip to content

Commit

Permalink
just some minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
greg6775 committed May 23, 2023
1 parent 45b09fc commit ef92b52
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 170 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- name: Pull Project
uses: actions/checkout@v2
uses: actions/checkout@v3.5.2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v3.6.0
with:
node-version: ${{ matrix.node-version }}

Expand Down
1 change: 0 additions & 1 deletion db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,4 @@ export default class DB {
}
});
}

}
13 changes: 0 additions & 13 deletions helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ export function sendBanMessage(ban: GuildBan, banned: boolean) {
})
}

export function handleRules(oldMember: PartialGuildMember | GuildMember, newMember: GuildMember) {
if (oldMember.pending !== newMember.pending) {
newMember.guild.roles.fetch(config.role_id).then(role => {
newMember.roles.add(role!, 'Verified');
})
newMember.guild.channels.fetch(config.log_channel).then(channel => {
const embed = defaultEmbed(newMember.user);
embed.setTitle(`${embed.data.title} verified`).setColor('#57F287');
(channel as TextChannel).send({ embeds: [ embed ] })
})
}
}

export function sendJoinMessage(member: GuildMember) {
const embed = defaultEmbed(member.user);
const role = member.guild.roles.cache.get(config.role_id);
Expand Down
3 changes: 1 addition & 2 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActivityType, Client, REST, Routes } from 'discord.js'
import { sendBanMessage, handleRules, sendJoinMessage, sendLeaveMessage, sendPrivateMessage, sendVoice } from './helper';
import { sendBanMessage, sendJoinMessage, sendLeaveMessage, sendPrivateMessage, sendVoice } from './helper';
import { handleInteraction } from "./interactions";
import DB from "./db";
//@ts-ignore
Expand Down Expand Up @@ -97,7 +97,6 @@ client.on('guildBanAdd', (ban) => sendBanMessage(ban, true))
client.on('guildBanRemove', (ban) => sendBanMessage(ban, false))

client.on('guildMemberAdd', sendJoinMessage);
//client.on('guildMemberUpdate', handleRules)
client.on('guildMemberRemove', sendLeaveMessage)

client.on('messageCreate', (message) => sendPrivateMessage(message, client))
Expand Down
20 changes: 10 additions & 10 deletions interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export async function handleInteraction(interaction: Interaction, db: DB) {
await interaction.showModal(ticket_modal);
break;
}
case "delete_ticket": {
case "close_ticket": {
let channel = interaction.channel as TextChannel;
interaction.reply({
content: `> We're closing your ticket. Please be patient.`,
});
setTimeout(() => {
channel.setParent("1082672434777428128", { lockPermissions: true });
channel.setParent("1110636030824042638", { lockPermissions: true });
}, 5000);
break;
}
Expand Down Expand Up @@ -86,9 +86,9 @@ export async function handleInteraction(interaction: Interaction, db: DB) {

let btnrow = new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder()
.setCustomId(`delete_ticket`)
.setCustomId(`close_ticket`)
.setStyle(ButtonStyle.Danger)
.setLabel(`Delete Ticket`),
.setLabel(`Close Ticket`),
]);
ch.send({
content: `${interaction.member} || <@&757969277063266407>`,
Expand Down Expand Up @@ -184,7 +184,7 @@ export async function handleInteraction(interaction: Interaction, db: DB) {
const reward = 10 + (Math.floor(Math.random() * 10));
const res = (await db.addCoins(interaction.user.id, reward));
if (res === null) {
interaction.reply("We couldn't find your account. Please [log in via discord here](<https://mc4u.xyz/login>)");
interaction.reply("We couldn't find your account. Please [log in via Discord here](<https://mc4u.xyz/login>)");
return;
}
await db.setLastDaily(interaction.user.id, Date.now());
Expand All @@ -206,9 +206,9 @@ export async function handleInteraction(interaction: Interaction, db: DB) {
}
await db.getCoins(id).then(result => {
if (result !== null) {
interaction.reply(`Your balance is ${result} coins.`);
interaction.reply(`You currently have ${result} coins.`);
} else {
interaction.reply("We couldn't find your account. Please [log in via discord here](<https://mc4u.xyz/login>)");
interaction.reply("We couldn't find your account. Please [log in via Discord here](<https://mc4u.xyz/login>)");
}
});
}
Expand All @@ -222,7 +222,7 @@ export async function handleInteraction(interaction: Interaction, db: DB) {
const coins = interaction.options.getInteger("coins", true);
const res = await db.addCoins(member.id, coins);
if (res === null) {
interaction.reply("We couldnt find the account in our database");
interaction.reply("We couldn't find the account in our database");
return;
}
interaction.reply(`Added ${coins} coins to ${member.user.username}'s balance.`);
Expand All @@ -237,13 +237,13 @@ export async function handleInteraction(interaction: Interaction, db: DB) {
const coins = interaction.options.getInteger("coins", true);
const res = await db.removeCoins(member.id, coins);
if (res === null) {
interaction.reply("We couldnt find the account in our database");
interaction.reply("We couldn't find the account in our database");
return;
}
interaction.reply(`Removed ${coins} coins from ${member.user.username}'s balance.`);
}


}

function lockVoice(interaction: ButtonInteraction, lock: boolean) {
Expand Down
Loading

0 comments on commit ef92b52

Please sign in to comment.