Skip to content

Commit f111ad0

Browse files
DB updates
1 parent 80b056a commit f111ad0

19 files changed

+74
-91
lines changed

.replit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
run = ["yarn", "start"]
1+
run = ["./node_modules/.bin/ts-node", "--esm", "index.ts"]
22

33
[nix]
44
channel = "stable-23_05"

commands/add.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export async function run(client: any, interaction: ChatInputCommandInteraction)
4343
try {
4444
const link: string = interaction.options.getString("link", true);
4545
const doc = await guildModel.findOne({
46-
GuildId: interaction.guild?.id
46+
GuildId: interaction.guild!.id
4747
});
4848
if(!doc) return interaction.reply({
4949
content: ClientMessages.ERR_SERVER_NOT_FOUND_ADMIN,
@@ -94,7 +94,7 @@ export async function run(client: any, interaction: ChatInputCommandInteraction)
9494
}
9595

9696
export async function autocomplete(client: any, interaction: AutocompleteInteraction) {
97-
const doc = await guildModel.findOne({ GuildId: interaction.guild?.id });
97+
const doc = await guildModel.findOne({ GuildId: interaction.guild!.id });
9898
if(!doc) return interaction.respond([]);
9999
const input = interaction.options.getFocused(true);
100100
var data: string[] = [];

commands/category.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function run(client: any, interaction: ChatInputCommandInteraction)
3636
try {
3737
const category = interaction.options.getString("category", true);
3838
const doc = await guildModel.findOne({
39-
GuildId: interaction.guild?.id
39+
GuildId: interaction.guild!.id
4040
});
4141
if (!doc) return interaction.reply({
4242
content: ClientMessages.ERR_SERVER_NOT_FOUND_ADMIN,
@@ -71,7 +71,7 @@ export async function run(client: any, interaction: ChatInputCommandInteraction)
7171
}
7272

7373
export async function autocomplete(client: any, interaction: AutocompleteInteraction) {
74-
const doc = await guildModel.findOne({ GuildId: interaction.guild?.id });
74+
const doc = await guildModel.findOne({ GuildId: interaction.guild!.id });
7575
if (!doc) return interaction.respond([]);
7676
const input: string = interaction.options.getFocused();
7777
const data: string[] = doc.types.filter((type) => type.startsWith(input));

commands/dm.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ export async function run(client: any, interaction: ChatInputCommandInteraction)
1818
const doc = await guildModel.findOne({ GuildId });
1919
if (!doc) return interaction.reply({ content: ClientMessages.ERR_SERVER_NOT_FOUND_ADMIN, ephemeral: true });
2020
const enable = interaction.options.getBoolean("enabled", true);
21-
const members: any = interaction.guild?.members.cache;
2221

23-
if (members.size < 100 && !doc.isPremium) return interaction.reply({ content: `DM mode is a premium feature for servers with more then 100 members. ${ClientMessages.ERR_NEED_PREMIUM}`, ephemeral: true });
22+
if (interaction.guild!.members.cache.size < 100 && !doc.isPremium) return interaction.reply({ content: `DM mode is a premium feature for servers with more then 100 members. ${ClientMessages.ERR_NEED_PREMIUM}`, ephemeral: true });
2423
doc.dmMode = enable;
2524
doc.save();
2625
interaction.reply({ content: `DM mode has been ${enable ? "enabled" : "disabled"}`, ephemeral: true });

commands/get-started.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ export const data = new SlashCommandBuilder()
88
.setDMPermission(false);
99

1010
export async function run(client: any, interaction: ChatInputCommandInteraction) {
11-
const model = await guildModel.findOne({ GuildId: interaction.guild?.id });
11+
const model = await guildModel.findOne({ GuildId: interaction.guild!.id });
1212
if(model) return interaction.reply({ content: "You have already set up Link Master!", ephemeral: true });
1313
await interaction.deferReply();
1414

1515
const newData = new guildModel({
16-
GuildId: interaction.guild?.id,
16+
GuildId: interaction.guild!.id,
1717
isPremium: false,
1818
dmMode: false,
19-
limit: 3,
20-
types: [],
21-
links: [],
19+
limit: 3
2220
});
2321
await newData.save();
2422
interaction.editReply("Set up! Thank you for using Link Master");

commands/help.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const tips: string[] = [
1111

1212
export async function run(client: any, interaction: ChatInputCommandInteraction) {
1313
const commandData = client.commands.map((c: SlashCommand) => c.data);
14+
1415
const slashCommandData = commandData
1516
.filter((command: any) => command instanceof SlashCommandBuilder)
1617
.map((c: any) => `\`${c.name}\``);

commands/limit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const data = new SlashCommandBuilder()
2727

2828
export async function run(client: any, interaction: ChatInputCommandInteraction) {
2929
const subcommand: string = interaction.options.getSubcommand();
30-
const doc = await guildModel.findOne({ GuildId: interaction.guild?.id });
30+
const doc = await guildModel.findOne({ GuildId: interaction.guild!.id });
3131
if (!doc) return interaction.reply({
3232
content: ClientMessages.ERR_SERVER_NOT_FOUND_ADMIN,
3333
ephemeral: true

commands/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const data = new SlashCommandBuilder()
99
.setDMPermission(false);
1010

1111
export async function run(client: any, interaction: CommandInteraction) {
12-
const doc = await guildModel.findOne({ GuildId: interaction.guild?.id });
12+
const doc = await guildModel.findOne({ GuildId: interaction.guild!.id });
1313
if (!doc) return interaction.reply({
1414
content: ClientMessages.ERR_SERVER_NOT_FOUND_ADMIN,
1515
ephemeral: true

commands/proxy.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export async function run(client: any, interaction: ChatInputCommandInteraction)
2626
try {
2727
data = await getProxy(interaction, category);
2828
} catch(error) {
29-
console.error(error);
3029
if(error instanceof ProxyError) return interaction.editReply({ content: error.message }); else return;
3130
}
3231
if(data.dm) {
@@ -41,7 +40,7 @@ export async function run(client: any, interaction: ChatInputCommandInteraction)
4140
}
4241

4342
export async function autocomplete(client: any, interaction: AutocompleteInteraction) {
44-
const doc = await guildModel.findOne({ GuildId: interaction.guild?.id });
43+
const doc = await guildModel.findOne({ GuildId: interaction.guild!.id });
4544
if(!doc) return interaction.respond([]);
4645
const input: string = interaction.options.getFocused();
4746
const data: string[] = doc.types.filter(type => type.startsWith(input));

commands/usage.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ export const data = new SlashCommandBuilder()
88
.setDMPermission(false);
99

1010
export async function run(client: any, interaction: ChatInputCommandInteraction) {
11-
// @ts-ignore
12-
const gid: string = interaction.guild.id;
11+
const gid: string = interaction.guild!.id;
1312
const doc = await guildModel.findOne({ GuildId: gid });
1413
if(!doc) return interaction.reply({
1514
content: ClientMessages.ERR_SERVER_NOT_FOUND,
@@ -20,15 +19,15 @@ export async function run(client: any, interaction: ChatInputCommandInteraction)
2019
content: ClientMessages.ERR_YOU_HAVE_NOT_USED_BOT,
2120
ephemeral: true
2221
});
23-
if(!user.guilds[gid]) return interaction.reply({
22+
if(!user.guilds.has(gid)) return interaction.reply({
2423
content: ClientMessages.ERR_YOU_HAVE_NOT_USED_BOT,
2524
ephemeral: true
2625
});
27-
28-
const links: string = user.guilds[gid].links.slice(0, doc.limit).join("\n");
26+
const userGuild = user.guilds.get(gid)!;
27+
const links: string = userGuild.links.slice(0, doc.limit).join("\n");
2928
const embed = new EmbedBuilder()
3029
.addFields([
31-
{ name: "Curent Usage", value: `${user.guilds[gid].uses} (out of ${doc.limit})` },
30+
{ name: "Curent Usage", value: `${userGuild.uses} (out of ${doc.limit})` },
3231
{ name: `Last ${doc.limit} links`, value: links }
3332
]);
3433
interaction.reply({ embeds: [embed], ephemeral: true });

0 commit comments

Comments
 (0)