Advertisement
Guest User

welcome.js

a guest
May 10th, 2021
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. const { Command } = require('discord.js-commando');
  2. const mongo = require('../../mongo');
  3. const WelcomeSchema = require('../../models/welcomeSchema');
  4.  
  5. const cache = {}
  6.  
  7. module.exports = class WelcomeSetCommand extends Command {
  8. constructor(client) {
  9. super(client, {
  10. name: 'setwelcome',
  11. group: 'server-config',
  12. memberName: 'setwelcome',
  13. description: 'A command that sets a welcome message.',
  14. userPermissions: ['ADMINISTRATOR'],
  15. args: [
  16. {
  17. key: 'message',
  18. prompt: 'What do want to say when a new user joins?',
  19. type: 'string'
  20. }
  21. ]
  22. })
  23. }
  24.  
  25. async run (msg, { message }) {
  26. const { channel, guild } = msg;
  27.  
  28. cache[guild.id] = [channel.id, message]
  29.  
  30. await mongo().then(async (mongoose) => {
  31. try{
  32. await WelcomeSchema.findOneAndUpdate({
  33. _id: guild.id
  34. }, {
  35. _id: guild.id,
  36. channelId: channel.id,
  37. text: message
  38. }, {
  39. upsert: true
  40. })
  41. } finally{
  42. mongoose.connection.close()
  43. }
  44. })
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement