Added !resettoke command to tokebot
This commit is contained in:
parent
d9bab09d53
commit
6639cee8ca
|
|
@ -124,16 +124,12 @@ module.exports = class{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
relayUserChat(socket, msg, type, links){
|
//Base chat functions
|
||||||
const user = this.server.getSocketInfo(socket);
|
|
||||||
this.relayChat(user.user, user.flair, user.highLevel, msg, type, socket.chan, links)
|
|
||||||
}
|
|
||||||
|
|
||||||
relayChat(user, flair, highLevel, msg, type = 'chat', chan, links){
|
relayChat(user, flair, highLevel, msg, type = 'chat', chan, links){
|
||||||
this.server.io.in(chan).emit("chatMessage", {user, flair, highLevel, msg, type, links});
|
this.server.io.in(chan).emit("chatMessage", {user, flair, highLevel, msg, type, links});
|
||||||
}
|
}
|
||||||
|
|
||||||
relayServerWisper(socket, user, flair, highLevel, msg, type, links){
|
relayPrivateChat(socket, user, flair, highLevel, msg, type, links){
|
||||||
socket.emit("chatMessage", {user, flair, highLevel, msg, type, links});
|
socket.emit("chatMessage", {user, flair, highLevel, msg, type, links});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,18 +137,26 @@ module.exports = class{
|
||||||
this.server.io.emit("chatMessage", {user, flair, highLevel, msg, type, links});
|
this.server.io.emit("chatMessage", {user, flair, highLevel, msg, type, links});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//User Chat Functions
|
||||||
|
relayUserChat(socket, msg, type, links){
|
||||||
|
const user = this.server.getSocketInfo(socket);
|
||||||
|
this.relayChat(user.user, user.flair, user.highLevel, msg, type, socket.chan, links)
|
||||||
|
}
|
||||||
|
|
||||||
|
//Toke Chat Functions
|
||||||
relayTokeCallout(msg, links){
|
relayTokeCallout(msg, links){
|
||||||
this.relayGlobalChat("Tokebot", "", '∞', msg, "toke", links);
|
this.relayGlobalChat("Tokebot", "", '∞', msg, "toke", links);
|
||||||
}
|
}
|
||||||
|
|
||||||
relayTokeWhisper(socket, msg, links){
|
relayTokeWhisper(socket, msg, links){
|
||||||
this.relayServerWisper(socket, "Tokebot", "", '∞', msg, "tokewhisper", links);
|
this.relayPrivateChat(socket, "Tokebot", "", '∞', msg, "tokewhisper", links);
|
||||||
}
|
}
|
||||||
|
|
||||||
relayGlobalTokeWhisper(msg, links){
|
relayGlobalTokeWhisper(msg, links){
|
||||||
this.relayGlobalChat("Tokebot", "", '∞', msg, "tokewhisper", links);
|
this.relayGlobalChat("Tokebot", "", '∞', msg, "tokewhisper", links);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Announcement Functions
|
||||||
relayServerAnnouncement(msg, links){
|
relayServerAnnouncement(msg, links){
|
||||||
this.relayGlobalChat("Server", "", '∞', msg, "announcement", links);
|
this.relayGlobalChat("Server", "", '∞', msg, "announcement", links);
|
||||||
}
|
}
|
||||||
|
|
@ -166,6 +170,7 @@ module.exports = class{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Misc Functions
|
||||||
clearChat(chan, user){
|
clearChat(chan, user){
|
||||||
const activeChan = this.server.activeChannels.get(chan);
|
const activeChan = this.server.activeChannels.get(chan);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,24 @@ class commandProcessor{
|
||||||
//send it
|
//send it
|
||||||
this.chatHandler.relayServerAnnouncement(commandObj.message, commandObj.links);
|
this.chatHandler.relayServerAnnouncement(commandObj.message, commandObj.links);
|
||||||
|
|
||||||
|
//disble send flag
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//throw send flag
|
//throw send flag
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async resettoke(commandObj, preprocessor){
|
||||||
|
//Check if the user has permission, and publicly shame them if they don't (lmao)
|
||||||
|
if(await permissionModel.permCheck(commandObj.socket.user, 'resetToke')){
|
||||||
|
//Acknowledge command
|
||||||
|
this.chatHandler.relayTokeWhisper(commandObj.socket, 'Toke cooldown reset.');
|
||||||
|
|
||||||
|
//Tell tokebot to reset the toke
|
||||||
|
preprocessor.tokebot.resetToke();
|
||||||
|
|
||||||
|
//disable send flag
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,7 +246,7 @@ class commandProcessor{
|
||||||
if(await chanDB.permCheck(commandObj.socket.user, 'clearChat')){
|
if(await chanDB.permCheck(commandObj.socket.user, 'clearChat')){
|
||||||
//Send off the command
|
//Send off the command
|
||||||
this.chatHandler.clearChat(commandObj.socket.chan, commandObj.argumentArray[1]);
|
this.chatHandler.clearChat(commandObj.socket.chan, commandObj.argumentArray[1]);
|
||||||
//throw send flag
|
//disable send flag
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -176,4 +176,12 @@ module.exports = class tokebot{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetToke(){
|
||||||
|
//Set cooldown to 0
|
||||||
|
this.cooldownCounter = 0;
|
||||||
|
|
||||||
|
//Null out the timer
|
||||||
|
this.cooldownTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,12 @@ const permissionSchema = new mongoose.Schema({
|
||||||
default: "admin",
|
default: "admin",
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
resetToke: {
|
||||||
|
type: mongoose.SchemaTypes.String,
|
||||||
|
enum: rankEnum,
|
||||||
|
default: "admin",
|
||||||
|
required: true
|
||||||
|
},
|
||||||
editTokeCommands: {
|
editTokeCommands: {
|
||||||
type: mongoose.SchemaTypes.String,
|
type: mongoose.SchemaTypes.String,
|
||||||
enum: rankEnum,
|
enum: rankEnum,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue