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

43 lines
1.6 KiB
JavaScript

const { Command } = require('discord-akairo');
const fs = require('fs');
6 years ago
class shameboardCommand extends Command {
constructor() {
6 years ago
super('shameboard', {
aliases: ['shameboard'],
category: 'admin',
channelRestriction: 'guild',
userPermissions: ['ADMINISTRATOR'],
description: {
6 years ago
content: 'Set shameboard',
usage: '[]',
examples: ['']
}
});
}
6 years ago
async exec(message) {
6 years ago
let shameboardChannel = message.channel.id;
6 years ago
fs.readFile(`./starboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
if (err){
6 years ago
fs.writeFile(`./starboard/${message.guild.id}.json`, `{"shameboard": "${shameboardChannel}"}`, function (err) {
if (err){
console.log(err);
}
6 years ago
return message.channel.send(`This channel have been set as the shameboard`);
})
} else {
6 years ago
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) {
return console.log(err);
}
})}});
6 years ago
return message.channel.send(`This channel have been set as the shameboard`);
}
}
6 years ago
module.exports = shameboardCommand;