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/ data/
*.patch *.patch
built/ built/
.idea/

2
package.json

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

28
src/commands/train.ts

@ -17,13 +17,15 @@ export const data = new SlashCommandBuilder()
.setName('subject') .setName('subject')
.setDescription('Optional subject to be used as a filter') .setDescription('Optional subject to be used as a filter')
.setRequired(false) .setRequired(false)
.addChoice('astro', 'astro') .addChoices(
.addChoice('bio', 'bio') { name: 'astro', value: 'astro' },
.addChoice('ess', 'ess') { name: 'bio', value: 'bio' },
.addChoice('chem', 'chem') { name: 'chem', value: 'chem' },
.addChoice('phys', 'phys') { name: 'ess', value: 'ess' },
.addChoice('math', 'math') { name: 'phys', value: 'phys' },
.addChoice('energy', 'energy') { name: 'math', value: 'math' },
{ name: 'energy', value: 'energy' },
)
.setRequired(false); .setRequired(false);
return option; 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 subject = interaction.options.get('subject') ? interaction.options.get('subject')?.value : null;
const authorId = interaction.user.id; const authorId = interaction.user.id;
let score; let score: number;
userScore userScore
.findOne({ authorID: authorId }) .findOne({ authorID: authorId })
.lean() .lean()
.then((obj, err) => { .then((obj: { score: number; }, err: unknown) => {
if (!obj) { if (!obj) {
score = 0; 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) { else if (obj) {
score = obj.score; score = obj.score;

8
src/index.ts

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

1224
yarn.lock

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