master
Kit Kasune 3 years ago
parent 68ec778817
commit 897d064699
  1. 2
      commands/dev/execute.js
  2. 50
      commands/fun/nowplaying.js
  3. 40
      commands/misc/lfm.js
  4. 14
      events/ready.js
  5. 1549
      package-lock.json
  6. 1
      package.json
  7. 1
      util/lxp/gainxp.js

@ -3,7 +3,7 @@ const Discord = require('discord.js');
const cp = require("child_process"); const cp = require("child_process");
module.exports = { module.exports = {
name: "Execute", name: "execute",
aliases: ['exec'], aliases: ['exec'],
meta: { meta: {
category: 'Developer', category: 'Developer',

@ -0,0 +1,50 @@
const Discord = require('discord.js');
const Saves = require("../../models/saves");
module.exports = {
name: "nowplaying",
aliases: ['np'],
meta: {
category: 'Fun',
description: "Show off the music you're currently listening to through last.fm!",
syntax: '`nowplaying [@mention]`',
extra: null
},
help: new Discord.MessageEmbed()
.setTitle("Help -> Now Playing")
.setDescription("Accesses last.fm's API to show off what music you're currently listening to. Use the `lfm` command for more information.")
.addField("Syntax", "`nowplaying [@mention]`"),
async execute(message, msg, args, cmd, prefix, mention, client) {
let savess = await Saves.findOne({name: 'lfm'}) ? await Saves.findOne({name: 'lfm'}) : new Saves({name: 'lfm'});
let saves = savess.saves;
let user = mention || message.author;
if (!saves.get(user.id)) {return message.channel.send(`${mention ? "That person's" : "Your"} last.fm username isn't set! ${mention ? "They" : "You"} can set it with \`${prefix}lfm set <username>\``);}
let found = false;
try {
const glfm = function() {return new Promise(resolve => {
let timeout = setTimeout(() => {return resolve(undefined);}, 3000);
let stream = client.lfm.stream(saves.get(user.id));
stream.on('nowPlaying', t => {
clearTimeout(timeout);
message.channel.send(new Discord.MessageEmbed()
.setAuthor(message.guild ? message.guild.members.cache.get(user.id) ? message.guild.members.cache.get(user.id).displayName : user.username : user.username, user.avatarURL())
.setTitle(`${saves.get(user.id)} | Now Playing`)
.setDescription(`<@${user.id}> is currently listening to **${t.name}** by **${t.artist['#text']}**.\nView the song [here](${t.url}).`)
.setColor("c375f0")
.setThumbnail(t.image[3]['#text'])
.setTimestamp()
)
found = true;
stream.stop();
return resolve(undefined);
});
stream.start();
});}
await glfm().catch((e) => {console.error(e);});
} catch (e) {console.error(e);}
if (!found) {return message.channel.send(`I couldn't find what \"${saves.get(user.id)}\" is listening to. Perhaps ${!mention ? "you" : "they"}'re not listening to anything, or you got ${!mention ? "your" : "their"} name wrong?`);}
}
};

@ -0,0 +1,40 @@
const Discord = require('discord.js');
const Saves = require('../../models/saves');
const ask = require("../../util/ask");
module.exports = {
name: "lfm",
aliases: ['lastfm'],
meta: {
category: 'Misc',
description: "Interact with the last.fm service",
syntax: '` <>`',
extra: null
},
help: new Discord.MessageEmbed()
.setTitle("Help -> Last.fm")
.setDescription("Interact with last.fm, a service that stores and analyzes your Spotify listening activity.")
.addField("Notice", "Most of the features of this command require you to have an account. You can make one at [last.fm](https://last.fm)")
.addField("Syntax", "``"),
async execute(message, msg, args, cmd, prefix, mention, client) {
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}\``);}
let savess = await Saves.findOne({name: 'lfm'}) || new Saves({name: 'lfm'});
let saves = savess.saves;
if (['s', 'set', 'setname', 'setusername', 'setn'].includes(args[0].toLowerCase())) {
args.shift();
let name;
if (!args.length) {
name = await ask(message, "What is your last.fm username?", 60000);
if (!name) {return;}
}
saves.set(message.author.id, name || args.join(" ").trim());
savess.saves = saves;
savess.save();
return message.channel.send(`Last.fm username set! Try \`${prefix}nowplaying\` if you're listening to music to show off what you're currently listening to!`);
}
}
};

@ -3,6 +3,7 @@ const chalk = require('chalk');
const moment = require('moment'); const moment = require('moment');
const mongoose = require('mongoose'); const mongoose = require('mongoose');
const ora = require('ora'); const ora = require('ora');
const lastfm = require("lastfm");
const GuildSettings = require('../models/guild'); const GuildSettings = require('../models/guild');
const BotDataSchema = require('../models/bot'); const BotDataSchema = require('../models/bot');
@ -17,6 +18,9 @@ const vcloop = require('../util/vcloop');
let prefix = 'n?'; let prefix = 'n?';
module.exports = async client => { module.exports = async client => {
if (client.misc.readied) {return;}
client.misc.readied = true;
const config = client.config; const config = client.config;
/*let db = mongoose.connection; /*let db = mongoose.connection;
@ -30,13 +34,16 @@ module.exports = async client => {
console.log(`${chalk.gray('[INFO]')} >> ${chalk.white(`Running on ${client.guilds.cache.size} servers!`)}`); console.log(`${chalk.gray('[INFO]')} >> ${chalk.white(`Running on ${client.guilds.cache.size} servers!`)}`);
console.log(`${chalk.gray('[INFO]')} >> ${chalk.white(`Serving ${client.users.cache.size} users!`)}`); console.log(`${chalk.gray('[INFO]')} >> ${chalk.white(`Serving ${client.users.cache.size} users!`)}`);
client.lfm = new lastfm.LastFmNode({api_key: client.config.lfm.key, secret: client.config.lfm.secret});
let responses = { let responses = {
"PLAYING": [ "PLAYING": [
`with my darling`, 'RAIN: Shadow Lords', "with my waifu", "with the neko formula", `with my darling`, 'RAIN: Shadow Lords', "with my waifu", "with the neko formula",
"with magic", "terrible anime games", "anime OSTs at max volume", "with magic", "terrible anime games", "anime OSTs at max volume",
`${Math.ceil(Math.random() * 100)} days of trying to become a samurai`, `${Math.ceil(Math.random() * 100)} days of trying to become a samurai`,
"with the sauce", "witch hats are >", "explosion magic is the best magic", "with the sauce", "witch hats are >", "explosion magic is the best magic",
"with Kazuma's sanity" "with Kazuma's sanity", "please help i gave myself cat ears",
"starting my own harem", "wor. wor never changes", "a little more UwU than necessary"
,`in ${client.guilds.cache.size} servers` ,`in ${client.guilds.cache.size} servers`
], ],
"WATCHING": [ "WATCHING": [
@ -45,7 +52,10 @@ module.exports = async client => {
"a slime somehow start an empire", "a fox-maid get her tail fluffed", "a slime somehow start an empire", "a fox-maid get her tail fluffed",
"a raccoon-girl and some guy with a shield", "some chick with unusually red hair", "a raccoon-girl and some guy with a shield", "some chick with unusually red hair",
"Mob hit 100", "a really bad harem anime", "The Black Swordsman", "Mob hit 100", "a really bad harem anime", "The Black Swordsman",
"The Misfit of Demon King Academy", "Akame ga Kill" "The Misfit of Demon King Academy", "Akame ga Kill", "a witch explode a castle",
"Code Geass", "\"did you really think ___ would be enough to kill me?\"",
"hentacle tentai", "JIBUN WO-", "he did it... he actually made risotto",
""
,`over ${client.guilds.cache.size} servers` ,`over ${client.guilds.cache.size} servers`
] ]
}; };

1549
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -11,6 +11,7 @@
"dblapi.js": "^2.4.1", "dblapi.js": "^2.4.1",
"discord.io": "https://github.com/woor/discord.io/tarball/gateway_v6", "discord.io": "https://github.com/woor/discord.io/tarball/gateway_v6",
"discord.js": "^12.2.0", "discord.js": "^12.2.0",
"lastfm": "^0.9.0",
"manyitems": "^1.0.2", "manyitems": "^1.0.2",
"moment": "^2.28.0", "moment": "^2.28.0",
"moment-precise-range-plugin": "^1.3.0", "moment-precise-range-plugin": "^1.3.0",

@ -2,7 +2,6 @@ const LXP = require('../../models/localxp');
const LR = require('../../models/levelroles'); const LR = require('../../models/levelroles');
module.exports = async (client, member, channel) => { module.exports = async (client, member, channel) => {
if (member.id === '468903364533420074' && channel.guild.id === '703196054966894642') {return;}
client.misc.cache.lxp.xp[channel.guild.id][member].lastXP = new Date().getTime(); client.misc.cache.lxp.xp[channel.guild.id][member].lastXP = new Date().getTime();
client.misc.cache.lxp.xp[channel.guild.id][member].xp += 10; client.misc.cache.lxp.xp[channel.guild.id][member].xp += 10;

Loading…
Cancel
Save