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 { Command } = require('discord-akairo');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
class shameboardCommand extends Command {
|
class shamoeboardCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('shameboard', {
|
super('shamoeboard', {
|
||||||
aliases: ['shameboard'],
|
aliases: ['shamoeboard'],
|
||||||
category: 'admin',
|
category: 'admin',
|
||||||
channelRestriction: 'guild',
|
channelRestriction: 'guild',
|
||||||
args: [
|
|
||||||
{
|
|
||||||
id: 'delete',
|
|
||||||
type: 'string'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
userPermissions: ['ADMINISTRATOR'],
|
userPermissions: ['ADMINISTRATOR'],
|
||||||
description: {
|
description: {
|
||||||
content: 'Set shameboard',
|
content: 'Set shamoeboard',
|
||||||
usage: '[]',
|
usage: '[]',
|
||||||
examples: ['']
|
examples: ['']
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message) {
|
||||||
let shameboardChannel = message.channel.id;
|
let shamoeboardChannel = message.channel.id;
|
||||||
|
|
||||||
|
fs.readFile(`./shamoeboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||||
|
|
||||||
fs.readFile(`./starboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
|
||||||
if (err){
|
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){
|
if (err){
|
||||||
console.log(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 {
|
} else {
|
||||||
if (args.delete == 'delete') {
|
let shamoeboard = JSON.parse(data); //now it an object
|
||||||
let shameboard = JSON.parse(data); //now it an object
|
shamoeboard ['shamoeboard'] = shamoeboardChannel;
|
||||||
shameboard ['shameboard'] = '';
|
var json = JSON.stringify(shamoeboard); //convert it back to json
|
||||||
var json = JSON.stringify(shameboard); //convert it back to json
|
fs.writeFile(`./shamoeboard/${message.guild.id}.json`, json, 'utf8', function(err) {
|
||||||
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) {
|
|
||||||
if(err) {
|
if(err) {
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
})}});
|
})}});
|
||||||
if (deleteBoard)
|
return message.channel.send(`This channel have been set as the shamoeboard`);
|
||||||
return message.channel.send('The shameboard have been deleted');
|
|
||||||
else
|
|
||||||
return message.channel.send(`This channel have been set as the shameboard`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = shameboardCommand;
|
module.exports = shamoeboardCommand;
|
|
@ -7,12 +7,6 @@ class StarBoardCommand extends Command {
|
||||||
aliases: ['starboard'],
|
aliases: ['starboard'],
|
||||||
category: 'admin',
|
category: 'admin',
|
||||||
channelRestriction: 'guild',
|
channelRestriction: 'guild',
|
||||||
args: [
|
|
||||||
{
|
|
||||||
id: 'delete',
|
|
||||||
type: 'string'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
userPermissions: ['ADMINISTRATOR'],
|
userPermissions: ['ADMINISTRATOR'],
|
||||||
description: {
|
description: {
|
||||||
content: 'Set starboard',
|
content: 'Set starboard',
|
||||||
|
@ -22,7 +16,7 @@ class StarBoardCommand extends Command {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message) {
|
||||||
let starboardChannel = message.channel.id;
|
let starboardChannel = message.channel.id;
|
||||||
|
|
||||||
fs.readFile(`./starboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
fs.readFile(`./starboard/${message.guild.id}.json`, 'utf8', function readFileCallback(err, data){
|
||||||
|
@ -34,24 +28,14 @@ class StarBoardCommand extends Command {
|
||||||
return message.channel.send(`This channel have been set as the starboard`);
|
return message.channel.send(`This channel have been set as the starboard`);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (args.delete == 'delete') {
|
let starboard = JSON.parse(data); //now it an object
|
||||||
let starboard = JSON.parse(data); //now it an object
|
starboard ['starboard'] = starboardChannel;
|
||||||
starboard ['starboard'] = '';
|
var json = JSON.stringify(starboard); //convert it back to json
|
||||||
var json = JSON.stringify(starboard); //convert it back to json
|
fs.writeFile(`./starboard/${message.guild.id}.json`, json, 'utf8', function(err) {
|
||||||
var deleteBoard = true;
|
if(err) {
|
||||||
} else {
|
return console.log(err);
|
||||||
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`);
|
return message.channel.send(`This channel have been set as the starboard`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue