Skip to content

Commit

Permalink
0.1.2 finished frfr
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSerge01 committed Nov 29, 2024
1 parent e6979c1 commit 1c24fa7
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
.env
.DS_Store
data.db
data.db
bun.lockb
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"The Sokora team",
"The GitHub contributors"
],
"version": "0.2.0",
"version": "0.1.2",
"main": "./src/index.ts",
"type": "module",
"scripts": {
Expand All @@ -21,7 +21,7 @@
},
"devDependencies": {
"@types/ms": "^0.7.34",
"bun-types": "^1.1.34",
"typescript": "^5.6.3"
"bun-types": "^1.1.38",
"typescript": "^5.7.2"
}
}
9 changes: 1 addition & 8 deletions src/commands/moderation/Unban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,12 @@ export default class Unban {
await errorCheck(
PermissionsBitField.Flags.BanMembers,
{ interaction, user: target, action: "Unban" },
{ allErrors: false, botError: true, ownerError: true },
{ allErrors: false, botError: true, ownerError: true, unbanError: true },
"Ban Members"
)
)
return;

if (!target)
return await errorEmbed(
interaction,
"You can't unban this user.",
"The user was never banned."
);

await modEmbed({ interaction, user: target, action: "Unbanned" }, reason);
await guild.members.unban(id, reason ?? undefined).catch(error => console.error(error));
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/news/Edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ export default class Edit {
content: roleToSend ? `<@&${roleToSend.id}>` : undefined
});

updateNews(id, title, body);
await interaction.reply({
updateNews(guild.id, id, title, body);
await i.reply({
embeds: [new EmbedBuilder().setTitle("News edited.").setColor(genColor(100))],
ephemeral: true
});
Expand Down
18 changes: 13 additions & 5 deletions src/utils/embeds/modEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type ErrorOptions = {
botError: boolean;
ownerError?: boolean;
outsideError?: boolean;
unbanError?: boolean;
};

export async function errorCheck(
Expand All @@ -29,13 +30,11 @@ export async function errorCheck(
permissionAction: string
) {
const { interaction, user, action } = options;
const { allErrors, botError, ownerError, outsideError } = errorOptions;
const { allErrors, botError, ownerError, outsideError, unbanError } = errorOptions;
const guild = interaction.guild!;
const members = guild.members.cache!;
const member = members.get(interaction.user.id)!;
const client = members.get(interaction.client.user.id)!;
const target = members.get(user.id)!;
const name = user.displayName;

if (botError)
if (!client.permissions.has(permission))
Expand All @@ -52,7 +51,17 @@ export async function errorCheck(
`You're missing the **${permissionAction}** permission.`
);

if (unbanError)
if (!user)
return await errorEmbed(
interaction,
"You can't unban this user.",
"The user was never banned."
);

if (!allErrors) return;
const target = members.get(user.id)!;
const name = user.displayName;
if (!target) return;
if (target == member)
return await errorEmbed(interaction, `You can't ${action.toLowerCase()} yourself.`);
Expand Down Expand Up @@ -83,7 +92,7 @@ export async function errorCheck(
);
}

if (outsideError) {
if (outsideError)
if (
!(await guild.members
.fetch(user.id)
Expand All @@ -95,7 +104,6 @@ export async function errorCheck(
`You can't ${action.toLowerCase()} ${name}.`,
"This user isn't in this server."
);
}
}

export async function modEmbed(
Expand Down
8 changes: 4 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"lib": ["ESNext", "ES2021.String"],
"module": "ESNext",
"target": "ESNext",
"moduleResolution": "Node",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
Expand All @@ -17,4 +17,4 @@
"allowJs": true,
"types": ["bun-types"]
}
}
}

0 comments on commit 1c24fa7

Please sign in to comment.