forked from Supositware/Haha-Yes
Merge branch 'master' of https://gitlab.com/loicbersier/discordbot
This commit is contained in:
commit
ffaa215ca6
2 changed files with 49 additions and 30 deletions
|
@ -48,7 +48,7 @@ class userInfoCommand extends Command {
|
|||
if (user.presence.activity) Embed.addField('Presence', user.presence.activity, true);
|
||||
|
||||
// Is the user a bot?
|
||||
if (user.bot) Embed.addField('Is a bot?', '✅', true); else if (!user.bot) Embed.addField('Is a bot?', '❌', true);
|
||||
if (user.bot) Embed.addField('Is a bot?', '✅', true);
|
||||
|
||||
// Show guild nickname
|
||||
if (member.nickname) Embed.addField('Nickname', member.nickname, true);
|
||||
|
|
|
@ -33,44 +33,63 @@ class ReadyListener extends Listener {
|
|||
console.log(`${this.client.readyAt}`);
|
||||
|
||||
//Bot status
|
||||
if (Math.floor((Math.random() * 2) + 1) == 1) {
|
||||
setStatus(this.client);
|
||||
// Change status every 30 minutes
|
||||
setInterval(async () => {
|
||||
setStatus(this.client);
|
||||
}, 1800000);
|
||||
|
||||
async function setStatus(client) {
|
||||
let owner = client.users.get(client.ownerID);
|
||||
let random = Math.floor((Math.random() * 3));
|
||||
if (random == 0) { // Random "Watching" status taken from json
|
||||
console.log('Status type: \x1b[32mWatching\x1b[0m');
|
||||
|
||||
let status = watch[Math.floor((Math.random() * watch.length))];
|
||||
status = status.replace('${prefix}', prefix[0]);
|
||||
|
||||
this.client.user.setActivity(`${status} | My prefix is: ${prefix[0]} `, { type: 'WATCHING' });
|
||||
} else {
|
||||
client.user.setActivity(`${status} | My prefix is: ${prefix[0]} `, { type: 'WATCHING' });
|
||||
} else if (random == 1) { // Random "Playing" status taken from json
|
||||
console.log('Status type: \x1b[32mPlaying\x1b[0m');
|
||||
|
||||
let status = game[Math.floor((Math.random() * game.length))];
|
||||
status = status.replace('${prefix}', prefix[0]);
|
||||
|
||||
this.client.user.setActivity(`${status} | My prefix is: ${prefix[0]}`, { type: 'PLAYING' });
|
||||
client.user.setActivity(`${status} | My prefix is: ${prefix[0]}`, { type: 'PLAYING' });
|
||||
} else if (random == 2 && owner.presence.activity != null) { // Bot owner status
|
||||
console.log('Status type: \x1b[32mCopying owner status\x1b[0m');
|
||||
// Get elapsed time from when the activity started
|
||||
let diffMins = 0;
|
||||
if (owner.presence.activity.timestamps) {
|
||||
let diffMs = (new Date() - owner.presence.activity.timestamps.start);
|
||||
diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000);
|
||||
}
|
||||
client.user.setActivity(`${owner.presence.activity.name}\nfor ${diffMins} minutes | My prefix is: ${prefix[0]}`, owner.presence.activity);
|
||||
} else { // Random user statuss
|
||||
console.log('Status type: \x1b[32mCopying random user status\x1b[0m');
|
||||
let randomuser = client.users.random();
|
||||
// If the random user have no activity or is a bot pick a new user
|
||||
while (randomuser.presence.activity == null || randomuser.presence.activity.type == 'CUSTOM_STATUS' || randomuser.bot) {
|
||||
randomuser = client.users.random();
|
||||
}
|
||||
|
||||
// Get elapsed time from when the activity started
|
||||
let diffMins = 0;
|
||||
if (randomuser.presence.activity.timestamps) {
|
||||
let diffMs = (new Date() - randomuser.presence.activity.timestamps.start);
|
||||
diffMins = Math.round(((diffMs % 86400000) % 3600000) / 60000);
|
||||
}
|
||||
|
||||
client.user.setActivity(`${randomuser.username} is ${randomuser.presence.activity.type.toLowerCase()} ${randomuser.presence.activity.name}\nfor ${diffMins} minutes | My prefix is: ${prefix[0]}`, { type: randomuser.presence.activity.type, url: randomuser.presence.activity.url, name: randomuser.presence.activity.name });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If stats channel settings exist, send bot stats to it
|
||||
if (statsChannel) {
|
||||
const channel = this.client.channels.get(statsChannel);
|
||||
channel.send(`Ready to serve in ${channelSize} channels on ${guildSize} servers, for a total of ${userSize} users.\nThere is ${commandSize} command loaded\n${this.client.readyAt}`);
|
||||
}
|
||||
/*
|
||||
//Fetch messages in every channel ( so they can still enter starboard in case of reboot)
|
||||
let array = [];
|
||||
let channels = this.client.channels.array();
|
||||
for (const channel of channels.values()) {
|
||||
array.push(channel.id);
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.client.channels.size; i++) {
|
||||
let channel = this.client.channels.get(array[i]);
|
||||
if (channel.messages) {
|
||||
channel.messages.fetch({ limit: 10 })
|
||||
.then(messages => console.log(`Received ${messages.size} messages`))
|
||||
.catch(err => console.error(err));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Expose stats
|
||||
if (exposeStats) {
|
||||
|
|
Loading…
Reference in a new issue