User Agent Command

This commit is contained in:
lilyissillyyy
2025-07-20 01:09:41 -04:00
parent 6fc212c4bb
commit 9d68b4e573
4 changed files with 23 additions and 3 deletions
+17
View File
@@ -0,0 +1,17 @@
const Command = require('../../framework/Command');
const { UserAgent } = require('user-agents');
module.exports = class UserAgentCommand extends Command {
constructor(client) {
super(client, {
name: 'user-agent',
group: 'random-res',
description: 'Responds with a random User Agent.'
});
}
run(msg) {
const agent = new UserAgent();
return msg.say(agent.toString());
}
};
+2 -1
View File
@@ -1,5 +1,6 @@
const Command = require('../../framework/Command');
const request = require('node-superfetch');
const { UserAgent } = require('user-agents');
const { list } = require('../../util/Util');
const moods = {
happy: 1,
@@ -45,7 +46,7 @@ module.exports = class NeopetCommand extends Command {
try {
const { body } = await request
.get(`http://pets.neopets.com/cpn/${encodeURIComponent(pet)}/${mood}/5.png`)
.set({ 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0' });
.set({ 'User-Agent': (new UserAgent()).toString() });
return msg.say({ files: [{ attachment: body, name: `${pet}-${mood}.png` }] });
} catch (err) {
if (err.status === 404) return msg.say('Could not find any results.');