You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Haha-Yes/commands/admin/shameboard.js

48 lines
1.7 KiB
JavaScript

const { Command } = require('discord-akairo');
const fs = require('fs');
5 years ago
class shameboardCommand extends Command {
constructor() {
5 years ago
super('shameboard', {
aliases: ['shameboard'],
category: 'admin',
channelRestriction: 'guild',
userPermissions: ['ADMINISTRATOR'],
description: {
5 years ago
content: 'Set shameboard',
usage: '[]',
examples: ['']
}
});
}
5 years ago
async exec(message) {
5 years ago
let shameboardChannel = message.channel.id;
fs.readFile(`./starboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) {
if (err) {
fs.writeFile(`./starboard/${message.guild.id}.json`, `{"shameboard": "${shameboardChannel}"}`, function (err) {
if (err) {
console.log(err);
}
fs.close();
return message.channel.send(`This channel have been set as the shameboard`);
})
} else {
let shameboard = JSON.parse(data); //now it an object
shameboard['shameboard'] = shameboardChannel;
var json = JSON.stringify(shameboard); //convert it back to json
fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function (err) {
if (err) {
fs.close();
return console.log(err);
}
})
}
});
fs.close();
return message.channel.send(`This channel have been set as the shameboard`);
}
}
5 years ago
module.exports = shameboardCommand;