Skip to content

Commit

Permalink
Merge pull request #5 from akargl/FEATURE-selfoida
Browse files Browse the repository at this point in the history
Feature selfoida
  • Loading branch information
akargl authored Jan 25, 2021
2 parents 7d9a77a + c9a3d9c commit 1fa395b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
12 changes: 9 additions & 3 deletions commands/oida.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const fs = require("fs");
module.exports = {
name: "oida",
description: "Oida a user.",
cooldown: 15 * 60,
//cooldown: 15 * 60,

execute(message, args) {
execute(message, args, client) {
if (!args.length) {
return message.reply("Heast, wen soll i oidaen?");
}
Expand All @@ -21,6 +21,12 @@ module.exports = {
lookupKey = username.toLowerCase();
}

if (client.settings.userIdsWithSelfOida.includes(message.author.id) &&
Math.random() <= client.settings.selfOidaChance) {
lookupKey = message.author.id;
username = message.author.username;
}

if (!this.oidaCount.hasOwnProperty(lookupKey)) {
this.oidaCount[lookupKey] = { oidaCount: 0 };
}
Expand All @@ -38,4 +44,4 @@ module.exports = {
console.warn("Couldn't open oidacount.json");
}
},
};
};
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const fs = require("fs");
const prettyMilliseconds = require("pretty-ms");
const client = new Client();

client.settings = JSON.parse(fs.readFileSync("settings.json", "utf8"));

client.commands = new Collection();
client.commandAliases = new Collection();
fs.readdirSync("./commands")
Expand Down Expand Up @@ -81,7 +83,7 @@ client.on("message", message => {
}

try {
command.execute(message, args);
command.execute(message, args, client);
} catch (error) {
console.error(error);
return message.reply("There was an error executing that command!");
Expand All @@ -95,14 +97,13 @@ client.on("presenceUpdate", (oldMember, newMember) => {
if (!oldMember) {
return;
}
const settings = JSON.parse(fs.readFileSync("settings.json", "utf8"));

const id = oldMember.id;

if (settings.monitoredBots.hasOwnProperty(id)) {
if (client.settings.monitoredBots.hasOwnProperty(id)) {
let botChannel = newMember.guild.defaultChannel;
if (settings.defaultChannels.hasOwnProperty(newMember.guild.id)) {
botChannel = client.channels.get(settings.defaultChannels[newMember.guild.id]);
if (client.settings.defaultChannels.hasOwnProperty(newMember.guild.id)) {
botChannel = client.channels.get(client.settings.defaultChannels[newMember.guild.id]);
}

if (!botChannel) {
Expand All @@ -127,8 +128,8 @@ client.on("presenceUpdate", (oldMember, newMember) => {
botUptimes.set(id, now);
} else if (oldMember.presence.status !== "offline" && newMember.presence.status === "offline") {
let msg = `OnO, ${newMember.displayName} is gone`;
if (settings.monitoredBots[id].pingOwner) {
msg += ` <@${settings.monitoredBots[id].ownerId}>.`;
if (client.settings.monitoredBots[id].pingOwner) {
msg += ` <@${client.settings.monitoredBots[id].ownerId}>.`;
}
if (duration) {
msg += ` Uptime was ${duration}.`;
Expand Down
9 changes: 8 additions & 1 deletion settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@
"defaultChannels": {
"569945613396082718": "570391301191761972",
"337519743345098763": "337519743345098763"
}
},

"userIdsWithSelfOida": [
"227081230540079104",
"219113680292413441",
"267717213316841473"
],
"selfOidaChance": 0.5
}

0 comments on commit 1fa395b

Please sign in to comment.