-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'developClientDiscord' into develop
- Loading branch information
Showing
11 changed files
with
347 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,59 @@ | ||
const { Events } = require("discord.js"); | ||
let timeout = 1000; | ||
|
||
function randomIntFromInterval(min, max) { | ||
// min and max included | ||
return Math.floor(Math.random() * (max - min + 1) + min); | ||
} | ||
|
||
async function activity(client) { | ||
const randomActivity = randomIntFromInterval(0, 25); | ||
switch (randomActivity) { | ||
case 0: | ||
client.user.setActivity("My name is Karoline"); | ||
timeout = randomIntFromInterval(60, 120) * 1000; | ||
break; | ||
|
||
case 1: | ||
client.user.setActivity("My name is Glados"); | ||
timeout = randomIntFromInterval(60, 120) * 1000; | ||
break; | ||
|
||
case 2: | ||
client.user.setActivity("My name is Connor"); | ||
timeout = randomIntFromInterval(60, 120) * 1000; | ||
break; | ||
|
||
case 3: | ||
client.user.setActivity("My name is Marcus"); | ||
timeout = randomIntFromInterval(60, 120) * 1000; | ||
break; | ||
|
||
case 4: | ||
client.user.setActivity("My name is Car (Tut tut)"); | ||
timeout = randomIntFromInterval(60, 120) * 1000; | ||
break; | ||
|
||
default: | ||
client.user.setActivity("My name is Kara"); | ||
timeout = randomIntFromInterval(300, 3600) * 1000; | ||
break; | ||
} | ||
return; | ||
} | ||
|
||
module.exports.run = async (client) => { | ||
client.on(Events.ClientReady, () => { | ||
client.on(Events.ClientReady, async () => { | ||
console.log(`Logged in as ${client.user.tag} !\n`); | ||
|
||
client.user.setActivity("My name is Kara"); | ||
await activity(client); | ||
while (true) { | ||
await new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
resolve(); | ||
}, timeout); | ||
}); | ||
await activity(client); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { Events } = require("discord.js"); | ||
const updateUser = require("../utils/updateUser").updateUser; | ||
|
||
module.exports.run = async (client) => { | ||
client.on(Events.UserUpdate, (oldUser, newUser) => { | ||
const userName = newUser.username; | ||
const userId = newUser.id; | ||
const oldAvatar = oldUser.avatar; | ||
const newAvatar = newUser.avatar; | ||
if (oldAvatar !== newAvatar) { | ||
const avatarUrl = newAvatar ? `https://cdn.discordapp.com/avatars/${userId}/${newAvatar}.webp` : null; | ||
updateUser({ userName: userName, userId: userId, data: { discordAvatarUrl: avatarUrl } }); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const NodeRSA = require("node-rsa"); | ||
|
||
module.exports.encryptData = encryptData; | ||
async function encryptData({ data, publicKey }) { | ||
try { | ||
const keyPublic = new NodeRSA(publicKey); | ||
data.date = new Date().toUTCString(); | ||
const passPhraseEncrypted = keyPublic.encrypt(JSON.stringify(data), "base64"); | ||
return passPhraseEncrypted; | ||
} catch { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.