init cummit
This commit is contained in:
commit
9f4cc0ca86
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
node_modules
|
||||
.env
|
||||
data
|
113
index.js
Normal file
113
index.js
Normal file
|
@ -0,0 +1,113 @@
|
|||
require('dotenv').config();
|
||||
|
||||
const { default: Log75, LogLevel } = require('log75');
|
||||
const logger = new Log75(process.env.NODE_ENV == 'production' ? LogLevel.Standard : LogLevel.Debug);
|
||||
|
||||
const Discord = require('discord.js');
|
||||
const client = new Discord.Client({ disableMentions: 'everyone' });
|
||||
|
||||
const Enmap = require('enmap');
|
||||
const activity = new Enmap();
|
||||
const enabled = new Enmap({ name: 'enabled' });
|
||||
|
||||
const prefix = process.env.PREFIX || '!!';
|
||||
|
||||
client.on('message', message => {
|
||||
try {
|
||||
if (!message.guild) return; // fuck DMs
|
||||
if (message.author.bot || message.author.id == client.user.id) return; // fuck bots
|
||||
|
||||
if (activity.get(message.channel.id) == undefined)
|
||||
activity.set(message.channel.id, 1);
|
||||
else
|
||||
activity.inc(message.channel.id);
|
||||
|
||||
logger.debug(`${message.channel.id} -> +1 => ${activity.get(message.channel.id)}`);
|
||||
setTimeout(() => {
|
||||
activity.dec(message.channel.id);
|
||||
logger.debug(`${message.channel.id} -> -1 => ${activity.get(message.channel.id)}`);
|
||||
}, 60000);
|
||||
|
||||
|
||||
// Handle the very epic command thingies
|
||||
let command = message.content?.startsWith(prefix) ?
|
||||
message.content
|
||||
?.toLowerCase()
|
||||
?.split(' ')[0]
|
||||
?.substr(prefix.length) :
|
||||
null;
|
||||
|
||||
if (
|
||||
command && (
|
||||
process.env.OWNERID ?
|
||||
message.author.id != process.env.OWNERID :
|
||||
!message.member.permissions.has('MANAGE_GUILD')
|
||||
)
|
||||
) return message.react(process.env.EMOJI_ID).catch(console.warn); // fuck people with no rights
|
||||
|
||||
switch(command) {
|
||||
case 'disable':
|
||||
case 'off':
|
||||
case 'die':
|
||||
case 'unalive':
|
||||
enabled.set(message.guild.id, false);
|
||||
message.channel.send(`**Disabled** the uber fruitening`);
|
||||
break;
|
||||
case 'enable':
|
||||
case 'on':
|
||||
case 'alive':
|
||||
case 'undie':
|
||||
enabled.set(message.guild.id, true);
|
||||
message.channel.send(`**Enabled** the uber fruitening`);
|
||||
break;
|
||||
}
|
||||
} catch(e) {
|
||||
logger.error('An error has occured.');
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
|
||||
// piss
|
||||
setInterval(() => {
|
||||
try {
|
||||
client.channels.cache.filter(c => c.type == 'text').forEach(async channel => {
|
||||
if (!(channel instanceof Discord.TextChannel)) return; // intellisense is wack
|
||||
|
||||
if (enabled.get(channel.guild.id) === false) return;
|
||||
|
||||
const randomNum = Math.round(Math.random() * 100);
|
||||
const channelActivity = activity.get(channel.id);
|
||||
|
||||
if (channelActivity > randomNum) {
|
||||
logger.debug(`${channel.id} -> Reaction triggered: ${channelActivity} > ${randomNum}`);
|
||||
const messages = await channel.messages.fetch({ limit: 12 });
|
||||
|
||||
messages.array()[Math.round(Math.random() * messages.size)]
|
||||
?.react(process.env.EMOJI_ID).catch(logger.warn)
|
||||
?.then(reaction => setTimeout(() => reaction.users.remove(client.user.id), Math.random() * 1500));
|
||||
}
|
||||
});
|
||||
} catch(e) {
|
||||
logger.error('An error has occured.');
|
||||
console.error(e);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
|
||||
// Login
|
||||
['TOKEN', 'EMOJI_ID', 'PREFIX', 'OWNERID'].forEach(i => process.env[i] ?? logger.warn(`Env var ${i} not found`));
|
||||
if (process.env.NODE_ENV != 'production') logger.info('Running in debug mode');
|
||||
client.login(process.env.TOKEN)
|
||||
.catch(e => { logger.error(`Login failed: ${e}`); process.exit(1) });
|
||||
|
||||
client.once('ready', () => {
|
||||
logger.done(`Logged in`);
|
||||
logger.info(
|
||||
logger.table([
|
||||
`${client.user.tag}`,
|
||||
`Cached users: ${client.users.cache.size}\n` +
|
||||
`Cached guilds: ${client.guilds.cache.size}`
|
||||
])
|
||||
);
|
||||
});
|
||||
|
1515
package-lock.json
generated
Normal file
1515
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
17
package.json
Normal file
17
package.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "uberpiss",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"discord.js": "^12.5.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"enmap": "^5.8.4",
|
||||
"log75": "^2.0.1"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue