forked from kotarou3/Pokemon-Showdown-Addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoof.js
More file actions
40 lines (35 loc) · 1.21 KB
/
poof.js
File metadata and controls
40 lines (35 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const messages = [
"didn't get a cool message because none have been added!"
];
exports.commands = {
d: 'poof',
cpoof: 'poof',
poof: function (target, room, user) {
if (Config.poofOff) return this.sendReply("Poof is currently disabled.");
if (target && !this.can('broadcast')) return false;
if (room.id !== 'lobby') return false;
var message = target || messages[Math.floor(Math.random() * messages.length)];
if (message.indexOf('{{user}}') < 0) {
message = '{{user}} ' + message;
}
message = message.replace(/{{user}}/g, user.name);
if (!this.canTalk(message)) return false;
var colour = '#' + [1, 1, 1].map(function () {
var part = Math.floor(Math.random() * 0xaa);
return (part < 0x10 ? '0' : '') + part.toString(16);
}).join('');
room.addRaw('<center><strong><font color="' + colour + '">~~ ' + Tools.escapeHTML(message) + ' ~~</font></strong></center>');
user.disconnectAll();
},
poofoff: 'nopoof',
nopoof: function () {
if (!this.can('poofoff')) return false;
Config.poofOff = true;
return this.sendReply("Poof is now disabled.");
},
poofon: function () {
if (!this.can('poofoff')) return false;
Config.poofOff = false;
return this.sendReply("Poof is now enabled.");
}
};