forked from Supositware/Haha-Yes
fixed starboard
This commit is contained in:
parent
d0bf43d7e9
commit
05567ef75e
2 changed files with 23 additions and 58 deletions
|
@ -1,62 +1,43 @@
|
|||
const { Command } = require('discord-akairo');
|
||||
const fs = require('fs');
|
||||
|
||||
class shameboardCommand extends Command {
|
||||
class shamoeboardCommand extends Command {
|
||||
constructor() {
|
||||
super('shameboard', {
|
||||
aliases: ['shameboard'],
|
||||
super('shamoeboard', {
|
||||
aliases: ['shamoeboard'],
|
||||
category: 'admin',
|
||||
channelRestriction: 'guild',
|
||||
args: [
|
||||
{
|
||||
id: 'delete',
|
||||
type: 'string'
|
||||
}
|
||||
],
|
||||
userPermissions: ['ADMINISTRATOR'],
|
||||
description: {
|
||||
content: 'Set shameboard',
|
||||
content: 'Set shamoeboard',
|
||||
usage: '[]',
|
||||
examples: ['']
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async exec(message, args) {
|
||||
let shameboardChannel = message.channel.id;
|
||||
async exec(message) {
|
||||
let shamoeboardChannel = message.channel.id;
|
||||
|
||||
|
||||
|
||||
fs.readFile(`./starboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||
fs.readFile(`./shamoeboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||
if (err){
|
||||
fs.writeFile(`./starboard/${message.guild.id}.json`, `{"shameboard": "${shameboardChannel}"}`, function (err) {
|
||||
fs.writeFile(`./shamoeboard/${message.guild.id}.json`, `{"shamoeboard": "${shamoeboardChannel}"}`, function (err) {
|
||||
if (err){
|
||||
console.log(err);
|
||||
}
|
||||
return message.channel.send(`This channel have been set as the shameboard`);
|
||||
return message.channel.send(`This channel have been set as the shamoeboard`);
|
||||
})
|
||||
} else {
|
||||
if (args.delete == 'delete') {
|
||||
let shameboard = JSON.parse(data); //now it an object
|
||||
shameboard ['shameboard'] = '';
|
||||
var json = JSON.stringify(shameboard); //convert it back to json
|
||||
var deleteBoard = true;
|
||||
} 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) {
|
||||
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);
|
||||
}
|
||||
})}});
|
||||
if (deleteBoard)
|
||||
return message.channel.send('The shameboard have been deleted');
|
||||
else
|
||||
return message.channel.send(`This channel have been set as the shameboard`);
|
||||
return message.channel.send(`This channel have been set as the shamoeboard`);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = shameboardCommand;
|
||||
module.exports = shamoeboardCommand;
|
|
@ -7,12 +7,6 @@ class StarBoardCommand extends Command {
|
|||
aliases: ['starboard'],
|
||||
category: 'admin',
|
||||
channelRestriction: 'guild',
|
||||
args: [
|
||||
{
|
||||
id: 'delete',
|
||||
type: 'string'
|
||||
}
|
||||
],
|
||||
userPermissions: ['ADMINISTRATOR'],
|
||||
description: {
|
||||
content: 'Set starboard',
|
||||
|
@ -22,7 +16,7 @@ class StarBoardCommand extends Command {
|
|||
});
|
||||
}
|
||||
|
||||
async exec(message, args) {
|
||||
async exec(message) {
|
||||
let starboardChannel = message.channel.id;
|
||||
|
||||
fs.readFile(`./starboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||
|
@ -33,25 +27,15 @@ class StarBoardCommand extends Command {
|
|||
}
|
||||
return message.channel.send(`This channel have been set as the starboard`);
|
||||
})
|
||||
} else {
|
||||
if (args.delete == 'delete') {
|
||||
let starboard = JSON.parse(data); //now it an object
|
||||
starboard ['starboard'] = '';
|
||||
var json = JSON.stringify(starboard); //convert it back to json
|
||||
var deleteBoard = true;
|
||||
} else {
|
||||
let starboard = JSON.parse(data); //now it an object
|
||||
starboard ['starboard'] = starboardChannel;
|
||||
var json = JSON.stringify(starboard); //convert it back to json
|
||||
}
|
||||
fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function(err) {
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
})}});
|
||||
if (deleteBoard)
|
||||
return message.channel.send('The starboard have been deleted')
|
||||
else
|
||||
return message.channel.send(`This channel have been set as the starboard`);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue