Development (#30)

pull/38/head
Samuel Shuert 3 years ago committed by GitHub
commit 9d3b721228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -177,7 +177,7 @@ const runServer = (client: NucleusClient) => {
const id = req.params.id;
if (id === undefined) return res.status(400).send("No id provided");
const channel = await client.channels.fetch(id);
if (channel === null) return res.status(404).send("Could not find a channel by that id");
if (channel === null) return res.status(400).send("Could not find a channel by that id");
if (channel.isDMBased()) return res.status(400).send("Cannot get a DM channel");
return res.status(200).send(channel.name);
});

@ -327,11 +327,11 @@ const editTrack = async (
} else {
if (!current.track.includes(role)) {
current.track.push(role);
await interaction.editReply({ embeds: LoadingEmbed, components: [] });
} else {
previousMessage = "That role is already on this track";
}
}
await interaction.editReply({ embeds: LoadingEmbed, components: [] });
break;
}
}

@ -6,6 +6,7 @@ import getEmojiByName from "../utils/getEmojiByName.js";
import client from "../utils/client.js";
import { callback as statsChannelUpdate } from "../reflex/statsChannelUpdate.js";
import { ChannelType, Message, ThreadChannel } from "discord.js";
import singleNotify from "../utils/singleNotify.js";
export const event = "messageCreate";
@ -19,7 +20,11 @@ export async function callback(_client: NucleusClient, message: Message) {
message.channel.type === ChannelType.GuildAnnouncement &&
message.reference === null
) {
if(message.channel.permissionsFor(message.guild.members.me!)!.has("ManageMessages")) {
await message.crosspost();
} else {
singleNotify(`I don't have permissions to publish in <#${message.channel.id}>`, message.guild.id, true);
}
}
if (message.author.bot) return;

@ -16,6 +16,8 @@ client.on("ready", async () => {
client.fetchedCommands = await client.application?.commands.fetch()!;
}
await client.database.premium.checkAllPremium();
await client.database.guilds.updateAllGuilds();
});
process.on("unhandledRejection", (err) => {

@ -50,7 +50,7 @@ class NucleusClient extends Client {
> = {};
fetchedCommands = new Collection<string, Discord.ApplicationCommand>();
constructor(database: typeof NucleusClient.prototype.database) {
super({ intents: 0b1100011011011111111111 });
super({ intents: 3276543 });
this.database = database;
}
}

@ -46,6 +46,19 @@ export class Guilds {
return entry ?? {};
}
async updateAllGuilds() {
const guilds = await this.guilds.find().toArray();
for (const guild of guilds) {
let guildObj;
try {
guildObj = await client.guilds.fetch(guild.id);
} catch (e) {
guildObj = null;
}
if(!guildObj) await this.delete(guild.id);
}
}
async read(guild: string): Promise<GuildConfig> {
// console.log("Guild read")
const entry = await this.guilds.findOne({ id: guild });

Loading…
Cancel
Save