various fixes to account model and intervals

merge-requests/4/head
Matthew 2020-03-28 12:10:58 -04:00
parent 23afdcdf90
commit febb9ee924
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
3 changed files with 61 additions and 59 deletions

View File

@ -16,10 +16,10 @@ export default class SecureSign_Account extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
const user = await this.client.db.Account.findOne({ userID: message.author.id }); const user = await this.client.db.Account.findOne({ userID: message.author.id });
if (!user || (!user.permissions.associate && !(message.channel instanceof PrivateChannel))) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Run this command in your DMs!***`); if (!user || (!user.permissions.staff && !(message.channel instanceof PrivateChannel))) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Run this command in your DMs!***`);
let account: AccountInterface; let account: AccountInterface;
if (!args[0] || !user.permissions.associate) account = user; if (!args[0] || !user.permissions.staff) account = user;
else account = await this.client.db.Account.findOne({ $or: [{ userID: args[0] }, { username: args[0] }, { emailAddress: args[0] }] }); else account = await this.client.db.Account.findOne({ $or: [{ userID: args[0] }, { username: args[0] }, { emailAddress: args[0] }] });
if (!account) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not found***`); if (!account) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not found***`);

View File

@ -13,7 +13,8 @@ export const memoryLimits = {
TIER_3_HARD: 550, TIER_3_HARD: 550,
}; };
export default async function memory(client: Client) { export default function memory(client: Client) {
setInterval(async () => {
const accounts = await client.db.Account.find(); const accounts = await client.db.Account.find();
for (const acc of accounts) { for (const acc of accounts) {
if (acc.root) return; if (acc.root) return;
@ -70,4 +71,5 @@ export default async function memory(client: Client) {
client.createMessage(channelID, { embed }); client.createMessage(channelID, { embed });
} }
} }
}, 300000);
} }

View File

@ -10,7 +10,7 @@ export interface AccountInterface extends Document {
locked: boolean, locked: boolean,
tier: number; tier: number;
permissions: { permissions: {
associate: boolean, staff: boolean,
sheriff: boolean, sheriff: boolean,
facultyMarshal: boolean, facultyMarshal: boolean,
}, },
@ -30,7 +30,7 @@ const Account: Schema = new Schema({
locked: Boolean, locked: Boolean,
tier: Number, tier: Number,
permissions: { permissions: {
associate: Boolean, staff: Boolean,
sheriff: Boolean, sheriff: Boolean,
facultyMarshal: Boolean, facultyMarshal: Boolean,
}, },