Browse Source

Merge branch 'master' into development

development
Abheek Dhawan 2 years ago
parent
commit
717e3838a9
Signed by: abheekd GPG Key ID: 7BE81B8C14475B67
  1. 1
      .gitignore
  2. 2
      package.json
  3. 28
      src/commands/train.ts
  4. 8
      src/index.ts
  5. 1224
      yarn.lock

1
.gitignore

@ -13,3 +13,4 @@ config.json
data/
*.patch
built/
.idea/

2
package.json

@ -17,7 +17,7 @@
"typescript": "^4.6.2"
},
"name": "awesomescibo",
"version": "4.6.0",
"version": "4.6.3",
"scripts": {
"build": "yarn tsc"
},

28
src/commands/train.ts

@ -17,13 +17,15 @@ export const data = new SlashCommandBuilder()
.setName('subject')
.setDescription('Optional subject to be used as a filter')
.setRequired(false)
.addChoice('astro', 'astro')
.addChoice('bio', 'bio')
.addChoice('ess', 'ess')
.addChoice('chem', 'chem')
.addChoice('phys', 'phys')
.addChoice('math', 'math')
.addChoice('energy', 'energy')
.addChoices(
{ name: 'astro', value: 'astro' },
{ name: 'bio', value: 'bio' },
{ name: 'chem', value: 'chem' },
{ name: 'ess', value: 'ess' },
{ name: 'phys', value: 'phys' },
{ name: 'math', value: 'math' },
{ name: 'energy', value: 'energy' },
)
.setRequired(false);
return option;
});
@ -33,13 +35,21 @@ export async function execute(interaction : CommandInteraction) {
const subject = interaction.options.get('subject') ? interaction.options.get('subject')?.value : null;
const authorId = interaction.user.id;
let score;
let score: number;
userScore
.findOne({ authorID: authorId })
.lean()
.then((obj, err) => {
.then((obj: { score: number; }, err: unknown) => {
if (!obj) {
score = 0;
const firstTimeEmbed = new MessageEmbed()
.setAuthor({ name: interaction.client.user?.tag ? interaction.client.user?.tag : '', iconURL: interaction.client.user?.displayAvatarURL() })
.setDescription('Hey! It seems like it\'s your first time using AwesomeSciBo. Here\'s some information regarding the bot if you need it (for issues, contributions, etc.):')
.addField('Creator', '<@745063586422063214> [@abheekd#3602]')
.addField('GitHub', '[Link](https://github.com/ADawesomeguy/AwesomeSciBo) (a star couldn\'t hurt...)')
.setColor('#ffffff')
.setTimestamp();
interaction.user.send({ embeds: [firstTimeEmbed] });
}
else if (obj) {
score = obj.score;

8
src/index.ts

@ -11,11 +11,11 @@ const client = new Client({
client['commands'] = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
const commandFiles = fs.readdirSync(`${__dirname}/commands`).filter(file => file.endsWith('.js'));
const eventFiles = fs.readdirSync(`${__dirname}/events`).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
import(`./commands/${file}`)
import(`${__dirname}/commands/${file}`)
.then(command => {
client['commands'].set(command.data.name, command);
log({ logger: 'command', content: `Registered command ${file}!`, level: 'info' });
@ -23,7 +23,7 @@ for (const file of commandFiles) {
}
for (const file of eventFiles) {
import(`./events/${file}`)
import(`${__dirname}/events/${file}`)
.then(event => {
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));

1224
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save