forked from cosmic/scythe
1
0
Fork 0

Compare commits

..

4 Commits

10 changed files with 343 additions and 8 deletions

88
src/commands/confess.ts Normal file
View File

@ -0,0 +1,88 @@
import {
ApplicationCommandOptionType,
Attachment,
Colors,
CommandInteraction,
EmbedBuilder,
MessageFlags,
TextChannel,
} from "discord.js";
import { Discord, Slash, SlashOption } from "discordx";
import db from "../db";
import { confessTable } from "../db/schema";
import { eq } from "drizzle-orm";
@Discord()
export class Confession {
@Slash({ name: "confess-setup", description: "setup confessions" })
async confessSetup(
@SlashOption({
name: "log_channel",
description: "channel to send logs",
required: true,
type: ApplicationCommandOptionType.Channel,
})
channel: TextChannel,
inter: CommandInteraction,
) {
if (inter.guild?.ownerId != inter.user.id) {
return inter.reply("you aren't the owner silly!");
}
await db.insert(confessTable).values({
guild: inter.guildId!,
channel: channel.id,
});
await inter.reply("confess setup done!");
}
@Slash({
name: "confess",
description: "confessions are LOGGED for moderation purposes.",
})
async confess(
@SlashOption({
name: "message",
description: "message to confess",
required: true,
type: ApplicationCommandOptionType.String,
})
message: string,
@SlashOption({
name: "attachment",
description: "submit an image attachment with the message :3",
required: false,
type: ApplicationCommandOptionType.Attachment,
})
attachment: Attachment,
inter: CommandInteraction,
) {
const embed = new EmbedBuilder()
.setTitle("A Confession!")
.setDescription(message)
.setFooter({ text: "Confessions" })
.setColor(Colors.DarkRed);
const logEmbed = new EmbedBuilder()
.setTitle(`Confession Log from ${inter.user.username}`)
.setDescription(message)
.setFooter({ text: "Confession Log" });
if (attachment) {
embed.setImage(attachment.url);
logEmbed.setImage(attachment.url);
}
const channelRes = await db
.select()
.from(confessTable)
.where(eq(confessTable.guild, inter.guildId!));
const channel = inter.client.channels.cache.get(
channelRes[0].channel,
) as TextChannel;
await (inter.channel as TextChannel).send({ embeds: [embed] });
await inter.reply({
content: "Confession Sent",
flags: MessageFlags.Ephemeral,
});
await channel.send({ embeds: [logEmbed] });
}
}

View File

@ -33,6 +33,9 @@ export class Intro {
set: { channel: channel.id },
setWhere: sql`guild = ${inter.guildId}`,
});
await inter.reply({content: "intro setup done!", flags: MessageFlags.Ephemeral});
await inter.reply({
content: "intro setup done!",
flags: MessageFlags.Ephemeral,
});
}
}

View File

@ -24,6 +24,7 @@ export class TicketComponenets {
.select()
.from(ticketsTable)
.where(eq(ticketsTable.user, inter.user.id));
if (check.length >= 1) {
await inter.reply({
content: "You already have a ticket open.",
@ -54,12 +55,20 @@ export class TicketComponenets {
PermissionsBitField.Flags.SendMessages,
],
},
{
id: inter.client.user.id,
allow: [
PermissionsBitField.Flags.ViewChannel,
PermissionsBitField.Flags.SendMessages
],
}
],
});
const category = inter.guild?.channels.cache.get(
const category = inter.guild!.channels.cache.get(
Bun.env.TICKET_CATEGORY,
) as CategoryChannel;
channel = await channel.setParent(category);
const embed = new EmbedBuilder()

View File

@ -0,0 +1,4 @@
CREATE TABLE `confess` (
`guild` text PRIMARY KEY NOT NULL,
`channel` text NOT NULL
);

View File

@ -0,0 +1,214 @@
{
"version": "6",
"dialect": "sqlite",
"id": "dea3a962-3fb8-4c45-90fa-baff2f53bfb2",
"prevId": "fb3b9c6d-7d3b-4651-b230-e163bf08b586",
"tables": {
"bye": {
"name": "bye",
"columns": {
"guild": {
"name": "guild",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"channel": {
"name": "channel",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"message": {
"name": "message",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"colonthree": {
"name": "colonthree",
"columns": {
"user": {
"name": "user",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"amount": {
"name": "amount",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"messages_count": {
"name": "messages_count",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"confess": {
"name": "confess",
"columns": {
"guild": {
"name": "guild",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"channel": {
"name": "channel",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"greets": {
"name": "greets",
"columns": {
"guild": {
"name": "guild",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"channel": {
"name": "channel",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"message": {
"name": "message",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"intro": {
"name": "intro",
"columns": {
"guild": {
"name": "guild",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"channel": {
"name": "channel",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"tickets": {
"name": "tickets",
"columns": {
"user": {
"name": "user",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"channel": {
"name": "channel",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"uptime": {
"name": "uptime",
"columns": {
"guild": {
"name": "guild",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"channel": {
"name": "channel",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"message": {
"name": "message",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"views": {},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@ -29,6 +29,13 @@
"when": 1742927150677,
"tag": "0003_clumsy_mephistopheles",
"breakpoints": true
},
{
"idx": 4,
"version": "6",
"when": 1744606507294,
"tag": "0004_keen_bedlam",
"breakpoints": true
}
]
}

View File

@ -36,4 +36,9 @@ export const introTable = sqliteTable("intro", {
channel: text().notNull(),
});
export const confessTable = sqliteTable("confess", {
guild: text().primaryKey(),
channel: text().notNull(),
});
export type ColonThreeType = InferSelectModel<typeof colonTable>;

View File

@ -28,11 +28,16 @@ export class MemberEvents {
await member.roles.add(botRole);
}
} else {
if(Date.now() - member.user.createdAt.getTime() < 1000 * 60 * 60 * 24 * 7) {
if (
Date.now() - member.user.createdAt.getTime() <
1000 * 60 * 60 * 24 * 7
) {
try {
await member.send("to protect against raids, bots, and other disturbances, accounts under a week old are kicked upon joining. please wait for your account to mature before rejoining.")
await member.send(
"to protect against raids, bots, and other disturbances, accounts under a week old are kicked upon joining. please wait for your account to mature before rejoining.",
);
} catch (_) {}
await member.kick("account less than week old")
await member.kick("account less than week old");
return;
}
await db.insert(colonTable).values({

View File

@ -2,7 +2,6 @@ import { Client, Discord, On, type ArgsOf } from "discordx";
import { underageCheck } from "../utils/underage";
import { bumpRemind } from "../utils/bump";
import { uptimeLoop } from "../utils/uptime-loop";
import { introCheck } from "../utils/intro-check";
@Discord()
export class Ready {
@ -20,6 +19,6 @@ export class Ready {
}
bumpRemind(client);
uptimeLoop(client);
introCheck(client);
//introCheck(client);
}
}

View File

@ -10,6 +10,7 @@ export const introCheck = async (client: Client) => {
for (const c of channelRes) {
const channel = client.channels.cache.get(c.channel) as TextChannel;
const guild = client.guilds.cache.get(c.guild);
await guild?.fetch();
const msgs = await channel.messages.fetch({ limit: 10 });
for (const m of msgs) {
if (!guild?.members.cache.has(m[1].author.id)) {