Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c6ef14ee70 |
|||
|
e68bb41960 |
|||
|
a6060cdbfb |
|||
|
6293010b6c |
|||
|
f4ffcbebde |
|||
|
2073a46715 |
|||
|
27fc1c55bf |
|||
|
8314be972f |
|||
|
ad73a83514 |
|||
|
40052ac85d |
|||
|
09eee1a0ca |
|||
|
340727ae60 |
|||
|
0a35549666 |
|||
|
9d0eb60b81 |
|||
|
d27c1bad55 |
23 changed files with 1140 additions and 1819 deletions
4
.github/workflows/CI.yml
vendored
4
.github/workflows/CI.yml
vendored
|
|
@ -16,6 +16,6 @@ jobs:
|
|||
with:
|
||||
node-version: 'latest'
|
||||
- name: install dependencies
|
||||
run: npm ci
|
||||
run: npm install
|
||||
- name: run tests
|
||||
run: npm test
|
||||
run: npm test
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
const calculateReloaded = require("../../util/calculateReloaded");
|
||||
const executeCommand = require("../../util/executeCommand");
|
||||
const reloadCommands = require("../../util/reloadCommands");
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -28,12 +27,10 @@ module.exports = {
|
|||
let commitCount = stdout.split(/\r\n|\r|\n/).length - 1
|
||||
sendText = `${sendText}\n\nLatest commits (${commitCount}):\n${stdout}`
|
||||
if(sendText.length >= 2000){
|
||||
sendText = sendText.slice(1955)
|
||||
sendText.slice(1955)
|
||||
sendText = `${sendText}\n... Message is too long to show everything`
|
||||
}
|
||||
message.channel.send(sendText)
|
||||
const githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]);
|
||||
client.githash = githash.error ? "N/A" : githash.output;
|
||||
if (err) console.log(stderr)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,10 @@ module.exports = {
|
|||
let descriptionArr = [`Name: ${client.user.username}`,
|
||||
`Prefix: ${prefix}`,
|
||||
`Total Servers: ${guildInfo.guildCount}`,
|
||||
`Total Members: ${guildInfo.totalMembers} (${guildInfo.uniqueMemberCount} unique)`,
|
||||
`Total Members: ${guildInfo.totalMembers}`,
|
||||
`Total Commands: ${client.commands.size}`,
|
||||
`Creation Date: ${getCreationDate(client)}`,
|
||||
`Source: [Click Here](https://github.com/SileNce5k/discord_bot)`,
|
||||
`Current Version: ${client.githash}`
|
||||
`Source: [Click Here](https://github.com/SileNce5k/discord_bot)`
|
||||
]
|
||||
|
||||
let description = "";
|
||||
|
|
|
|||
|
|
@ -1,103 +0,0 @@
|
|||
// Code is taken from https://github.com/stphnduvall/mcstatus/blob/master/src/index.ts
|
||||
// and converted to pure js.
|
||||
|
||||
const net = require('net')
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'mc',
|
||||
description: 'get minecraft server information',
|
||||
hidden: true,
|
||||
needsWhitelist: true,
|
||||
async execute({ message, args }) {
|
||||
let host = "";
|
||||
let port = 25565;
|
||||
if (args[0]) host = args[0];
|
||||
|
||||
if (host.includes(":")) {
|
||||
port = host.replace(/.+(?:\:)/g, "");
|
||||
host = host.match(/.+(?:\:)/g, "")[0].replace(":", "");
|
||||
}
|
||||
if(host === "") return message.channel.send("No host provided")
|
||||
let info = await getMinecraftServerInfo(host, port);
|
||||
if (info) {
|
||||
const embed = new EmbedBuilder()
|
||||
embed.setColor("#ee7939")
|
||||
embed.setTimestamp()
|
||||
embed.addFields(
|
||||
{ name: "ping", value: info.ping.toString(), inline: false },
|
||||
{ name: "Player Count", value: info.playercount.toString(), inline: false },
|
||||
{ name: "Max Players", value: info.maxPlayers.toString(), inline: false },
|
||||
{ name: "MOTD", value: info.motd, inline: false },
|
||||
)
|
||||
|
||||
message.channel.send({ embeds: [embed] });
|
||||
} else {
|
||||
message.channel.send("Something went wrong\nThe minecraft server is likely not reachable from the discord bot")
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
async function getMinecraftServerInfo(host, port = 25565) {
|
||||
let serverInfo = {
|
||||
ping: undefined,
|
||||
maxPlayers: undefined,
|
||||
version: undefined,
|
||||
playercount: undefined,
|
||||
motd: undefined
|
||||
}
|
||||
|
||||
let startTime = new Date();
|
||||
let data;
|
||||
let ping;
|
||||
serverInfo = await new Promise((resolve) => {
|
||||
const client = net.connect({ host, port }, () => {
|
||||
ping = Math.round(new Date().getMilliseconds() - startTime.getMilliseconds());
|
||||
|
||||
let buff = Buffer.from([0xFE, 0x01]);
|
||||
client.write(buff);
|
||||
|
||||
})
|
||||
let error = false;
|
||||
client.on('data', (d) => {
|
||||
data = d.toString()
|
||||
client.destroy();
|
||||
|
||||
})
|
||||
client.once('error', (error) => {
|
||||
console.error(error)
|
||||
error = true;
|
||||
})
|
||||
client.once('connectionAttemptFailed', (ip) => {
|
||||
console.error("in attempt failed")
|
||||
error = true;
|
||||
})
|
||||
|
||||
client.once('connectionAttemptTimeout', (ip) => {
|
||||
console.error("in attempt timeout")
|
||||
error = true;
|
||||
})
|
||||
client.on('close', () => {
|
||||
if (!error) {
|
||||
let _serverInfo = data?.split('\x00\x00\x00');
|
||||
|
||||
if (!_serverInfo) {
|
||||
console.log("Something went wrong.")
|
||||
resolve(serverInfo)
|
||||
}
|
||||
serverInfo.version = _serverInfo[2].replace(/\u0000/g, '')
|
||||
serverInfo.motd = _serverInfo[3].replace(/\u0000/g, '')
|
||||
serverInfo.playercount = Number(_serverInfo[4].replace(/\u0000/g, ''))
|
||||
serverInfo.maxPlayers = Number(_serverInfo[5].replace(/\u0000/g, ''))
|
||||
serverInfo.ping = Number(ping)
|
||||
resolve(serverInfo)
|
||||
} else {
|
||||
resolve(0)
|
||||
}
|
||||
})
|
||||
})
|
||||
return serverInfo
|
||||
}
|
||||
|
|
@ -16,9 +16,9 @@ module.exports = {
|
|||
let user = message.guild.members.cache.get(info);
|
||||
let guildPfp = user.avatarURL({format: 'png', dynamic: true, size: 4096});
|
||||
let globalPfp = user.user.avatarURL({format: 'png', dynamic: true, size: 4096});
|
||||
let sendText = `${globalPfp}`;
|
||||
let sendText = `Global pfp:\n${globalPfp}`;
|
||||
if(guildPfp != null){
|
||||
sendText = `Global pfp${sendText}\nGuild pfp:\n${guildPfp}`;
|
||||
sendText = `${sendText}\nGuild pfp:\n${guildPfp}`;
|
||||
}
|
||||
|
||||
message.channel.send(sendText)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ module.exports = {
|
|||
{name: "Server Name", value: message.guild.name, inline: false},
|
||||
{name: "Created", value: convertDateToISOString(message.guild.createdAt), inline: false},
|
||||
{name: "Members", value: message.guild.memberCount.toString(), inline: false},
|
||||
{name: "Channels", value: message.guild.channels.channelCountWithoutThreads.toString(), inline: false},
|
||||
|
||||
|
||||
])
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const { execFileSync } = require('child_process');
|
||||
const path = require('path');
|
||||
const fs = require('fs')
|
||||
|
||||
const executeCommand = require('../../util/executeCommand');
|
||||
module.exports = {
|
||||
name: 'dl',
|
||||
description: 'Download a video',
|
||||
|
|
@ -38,7 +38,7 @@ module.exports = {
|
|||
|
||||
const originalMessage = await message.channel.send("Downloading video...")
|
||||
|
||||
if(executeCommand("yt-dlp", [url, "-P", downloadsDir, "--cookies", cookieFilepath]).error){
|
||||
if(this.executeCommand("yt-dlp", [url, "-P", downloadsDir, "--cookies", cookieFilepath]).error){
|
||||
originalMessage.edit("An error occurred when downloading the video.");
|
||||
this.cleanUp(downloadsDir);
|
||||
return;
|
||||
|
|
@ -68,4 +68,18 @@ module.exports = {
|
|||
fs.rmSync(downloadsDir, {force: true, recursive: true});
|
||||
},
|
||||
|
||||
executeCommand(command, commandArgs, verbose=false) {
|
||||
if (typeof command !== 'string' || !Array.isArray(commandArgs)) return { error: true };
|
||||
console.log("Executing:", command, commandArgs.join(" "));
|
||||
try {
|
||||
const output = execFileSync(command, commandArgs, {encoding: 'utf8'})
|
||||
if (output.length != 0 && verbose)
|
||||
console.log(output)
|
||||
} catch (error) {
|
||||
console.error(`Error executing ${command} command:`, error);
|
||||
return { error: true };
|
||||
}
|
||||
return { error: false };
|
||||
},
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,13 +87,11 @@ module.exports = {
|
|||
if(sendText.embed != null){
|
||||
let parse = parseMention(message.author.id, message.guild)
|
||||
let user = message.guild.members.cache.get(parse);
|
||||
if(!sendText.embed.data.color){
|
||||
let roleColor = 15788778;
|
||||
if (user.roles.color) {
|
||||
roleColor = user.roles.color.color;
|
||||
}
|
||||
sendText.embed.setColor(roleColor);
|
||||
let roleColor = 15788778;
|
||||
if (user.roles.color) {
|
||||
roleColor = user.roles.color.color;
|
||||
}
|
||||
sendText.embed.setColor(roleColor);
|
||||
message.channel.send({embeds :[sendText.embed]})
|
||||
}else{
|
||||
message.channel.send(sendText.text.replaceAll("<prefix>", prefix));
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
module.exports = {
|
||||
name: 'ig',
|
||||
description: 'Replaces Instagram links with kkinstagram and deletes the original message',
|
||||
execute({message, args}) {
|
||||
const noUrlErr = "You need to provide an Instagram link to use this command."
|
||||
if(args.length < 1) {
|
||||
message.channel.send(noUrlErr);
|
||||
return;
|
||||
}
|
||||
let replacedLink = "";
|
||||
const regex = /(?<=\/)(instagram)\.com/g
|
||||
if(args[0].startsWith("https://") || args[0].startsWith("http://")){
|
||||
replacedLink = args[0].replace(regex, "kkinstagram.com");
|
||||
}
|
||||
if(replacedLink.length === 0 || args[0] === replacedLink){
|
||||
message.channel.send(noUrlErr);
|
||||
return;
|
||||
}
|
||||
message.channel.send(replacedLink);
|
||||
try{
|
||||
message.delete()
|
||||
}catch(err){
|
||||
console.error(`${this.name}: An error occurred while trying to delete the original message.`)
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
module.exports = {
|
||||
name: 'say',
|
||||
description: 'Repeats arguments',
|
||||
admin: true,
|
||||
execute({message, args}) {
|
||||
|
||||
if(args.length == 0)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const { writeFile } = require('node:fs/promises')
|
||||
const { Readable } = require('node:stream')
|
||||
const executeCommand = require('../../util/executeCommand');
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: 'tdoss',
|
||||
|
|
@ -60,8 +60,8 @@ module.exports = {
|
|||
}
|
||||
|
||||
|
||||
const commandArgs = [tdossTemplate, "(", `${directory}/input.png`, "-resize", "800x800^", "-gravity", "center", "-extent", "1000x1000", ")", "-compose", "dst-over", "-composite", `${directory}/tdoss_result.png`]
|
||||
if (executeCommand("magick", commandArgs).error === true) {
|
||||
const command = `magick ${tdossTemplate} \\( ${directory}/input.png -resize 800x800^ -gravity center -extent 1000x1000 \\) -compose dst-over -composite ${directory}/tdoss_result.png`;
|
||||
if (this.executeCommand(command).error === true) {
|
||||
message.channel.send("Something went wrong during image manipulation.\nTry again and if it keeps happening, contact the owner of the bot.")
|
||||
fs.rmSync(`${directory}`, {recursive: true})
|
||||
return
|
||||
|
|
@ -75,6 +75,20 @@ module.exports = {
|
|||
await message.channel.send({files: [final_image]})
|
||||
fs.rmSync(`${directory}`, {recursive: true})
|
||||
},
|
||||
|
||||
|
||||
executeCommand(command) {
|
||||
console.log("Executing:", command)
|
||||
try {
|
||||
const output = execSync(command, { encoding: 'utf-8' })
|
||||
if (output.length != 0)
|
||||
console.log(output)
|
||||
} catch (error) {
|
||||
console.error(`Error executing ${command.split(" ")[0]} command:`, error);
|
||||
return { error: true };
|
||||
}
|
||||
return { error: false };
|
||||
},
|
||||
// https://stackoverflow.com/a/77210219
|
||||
async downloadImage(url, path) {
|
||||
let res;
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
|
||||
module.exports = {
|
||||
name: 'x',
|
||||
description: 'Replaces X/Twitter links with fxtwitter and deletes the original message',
|
||||
execute({message, args}) {
|
||||
const noUrlErr = "You need to provide an X or twitter link to use this command."
|
||||
if(args.length < 1) {
|
||||
message.channel.send(noUrlErr);
|
||||
return;
|
||||
}
|
||||
let replacedLink = "";
|
||||
const regex = /(?<=\/)(x|twitter)\.com/g
|
||||
if(args[0].startsWith("https://") || args[0].startsWith("http://")){
|
||||
replacedLink = args[0].replace(regex, "fxtwitter.com");
|
||||
}
|
||||
if(replacedLink.length === 0 || args[0] === replacedLink){
|
||||
message.channel.send(noUrlErr);
|
||||
return;
|
||||
}
|
||||
message.channel.send(replacedLink);
|
||||
try{
|
||||
message.delete()
|
||||
}catch(err){
|
||||
console.error(`${this.name}: An error occurred while trying to delete the original message.`)
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
2603
package-lock.json
generated
2603
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -5,8 +5,8 @@
|
|||
"main": "server.js",
|
||||
"dependencies": {
|
||||
"@zuzak/owo": "^1.14.1",
|
||||
"discord.js": "^14.21.0",
|
||||
"dotenv": "^17.2.1",
|
||||
"discord.js": "^14.20.0",
|
||||
"dotenv": "^16.5.0",
|
||||
"seedrandom": "^3.0.5",
|
||||
"sqlite3": "^5.1.6"
|
||||
},
|
||||
|
|
@ -21,6 +21,6 @@
|
|||
"license": "UNLICENSE",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^30.0.0",
|
||||
"jest": "^30.0.5"
|
||||
"jest": "^30.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
const fs = require('fs');
|
||||
const createInitialConfig = require("./util/createInitialConfig")
|
||||
const convertJSONToSQL = require('./util/timer/convertJSONToSQL');
|
||||
const executeCommand = require('./util/executeCommand.js');
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
if(!fs.existsSync("./data/config.json")) {
|
||||
createInitialConfig();
|
||||
|
|
@ -57,9 +56,6 @@ client.settings.set("presenceType", presenceType);
|
|||
client.settings.set("presenceText", presenceText);
|
||||
client.settings.set("globalPrefix", globalPrefix);
|
||||
|
||||
const githash = executeCommand(`git`, ["rev-parse", "--short", "HEAD"]);
|
||||
client.githash = githash.error ? "N/A" : githash.output;
|
||||
|
||||
const reloadCommands = require("./util/reloadCommands.js");
|
||||
const onMessage = require('./server/message');
|
||||
const onReady = require('./server/ready');
|
||||
|
|
|
|||
17
tests/getGuildCount.test.js
Normal file
17
tests/getGuildCount.test.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const getGuildInfo = require('../util/getGuildInfo');
|
||||
|
||||
|
||||
|
||||
test("Testing getGuildCount", () => {
|
||||
for(let i = 1; i < 200000; i = i+i*30 ){
|
||||
let client = {guilds: {cache: new Map()}}
|
||||
client.guilds.cache.each = client.guilds.cache.forEach;
|
||||
|
||||
for(let j = 0; j < i; j++){
|
||||
client.guilds.cache.set(`num: ${j}`, j);
|
||||
}
|
||||
|
||||
expect(getGuildInfo(client).guildCount).toBe(i);
|
||||
|
||||
}
|
||||
})
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
const { execFileSync } = require('child_process');
|
||||
module.exports = function(command, commandArgs, verbose=false) {
|
||||
if (typeof command !== 'string' || !Array.isArray(commandArgs)) return { error: true };
|
||||
console.log("Executing:", command, commandArgs.join(" "));
|
||||
let output;
|
||||
try {
|
||||
output = execFileSync(command, commandArgs, {encoding: 'utf8'})
|
||||
if (output.length !== 0 && verbose)
|
||||
console.log(output)
|
||||
} catch (error) {
|
||||
console.error(`Error executing ${command} command:`, error);
|
||||
return { error: true };
|
||||
}
|
||||
return { error: false, output};
|
||||
}
|
||||
|
|
@ -1,16 +1,9 @@
|
|||
module.exports = function(client){
|
||||
let guildCount = 0;
|
||||
let totalMembers = 0;
|
||||
const uniqueMembers = new Map();
|
||||
client.guilds.cache.each(guild => {
|
||||
guildCount++
|
||||
totalMembers += guild.memberCount;
|
||||
guild.members.cache.each(member => {
|
||||
if(!uniqueMembers.has(member.id)){
|
||||
uniqueMembers.set(member.id, true);
|
||||
}
|
||||
})
|
||||
});
|
||||
const uniqueMemberCount = uniqueMembers.size;
|
||||
return {guildCount, totalMembers, uniqueMemberCount};
|
||||
return {guildCount: guildCount, totalMembers: totalMembers};
|
||||
}
|
||||
|
|
@ -2,11 +2,6 @@ const getNickname = require("../getNickname");
|
|||
const parseMention = require("../parseMention");
|
||||
const getFmUsername = require("./getFmUsername");
|
||||
const {EmbedBuilder} = require('discord.js');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { writeFile } = require('node:fs/promises')
|
||||
const executeCommand = require('../executeCommand');
|
||||
const { Readable } = require('node:stream')
|
||||
|
||||
require("dotenv").config();
|
||||
module.exports = async function (userID, guild) {
|
||||
|
|
@ -63,56 +58,21 @@ module.exports = async function (userID, guild) {
|
|||
sendText.text = tracks.errorMsg;
|
||||
return sendText;
|
||||
}
|
||||
let coverDir = path.resolve(process.cwd(), 'data', 'covers');
|
||||
let color = "#C27D0E"
|
||||
const directory = path.resolve(coverDir, Math.floor(new Date).toString())
|
||||
fs.mkdirSync(directory, {recursive: true})
|
||||
const coverFile = path.resolve(directory, "cover")
|
||||
let downloadResult = await downloadImage(tracks[0].cover, coverFile);
|
||||
if(downloadResult.value === ERROR_CODES.SUCCESS){
|
||||
const commandArgs = [`${coverFile}.${downloadResult.ext}`, "-resize", "1x1", "txt:-"]
|
||||
let res = executeCommand("magick", commandArgs);
|
||||
if(!res.error) color = res.output.split("\n")[1].split(" ")[3].slice(0,7);
|
||||
|
||||
}
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({name: `Now playing - ${nickname}`, iconURL: user.user.avatarURL({ dynamic: true, size: 4096 })})
|
||||
.setThumbnail(tracks[0].cover)
|
||||
.setColor(color)
|
||||
.addFields({
|
||||
name: `${isCurrentScrobble}:`, value: `${tracks[0].song}\n **${tracks[0].artist} • ** ${tracks[0].album}`
|
||||
},)
|
||||
.setAuthor({name: `Now playing - ${nickname}`, iconURL: user.user.avatarURL({ dynamic: true, size: 4096 })})
|
||||
.setThumbnail(tracks[0].cover)
|
||||
.setColor(15780145)
|
||||
.addFields({
|
||||
name: `${isCurrentScrobble}:`, value: `${tracks[0].song}\n **${tracks[0].artist} • ** ${tracks[0].album}`
|
||||
},)
|
||||
if (isCurrentScrobble === "Current") {
|
||||
embed.addFields({
|
||||
name: "Previous:", value: `${tracks[1].song}\n **${tracks[1].artist} • ** ${tracks[1].album}`
|
||||
},)
|
||||
}
|
||||
sendText.embed = embed;
|
||||
fs.rmSync(`${directory}`, {recursive: true})
|
||||
} else {
|
||||
sendText.text = "You haven't set your last.fm username yet. Use `<prefix>fm set <lastfm_username>` to set it.";
|
||||
}
|
||||
return sendText;
|
||||
}
|
||||
const ERROR_CODES = {
|
||||
SUCCESS: 0,
|
||||
HTTP_ERROR: 1,
|
||||
NOT_IMAGE: 2,
|
||||
FETCH_ERROR: 3
|
||||
}
|
||||
async function downloadImage(url, downloadPath) {
|
||||
let res;
|
||||
try {
|
||||
res = await fetch(url);
|
||||
} catch (error) {
|
||||
return {value: ERROR_CODES.FETCH_ERROR, errorMessage: error.cause?.message || error.message};
|
||||
}
|
||||
if(!res.ok) return {value: ERROR_CODES.HTTP_ERROR, errorMessage: res.status.toString()};
|
||||
const contentType = res.headers.get('content-type');
|
||||
|
||||
if(!contentType || !contentType.startsWith("image")) return {value: ERROR_CODES.NOT_IMAGE, errorMessage: contentType || "No content-type header"};
|
||||
const fileExt = contentType.split("/")[1]
|
||||
const stream = Readable.fromWeb(res.body)
|
||||
await writeFile(`${downloadPath}.${fileExt}`, stream);
|
||||
return {value: ERROR_CODES.SUCCESS, errorMessage: "", ext: fileExt};
|
||||
}
|
||||
}
|
||||
|
|
@ -77,8 +77,7 @@ module.exports = async function (userID, option, guild, compatibility=false) {
|
|||
fetch(`https://ws.audioscrobbler.com/2.0/?method=user.gettopalbums&user=${lastfmUsername}&period=${option[0]}&api_key=${process.env.LAST_FM_API_KEY}&format=json`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const maxIterations = data.topalbums.album.length >= 10 ? 10 : data.topalbums.album.length;
|
||||
for(let i = 0; i < maxIterations; i++){
|
||||
for(let i = 0; i < 10; i++){
|
||||
let album = {}
|
||||
let currentAlbum = data.topalbums.album[i];
|
||||
album.artist = currentAlbum.artist.name;
|
||||
|
|
|
|||
|
|
@ -77,8 +77,7 @@ module.exports = async function (userID, option, guild, compatibility=false) {
|
|||
fetch(`https://ws.audioscrobbler.com/2.0/?method=user.gettopartists&user=${lastfmUsername}&period=${option[0]}&api_key=${process.env.LAST_FM_API_KEY}&format=json`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const maxIterations = data.topartists.artist.length >= 10 ? 10 : data.topartists.artist.length;
|
||||
for(let i = 0; i < maxIterations; i++){
|
||||
for(let i = 0; i < 10; i++){
|
||||
let artist = {}
|
||||
let currentArtist = data.topartists.artist[i];
|
||||
artist.name = currentArtist.name;
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ module.exports = async function (userID, option, guild, compatibility=false) {
|
|||
fetch(`https://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=${lastfmUsername}&period=${option[0]}&api_key=${apiKey}&format=json`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const maxIterations = data.toptracks.track.length >= 10 ? 10 : data.toptracks.track.length;
|
||||
for(let i = 0; i < maxIterations; i++){
|
||||
for(let i = 0; i < 10; i++){
|
||||
let track = {}
|
||||
let currentTrack = data.toptracks.track[i];
|
||||
track.artist = currentTrack.artist.name;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ module.exports = function ({presenceText, presenceType, client}) {
|
|||
guilds: guildInfo.guildCount,
|
||||
prefix: globalPrefix,
|
||||
uptime: uptimeFormat,
|
||||
members: guildInfo.totalMembers,
|
||||
uniqueMembers: guildInfo.uniqueMemberCount
|
||||
members: guildInfo.totalMembers
|
||||
}
|
||||
|
||||
const regex = /(?<=\${)(.*?)(?=})/g;
|
||||
|
|
|
|||
Loading…
Reference in a new issue