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.7 KiB
JavaScript

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