-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
18 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { ChatInputCommandInteraction } from "discord.js" | ||
import { plugins } from "@/discord" | ||
|
||
export default { | ||
name: 'mongodb', | ||
|
@@ -18,22 +19,24 @@ export default { | |
}, | ||
], | ||
run: async (interaction: ChatInputCommandInteraction) => { | ||
const show = interaction.options.getBoolean('show') | ||
const user = interaction.options.getString('user') | ||
const mongodb = plugins.get('mongodb') | ||
|
||
if ( | ||
!client.mongodb | ||
!mongodb | ||
) | ||
return interaction.followUp({ content: `> 🤯 MongoDB plugin not loaded` }); | ||
|
||
const { models } = await client.mongodb | ||
const { models } = await mongodb; | ||
|
||
const show = interaction.options.getBoolean('show') | ||
const user = interaction.options.getString('user') | ||
|
||
if ( | ||
show | ||
) { | ||
const users = await models.User.find() | ||
|
||
return interaction.followUp({ content: `> 😉 Users: ${users.map(u => u.username).join(', ') || 'No users in the db'}` }) | ||
return interaction.followUp({ content: `> 😉 Users: ${users.map((u: any) => u.username).join(', ') || 'No users in the db'}` }) | ||
} | ||
|
||
if ( | ||
|
@@ -44,14 +47,14 @@ export default { | |
|
||
if ( | ||
!username | ||
) return interaction.followUp({ content: `> 🤯 You need to provide a username` }) | ||
) return interaction.followUp({ content: `> 🩻 You need to provide a username` }) | ||
|
||
const newUser = new models.User({ username, email: email || '[email protected]' }) | ||
await newUser.save() | ||
|
||
return interaction.followUp({ content: `> 🚀 User added: ${username}` }) | ||
} | ||
|
||
return interaction.followUp({ content: `> 🤯 This is not how you should use the command >:(` }) | ||
return interaction.followUp({ content: `> 🤨 This is not how you should use the command >:(` }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters