Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { Command } = require('discord.js-commando');
- const mongo = require('../../mongo');
- const WelcomeSchema = require('../../models/welcomeSchema');
- const cache = {}
- module.exports = class WelcomeSetCommand extends Command {
- constructor(client) {
- super(client, {
- name: 'setwelcome',
- group: 'server-config',
- memberName: 'setwelcome',
- description: 'A command that sets a welcome message.',
- userPermissions: ['ADMINISTRATOR'],
- args: [
- {
- key: 'message',
- prompt: 'What do want to say when a new user joins?',
- type: 'string'
- }
- ]
- })
- }
- async run (msg, { message }) {
- const { channel, guild } = msg;
- cache[guild.id] = [channel.id, message]
- await mongo().then(async (mongoose) => {
- try{
- await WelcomeSchema.findOneAndUpdate({
- _id: guild.id
- }, {
- _id: guild.id,
- channelId: channel.id,
- text: message
- }, {
- upsert: true
- })
- } finally{
- mongoose.connection.close()
- }
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement