#development
1 messages ยท Page 863 of 1
@elder vine Finaly, java.json things work in the app
Good :)
You don't have two message events?
@elder vine i don't get it
Neither do I, something in your pm2 config must be wrong?
@elder vine my p.json is this```json
{
"name": "bot",
"version": "1.0.0",
"description": "A simple Node app built on Express, instantly up and running.",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"start": "node index.js"
},
"engines": {
"node": "12.x"
},
"author": "Cxllm",
"license": "ISC",
"dependencies": {
"8ball.js": "^1.1.0",
"@discordjs/opus": "^0.1.0",
"@ffmpeg-installer/ffmpeg": "^1.0.20",
"@ksoft/api": "^3.1.6",
"boats.js": "^2.4.0",
"cheerio": "^0.22.0",
"cpu-stat": "^2.0.1",
"dblapi.js": "^2.4.0",
"discord.js": "^12.1.1",
"express": "^4.17.1",
"express-glitch-keepalive": "^0.2.0",
"ffmpeg": "^0.0.4",
"ffmpeg-static": "^4.0.1",
"flexilink": "^2.0.0",
"fluent-ffmpeg": "^2.1.2",
"fs-nextra": "^0.4.7",
"gblapi.js": "^1.3.13",
"genius-api": "^0.4.1",
"genius-lyrics": "^1.0.9",
"give-me-a-joke": "^0.2.5",
"hastebin-gen": "^2.0.5",
"imageapi.js": "^1.0.2",
"mathjs": "^6.6.1",
"moment": "^2.24.0",
"ms": "^2.1.2",
"node-fetch": "^2.6.0",
"node-superfetch": "^0.1.10",
"nodemon": "^2.0.3",
"novelcovid": "^1.0.9",
"pm2": "^4.2.3",
"quick.db": "^7.0.0-b22",
"random-facts": "^1.0.6",
"random-puppy": "^1.1.0",
"simple-youtube-api": "^5.2.1",
"superagent": "^5.2.2",
"tinyurl": "^1.1.3",
"urban": "^0.3.2",
"weather-js": "^2.0.0",
"yql": "^1.0.2",
"yt-search": "^1.1.2",
"ytdl-core": "^2.0.1",
"ytdl-core-discord": "^1.1.0",
"ytpl": "^0.1.20"
},
"repository": {
"url": "git+https://github.com/cxllm/corynth.git"
},
"bugs": {
"url": "https://github.com/cxllm/corynth/issues"
},
"homepage": "https://github.com/cxllm/corynth#readme",
"devDependencies": {}
}
hi package.json file that took up chat rather than being pasted in a hastebin
You probs do.
Where
1 sec
fs.readdir(__dirname +'/events/', (err, files) => {
if (err) console.log(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, (...args) => eventFunc.run(client, ...args));
});
});
That's what my events handler basically is
fs.readdir("./events/", (err, files) => {
if (err) console.log(err);
files.forEach(file => {
let eventFunc = require(`./events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, (...args) => eventFunc.run(client, ...args));
});
});```
const config = require("../config.json")
const Discord = require("discord.js")
const {queue} = require("../queue.js")
exports.run = async (client, message) => {
if (message.author.bot) return;
if (message.channel.type == "dm") return;
const db = require('quick.db')
let prefix = await db.fetch(`prefix_${message.guild.id}`);
if (!prefix) {
prefix = 'c!'
}
let mention = new RegExp(`^(<@!?${client.user.id}>)\\s*`);
const embed2 = new Discord.MessageEmbed()
.setTitle("My prefix for this server is " + prefix)
.setDescription(`Type ${prefix}help for commands and for links to our support server`)
.setColor(0x00aaff)
if(message.content.startsWith(prefix)) {
let messageArray = message.content.split(" ");
let cmd = messageArray[0].toLowerCase();
let args = messageArray.slice(1);
let command = client.commands.get(cmd.slice(prefix.length))
if (!command) command = client.commands.get(client.aliases.get(cmd.slice(prefix.length)));
if (!command) return;
if(command.category === "Owner" && message.author.id != config.ownerid) return;
command.run(client, message, args, queue).then( () => {
const Embed = new Discord.MessageEmbed()
.setTitle("Command Run")
.setDescription(`The command **${command.category}/${command.name}** was run by **${message.author.username}** in **${message.guild.name}**`)
.setColor(0x00aaff)
const cnl = client.channels.cache.get("697061184708280350")
cnl.send(Embed)}).catch(e => {
const {ownerid} = require('../config.json')
message.channel.send("Unfortunately, there was an error executing that command and I will inform the developer so he can fix it.")
client.users.cache.get(ownerid).send(`There has been an error executing ${command.name}\n\`\`\`js\n${e}\`\`\``)
})
} else if (message.content.match(mention)){return message.channel.send(embed2);}
else return undefined;
}``` This is my message.js
Which of the instances is your bot?
index
why do you have 2 instances?
then remove one of them
For some reason my bot runs every command twice
The two pm2's isn't the same
It isn't intentional
pm2 delete bot
It's not bot
so those are two different bots?
Yep
show your index.js
Ok
?
https://hastebin.com/izobamemob.js - index.js
https://hastebin.com/egobefuyon.js - message.js
I have no idea
type top in your terminal
also, why do you have 2 bots in your file lol
bot and client
I have no idea
fair enough
Hi I'm having trouble installing discord.py on my windows computer.
It has Python 3.8.2.
any errors?
When I try to type "python3 -m pip install -U discord.py" it returns
File "<stdin>", line 1
python3 -m pip install -U discord.py
^
I have no idea how to do anything
Screenshot?
can you try just pip install -U discord.py
oof okay XD
I havent used python in ages but i dont remember needing the first bit
I was using the wrong "put in code" place
I don't know what you call those
I'm a big noob
Everyone has to start somewhere ๐ just learn to learn from mistakes
Thank you
if(command === "example") {
let randomnumber = Math.floor(Math.random() * 11)
const filter = m => m.author.id === message.author.id
message.channel.send("Choose a random number.")
console.log(randomnumber)
message.channel.awaitMessages(filter, {
max: 1,
time: 10000
}).then(collected => {
if(collected === randomnumber) return message.channel.send("Right!")
if(collected !== randomnumber) return message.channel.send("Wrong!")
})
}```
The code sends the message and then sends wrong, doesn't wait
What is the problem with the await messages?
v11
I suggest making a collector
But isn't that supposed to work ?
What's wrong?
@earnest phoenix what is max supposed to be, because there is max and maxMatches in Discord.js v11:
max- The maximum numbers to process (aka see).maxMatches- The maximum number of messages allowed to pass the filter.
Oh right
i will try maxmatches
It did work but when i match the right number it will still say im wrong
also collected is going to be a collection of messages, not the random number
^
oh
so how do i make it work with randomnumber?
get the first item from the collection with a method like .first() and compare the content
it's in the docs
i tried it didnt work
collected.first().content
this?
Can you show what you did
yeah
ok
if(command === "example") {
let randomnumber = Math.floor(Math.random() * 11)
const filter = m => m.author.id === message.author.id
message.channel.send("Choose a random number.")
console.log(randomnumber)
message.channel.awaitMessages(filter, {
maxMatches: 1,
time: 10000
}).then(collected => {
if(collected === randomnumber) return message.channel.send("Right!")
if(collected !== randomnumber) return message.channel.send("Wrong!")
})
}```
I also tried using if collected.first().content but it still says im wrong...
third issue with your code, === is strict. == is loose. You'd need to convert the string to a number, validate, then compare etc.
you didn't even use collected.first()
i said when i tried it still didnt work
Also you are comparing a collection to a number so
...
collected.first().content will always be a string, so either compare loosely (==) or turn it into a number, like Kinolite said
so you're saying == is for numbers?
it's for comparing loosely, aka "4" == 4 will return true
ok
If you use strict compare it won't ("4" === 4)
You should try using === whenever possible. == can have side effects.
oh
no it can't
i didnt know that
learning new stuff everyday i guess
thanks! it worked perfectly
no it can't
@cinder patio it can: https://stackoverflow.com/a/359509/11389072
One thing i forgot
How can i do it so if there is no answer it will respond?
i tried doing this
if(!collected.first().content) return message.channel.send("WHY")```
I think that it only returns when it is collected
check if the collection's size is more than 0
add errors: ["time"] to your await message function
im adding an error catch
then catch it
Or just check if the collection size is zero and don't catch any errors
added this
}).catch(err => message.channel.send("WHY")) ```
worked
if(collection.size == 0) ?
collected*
Ran into another problem. So basically I made a standard ping command like
@client.command
async def ping(ctx):
print(f"Pong! {round(client.latency * 1000)}ms")
And I got this weird message saying
"Ignoring exception in command None: discord.ext.commands.errors.CommandNotFound: Command "ping" is not found"
And so before I made this command it just said Pong! and it worked but now every time I type the command it spams multiple responses of what my code used to look like so for example, it would show something like this
I feel like it gets worse the more I try to retype the code.
Are you ignoring bots? Are you checking the exceptions to include when the user uses a command that does not exist?
Bot permissions?
It has admin as bot permissions so it can basically do anything
Should I post my entire code
It's 23 lines
Ack bugs have taken over me again
What would be better? In the database I have a few rows whose values can be either 0, 1 or 2. Would it better to store them all in one row via a bitfield (0x2000 - 0, 0x4000 - 1, 0x8000 - 2) problem is, the max of the number is 34952, and I am not sure if would require more space than 4 rows with 0 / 1 / 2s
Is there a bot that has a way I can make it so a role gets removed when receiving a different role?
You get role Test1
Role **Test2 **gets removed
dm me if you know how
listen to event
I feel like my bot is running all versions of my code that have existed since I made the first @client.command line and now.
Even if I take that command away the command still works
What would be better? In the database I have a few rows whose values can be either 0, 1 or 2. Would it better to store them all in one row via a bitfield (0x2000 - 0, 0x4000 - 1, 0x8000 - 2) problem is, the max of the number is 34952, and I am not sure if would require more space than 4 rows with 0 / 1 / 2s
Actually I don't think it'd matter because 8bit integers' size is 1 byte, while 32bit integers' size is 4 bytes. Although If I decide to add more options with 0/1/2 then bitfield would save more space
I still get this thing
Ignoring exception in command None:
discord.ext.commands.errors.CommandNotFound: Command "ping" is not found
and this error
And the command used to say print('___') so it also prints the pong
Basically my code is running every single version of this code for some reason
Are you deleting your ping messages
Are those all responses sent just on one command usage
Yes
Your code is kinda drunk buddy
oh no
You're not supposed to send that many messages at once
Restart your machine first, make sure you're actually closing your bot instance when restarting
-ok-
One more question what is a bot instance
Your script
How to get a specific user messages and delete them ?
Ok
fetch the message and delete
Thank you @slender thistle
@earnest phoenix like get their last message id and delete it or...
Delete whatever that specific user says?...
why not fetch the messages and delete it @earnest phoenix ?
@elder vine i mean you can but i meant like do you want every message of that user to be deleted or something?
message.channel.fetchMessages({
limit: `${args[1]}`,
}).then((messages) => {
messages = messages.filter(user => user.id === user.id)
message.channel.bulkDelete(messages)```
i tried this but it doesnt seem to be working
the limit is the number i put to delete
but it deletes every message
parseInt(args[1])
yeah
It doesnt solve the problem tho
I need to fetch the user's messages and delete them
well, you're filtering them by their id
so it'll delete every
messages.filter(msg => msg.author.id === message.author.id)
you're comparing 1 to 1
like it'll delete everything
Wait, why do you need to fetch the messages before you bulkDelete?
Alright, so my bot accessess an api, but some of the api responses I get are links to more things within the api,and when my bot reads those, it just spits out {object,object}
how would i get it to read the api responses from the api
Has anyone been able to use github self-host runner's with their discord bot?
@copper cradle but i need to delete the messages with the users id not with the message author id
ill try
Doesnt work
@quartz kindle sorry I have been out, can we continue with the issue about the two instances
I think it's something to do with my code
Snekfetch confused my brain 
superagent.get('https://srhpyqt94yxb.statuspage.io/api/v2/summary.json').then(r=>message.reply(r.headers.status))
i tried like 9 different things and I still don't know how to get this to work
Snekfetch is dead
snekfetch has been deprecated forever
i knu
use node-fetch or node's built in http module
You can't?
im using request for my api bot
@golden condor did you delete/re-add any of the bots from pm2 since you posted the pm2 image?
the process PIDs dont match
when you do pm2 restart, sometimes it loads twice?
Yeah
I restarted
It didn't go twice
I have another question
How do I use webhooks inside the code
Like the donatebot webhook for example
@earnest phoenix ah
well still
you're cheching if the message id is the same as... well the same message id
check what you did
so im using request to acces an api, but the api has some responses that are coming out as (Object,Object) it seems to be the ones where the responses are more variabes, how to I get my bot to read those variables
for example, say i want to get the name of the subclasses from "subclasses":[{"name":"Lore","url":"/api/subclasses/lore"},{"name":"Fiend","url":"/api/subclasses/fiend"}],"url":"/api/spells/command"}
messages.filter(user => user.id === user.id) in this case, user is not an user object, naming it user doesn't change what it is, this shows that you don't actually know how to use functions, in this case user is a message object, so youre checking if the message id is the same as the message id duuuhh, so it'll always be true
@golden condor you mean top.gg webhooks or discord webhooks?
@valid gyro subclasses is an array, like this subclasses:[{subclass},{subclass}]
do access items from an array, you use their index number, for example the first subclass would be subclasses[0], the second one would be subclasses[1] and so on
then you can get the name property after you get the item: subclasses[0].name to get the name of the first subclass
you can also use subclasses.map() to transform the items of the array, and give you for example a list of names, instead of a list of subclasses
an example of the .map function would be subclasses.map(subclass => subclass.name) to return a list of names (transform each item of the subclasses array into a name)
so rn my command is msg.channel.send(`Subclasses: ${body.subclasses}`);
I would tack the subclasses.map(subclass => subclass.name) to the end of that?
that would return a list of names yes
idk how donatebot works, havent used it
does it send a message with a different username/profile pic?
that gives me a subclassess is not defined error
then you used it wrong
probably
remember, your subclasses is your body.subclasses
you just need to attach the map function to it
it works now, but it sends subclasses and the function before it twice
which is... odd
@quartz kindle now im getting the information I needed but everything is being sent twice
I need some help, so I Wanna put how many votes I have on my botinfo. How can i show how many votes I have on top.gg?
thats probably a #topgg-api question @raven urchin
So, i have FFmPeg installed, and it has FFprobe but yet it's still coming up with this error message,
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: DownloadError: [0;31mERROR:[0m ffprobe/avprobe and ffmpeg/avconv not found. Please install one.```
there's a good few lines of it but that's the main error,
what
Why is this in #development ?
Using MongoDB with node. Is making a new client each time I want to query something a bad idea? For example: Someone runs a command e.g. settings and it queries the database instancing a new client.
Or should I have one constantly open and query that?
yes
Yes to what?
You're probably much better off opening one instance when you start your bot
Need some help with my bot. Any1 free?
Whenever someone uses a command in chat it also types "null" in the console. so my console is spammed with "null" over and over again
@cinder patio yeah iii did
But it still did the same
It sometimes does
And sometimes doesn't
It's weird
Hi
Ok
bot.on('message', message=>{
let args = message.content.substring(PREFIX.length).split(" ");
switch(args[0]){
case 'help':
message.channel.send({embed: {
color: 3447003,
title: "Help",
fields: [
{ name: "Commands", value: "!help\n!xur\n!lfg", inline: true},
]
}
});
break;
case 'lfg':
message.channel.send('https://www.bungie.net/en/ClanV2/FireteamSearch')
break;
case 'xur':
const attachtment = new Discord.MessageAttachment('./screenshot.jpeg')
message.channel.send(attachtment);
break;
}
@elder vine
yes
Can you show those lines?
Im kinda new to nodejs so dont be too harsh on me ๐
console.log(error) might be the issue
Is there a difference between client.on('ready' and client.once('ready'? I'd say the last one is only executed once, but how can this event be triggered multiple times instead?
I'm trying to make a server time feature on my bot. I want to send a message after a setup and update it every hour, but I also want users to be able to make changes if needed. How should I go about doing this?
How would I sent an embed via a webhook using eris?
@elder vine What do I put there instead?
Found the problem
It decided to log error even tho it did it properly
@nocturne grove the ready event should only be triggered once anyway (unless you are sharding), but I've never seen client.once anywhere, is that even working? ๐
which d.js version are you using?
@nocturne grove you are checking if there is an error, if so you log it. Then inside the else area, you log that same error. Which if it goes to the else block is obviously null
@nocturne grove you are checking if there is an error, if so you log it. Then inside the else area, you log that same error. Which if it goes to the else block is obviously null
@blazing portal
Sorry wrong mention Menno, forgive me :(
@buoyant totem this was meant for you
I'm trying to make a server time feature on my bot. I want to send a message after a setup and update it every hour, but I also want users to be able to make changes if needed. How should I go about doing this?
Can someone answer this?
ty!
Sbss can you explain this a little more? and what lib are you using?
its working now
discord.js
Pretty much I want to send an embed after a setup process is done, and update it once per hour
i'm coding with eris, and i can't find how to set the bot's status. if anyone could point me to a source that would be very appreciated
You sucessfully sent the embed?
okay ๐
i'll use vc names instead
ty!
@gritty bolt to start off you can do this in your ready event:
client.channels.get(id).send(message).then(message => { setInterval(() => {
message.edit(edit); }); });```
Hmm okay
i'm coding with eris, and i can't find how to set the bot's status. can anyone help?
Eris, a NodeJS Discord library
What kind of tickets, and which lib?
to create private rooms that staff can answer and use glitch xd
listen some events
which
which lib/lang do you use
Let's see xd that I'm more or less new, what is lib? and lang
which programming language do you use for code your bot
I use a page called glitch to put all the codes ect events
this is just a widget
not for posting server count
check this https://top.gg/api/docs#jslib
I use a page called glitch to put all the codes ect events
@upbeat vapor can you show your codes
I can invite you to my project and modify some things yourself if you want xd
<a href="https://top.gg/bot/691936549243191346" >
<img src="https://top.gg/api/widget/691936549243191346.svg" alt="Corona Stats" />
</a>
@summer torrent i have to edit my bot codes then?
yes
ans then?
dbl.getStats("264811613708746752").then(stats => { console.log(stats) // {"server_count":2,"shards":[]} });
then?
xd
... sad lyf
can u send me ss
Example of posting server count with supported libraries (Discord.js and Eris)
const Discord = require("discord.js"); const client = new Discord.Client(); const DBL = require("dblapi.js"); const dbl = new DBL('Your top.gg token', client); // Optional events dbl.on('posted', () => { console.log('Server count posted!'); }) dbl.on('error', e => { console.log(Oops! ${e}); })
this?
?
@upbeat vapor do you know javascript?
No, what is that ?

xd
first learn js basics pls
So i have this command called prefix which changes the bot prefix to anything you want if you have the manage server permission for that server...
But when i use this in my server it works but when i use it on other server it gives me that error below... (I type _prefix and that shows up without even changing the prefix)
where did you create it?
๐ญ
Created what?... The command? @upbeat vapor
Sep so you use packet or event because there are many things
Hmm
I use this 2 for the prefix and choose the specific channels for each command
and as you say you want to change the prefix xd
Lol
You are not really using a json file as your 'database'? ๐ฎ
I love using json files as database lmao
if I use base data because if not, the prefix ect is not created, do you want me to send you a photo?
@earnest phoenix XD
Wait what... I didn't get what you said lmao
for the prefix you need a database
@upbeat vapor json works too
hasPermission("MANAGE_SERVER" || "ADMINISTRATOR") is wrong
It works xd but I guide myself more if it haha
@summer torrent wait how is it wrong?
create a loop for that
@summer torrent loop for which one?
(Idk how it works tbh lmao)
wait why don't you just check for MANAGE_SERVER? because ADMINISTRATOR already has a manage server perm
@summer torrent i mean like when i only check for manage server and if the user has the administrator permission but doesn't have the manage server permission (check mark on the permission) ... It doesn't work
administrator has all perms
But as anyways that permission check literally works for every command that it needs...
@summer torrent wait...
If you scroll up and see that fs function... Does it need JSON.stringify() if the prefix that was provided was not a number?
Or it doesn't matter?
Wait i figured it out nevermind
hi, i was looking to dable a lil bit around making a discord bot for my own server.. which language would u guys suggest i start off with? some online sources talk about node.js n python
@hidden canopy in my opinion...
JavaScript + discord.js is the best option...
hm okay, thanks I'll take a look
Np
Whats a good library to generate api tokens for my api?
Guess ill just use uid-generator lol
I mean it doesnt need to be secure, its not like they're accessing personal information
So i have a command that everyone that has the Administrator permission in the server can use it... But... How can i make the bot not check for if i have the administrator permission or not?
(Because I'm the bot owner basically)
if(!<array of admins>.includes(user id)) check if a user needs admin
so basically If its not in the array of admins (on ur bot)
itll check for administrator
Oh i see... Thx
in embeds, is there a field that can have an image with text like the author? or is there any way to do multiple authors? (@ me)
So I have the idea to make a bot that could stop an alt account: Like maybe it could get the ip of the new user and search in the server if there is someone with the same ip. If there is the alt would get banned
But now my question is... Is there a way to find the user ip?
No, discord's api does not provide that information
That'd be a huge security concern
All bans are ip bans
well how can some people are able to come back with an alt?
VPNs
I'm fast as fuck boiiiiiiiiiii
Not u
Anyone want to give me an idea of something to code?
Please
I'm begging... the boredomness of the quarantine will kill me
(They told me to ask here)
Any library
a covid-19 command?
Lol dw I speak french
thanks for the idea!!
Again thanks for your help! ๐
you too
@Z4-bakedpotato#6969 you can't have multiple authors in your embeds but... You mean like write a text above the image in an embed?
Wait did he left? Lmao
const eris = require('eris');
callisto.on('ready', (callisto, msg) => {
callisto.editStatus({
status: 'online',
game: {
name: 'Users run !help',
type: 2
}
})
callisto.executeWebhook('698643966228431009', 'auth', {
embed: {
author: {
name: 'Ready',
icon_url: callisto.user.avatarURL
},
timestamp: true,
color: 'BLUE',
fields: [
{
name: 'Username',
value: `${callisto.user.tag}`
},
{
name: 'Guild Count',
value: callisto.guilds.size
},
{
name: 'user Count',
value: callisto.users.size
},
{
name: 'Time',
value: `${new Date()}`
}
]
}
})
console.log('[Callisto] Connected to Discord')
})
``` Anyone see anything wrong with this why it wouldn't set the status or send the webhook, but it console logs?
No errors
Is there a way to prevent shards shutting down for no reason or restart at the moment it shut downs?
if it shutdowns there's a reason and yes, check if it goes down or if you have a custom event system you can make it send an event to make your shard orchestrator restart it
so how can I restart it, I still donโt get the idea
@ember atlas I think embed is supposed to be embeds: Array<Embed>
Ya, I figured that out
hi
with my shardPreReady event, it takes an id var, and i just set my event handler how can i define id because the meesage is not being sent to the channel it usually does before i had it? Any ideas? My file looks like ```js
const { idle } = require('../../emotes.json');
module.exports = {
name: 'shardPreReady',
execute: (message, client) => {
client.createMessage('687774976631373846', {
embed: {
title: `Shard Pre-ready`,
description: `${idle} ID: ${id}`,
color: 0xfffffa
}
});
}
};
and my event handler looks like:js
client.events = new Eris.Collection();
fs.readdirSync('./events/').forEach((dir) => {
const evFiles = fs.readdirSync(./events/${dir}/).filter((file) => file.endsWith('.js'));
for (const file of evFiles) {
const event = require(./events/${dir}/${file});
client.events.set(event.name, event);
}
evFiles.forEach((f, i) => {
require(./events/${dir}/${f});
console.log(${i + 1}: ${f} event loaded.);
});
});``` the handler works, its just events which takes vars
with eris
how you attach the events to the eris client
oh
just with a try and catch thingy in the message event
like
try {
evFiles.execute(message, client)
} catch(e) {
console.log(e)
}```
how do you do it in the shardPreReady event?
the way i would do it in the event handler i just made, i shown above and usually its just```js
client.on('shardPreReady', (id) => {
client.createMessage('channel', {
embed: {
title: 'shard pre ready',
descritpion: ${idle} ID: ${id}
}}})
yes but show the code using the event handler
const { idle } = require('../../emotes.json');
module.exports = {
name: 'shardPreReady',
execute: (message, client) => {
client.createMessage('687774976631373846', {
embed: {
title: `Shard Pre-ready`,
description: `${idle} ID: ${id}`,
color: 0xfffffa
}
});
}
};
that?
show the client.on("shardPreReady") using that
client.on("shardPreReady", id => {
client.events.get("shardPreReady").execute()
})```
something like that
you showed the shardPreReady event as a file in the handler, and as hardcoded in the event itself, but you didnt show how you use the file in the handler
then what are you expecting?
idk, i thought that it would work like that
you created a file for the event, but you're not using it anywhere
kk, i'll do that
how do i edit the message the bot sent
(discord.js)
(javascript)
<message>.edit(string)
ok
if(message.content === '!hello'){
message.channel.send('hi')
message.edit('e')
}
})```
thats my code rn
how to fix to make it edit
u have to define it as something like reee = message.channel.send
but u have to await that
okay im lost
and reee.edit('pls dont ping me k')
Learn about promises. You have to send the message, wait, then edit that same message.
You're referencing the message any user sent.
Which could be not your own.
yea
if(message.content === '!hello'){
const reee = message.channel.send
message.channel.send('hi')
reee.edit('e')
}
});```
this still didnt work
Please learn JavaScript.
Jade and Eren, you both are the last survivors
Here's an example on editing messages: https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=edit
@still lily for example:
await message.channel.send("Doing something").then(async message => {
await message.edit("E");
});
});```
Can someone help me? I have this event handler: ```js
readdirSync('./events/').forEach(dir => {
const events = readdirSync(./events/).filter(file => file.endsWith('.js'));
for (let file of events) {
const evt = require(./events/${file})
let eName = file.split('.')[0]
callisto.on(eName, evt.bind(null, callisto))
}
for (let file of events) {
let pull = require(`./events/${file}`);
}
});
console.log([Callisto] Events Loaded)
ur probably nesting events?
what
Why are you requiring the file a second time, but not doing anything with it? Could you possibly show more of your code (Boss)? Maybe you're nesting events like officially said?
@still lily change that to:
if (message.author.bot) return;
await message.channel.send("Doing something").then(async message => {
await message.edit("E");
});
});```
that is the literally the code
i was talking about "its jake" about nesting events
lol
๐ณ
u dont have to await editing the message
idk, kinolte might be right, im stuck with creating an event handler myself shrug
@sudden geyser Ive just always done it like this (before switching to eris), it's my go to event handler and it just started having this issue today
Alright, and I assume that snippet of code is the top-level of your file (as in it'll only be run once)?
mhm
Its weird, i have 2 events logs and sends twice, 3 logs 3 times and sends the hook 3 times and etc
ive never done it like that
tbh, rarely edit messages
so, i wouldn't really kno tbh
sometimes an image or gif doesn't load in a RichEmbed, does anyone know why? Usually if I edit the embed afterwards, the image would load. It's as if it needs to be refreshed sometimes. Just curious why that happens?
@digital ibex editing an embed to other embed is satisfying tho lmao
That's a user specific issue
@wide ridge code?
i only edit a message for the ping command
Which I think is caused by just having your connection bork
While you might not see the image, others probably can
gopi, thats most likely ur connection or discord
probably discord
Occasionally it'll also just be discord being poopy and no one will see any images for a while
@late hill nope sometimes discord API can't fetch image URLs... That's the issue
O.O
as long as the url is a string, then its discord
.setImage(\`${gif}\`)
.setColor(\`${colorCode}\`)
.setDescription(\`${msgToSend}\`)
.setTimestamp();```
why is it a common af issue on mobile devices
yeah url is a string
@wide ridge wait a minute...
Why are you putting \? Instead of just \?
Backslash didn't appear lmao
um
https://canary.discordapp.com/channels/264445053596991498/272764566411149314/698694444152520734
- Read the
./events/directory. - For each directory:
a. Read the./events/directory and filter it for each JS file.
b. For each JS file:- Require the file (
./events/<file>) - Load the file.
c. For each JS file (again): - Require the file.
- Require the file (
- Log "Events Loaded"
@ember atlas I can't guess it off the top of my head, but does this sound normal? You'd essentially be reading the directory once to do it your usual once, but you're doing it again, so wouldn't it being it all over again for how many events you have to load?
because without having to contactonate or whatever tf its called
connactecate
yeah, idk how to spell it
Why are you putting \
? Instead of just?
@earnest phoenix that's in my broadcastEval for sharding
@wide ridge hmm... Anyway...
But always .setImage(`${gif}`) worked tho
@sudden geyser Went ahead and removed the last requiring the file, issue still persists
:D
original code is
.setColor(`${colorCode}`)
.setImage(`${gif}`)```
setimaghe never works for me
so yeah it's a discord issue
strange
kind of have to just get used to it I guess
it's not that common, but still happens occasionally
yes
it sucks getting bug reports from people thinking your bot is broken because the images don't load
@ember atlas, you're not doing anything with it, so it wouldn't be an issue (I think). I think it has to be with you requiring the same directory twice and looping it twice in the same loop. That's likely the cause of it re-requiring it for the number of events.
I just really dont get it
It's always worked til now
readdirSync('./events/').forEach(dir => {
const events = readdirSync(`./events/`).filter(file => file.endsWith('.js'));
for (let file of events) {
const evt = require(`./events/${file}`)
let eName = file.split('.')[0]
callisto.on(eName, evt.bind(null, callisto))
}
});
``` changed to this
If you removed readdirSync('./events/').forEach((dir) => { and the ending }), would that change anything?
That's what I've been talking about the whole time.
i used to do events/dir/file
Never fixed that 
Yep there it is
Sorry for me being dumb 

whats the equivalent of message.guildfor eris?
message.channel.guild
the smaller the library yes you can expand on it
or at least it becomes much easier
in fact you could make djs out of eris but that's just saying how easy it is to extend off of what eris provides for you
Can i ask what are PRIORITY_SPEAKER and STREAM and VIEW_GUILD_INSIGHTS permissions?
@earnest phoenix
Hmm what about the view guild insights? @ember atlas
Where do you see that at?
In the image
I believe that has something to do with partnered / verified guild things
Hmm
It's some kind of statistics i think
Need some help if anyone is available. Trying to embed the roles of the person who typed the command but I cant seem to figure it out
Can you show your code
Sure thing
switch(args[0]){
case 'info':
const info = new Discord.MessageEmbed()
.setTitle('User Information')
.addField('Player Name', message.author.username)
.addField('Roles', message.member.roles)
.setColor(3447003)
.setThumbnail(message.author.displayAvatarURL());
message.channel.send(info);
break;
This is the part that sends the embed
For you it looks like this right?
yes
message.member.roles is not a thing i guess. You need to look up the docs
Let me see real quick
Spent over an hour looking
@commands.has_permissions(administrator =True)
async def ban(ctx, member : discord.Member, reason=None):
await member.ban(reason=reason)
await ctx.send(f'Banned {member.name} for {reason}')
await user.send(f'Banned {member.name} for {reason}')```
I do not know why it is not sending the user that was banned the message
something like this orjan
No but I will try
kk
ahhh
So how would I modify the user.send what I do member.send
Yes
its fairly simple
@commands.has_permissions(administrator =True)
async def ban(ctx, member : discord.Member, reason=None):
await member.ban(reason=reason)
await ctx.send(f'Banned {member.name} for {reason}')
await member.send(f'Banned {member.name} for {reason}')``` so this
@fleet chasm How do I make that line between (' ')
like space the roles out
first send message then ban
Yeah but how do I type that symbol
ahh yes cry
| copy that @buoyant totem
forgot about that lmao
ty
Also in that command it only takes the first word for the reason how would I get to take the entire sentence
when you ban, you remove the user from the guild, effectively making your bot to not meet one of two conditions to send a dm
I just got an error with it @fleet chasm
here's how it looks rn
switch(args[0]){
case 'info':
const info = new Discord.MessageEmbed()
.setTitle('User Information')
.addField('Player Name', message.author.username)
.addField('Roles', message.member.roles.map(r => `${r}`).join(' | '))
.setColor(3447003)
.setThumbnail(message.author.displayAvatarURL());
message.channel.send(info);
break;
}
roles.cache
async def ban(ctx, member : discord.Member, *, reason=None):
if you are on v12?
you should learn python @outer niche
roles.cache.map then
ah ok
I know Python it would not help if I was in the hospital though
And on a crap ton of drugs
https://discordjs.guide/additional-info/changes-in-v12.html you can look at this for changes in v12 orjan
np
@outer niche how about sending before banning
Thats already been mentioned
@commands.has_permissions(administrator =True)
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)
await ctx.send(f'Banned {member.name} for {reason}')
await member.send(f'Banned {member.name} for {reason}')```
This does not send a DM to the user And it does not capture the entire sentence like I wanted it to does anybody know what happened where I went wrong
we told you
send the message
before banning
or else it'll error
cause the member will no longer be in the guild
@commands.has_permissions(administrator =True)
async def ban(ctx, member : discord.Member, *, reason=None):
await ctx.send(f'Banned {member.name} for {reason}')
await member.send(f'Banned {member.name} for {reason}')
await member.ban(reason=reason)``` this
try it out and see
when a guild experiences an outage and recovers, will the guild.available be true by the time the guild create event fires for that guild
A guild becoming available triggers guild create?
some libraries,
Weird
now i have a problem i could use help with
function copythings(filename) {
var copyfield = document.getElementById("copyfield")
copyfield.value = `ree+${filename}`
copyfield.select()
document.execCommand("copy")
copyfield.value = ""
}
<textarea id="copyfield"></textarea>
so the issue here is, when i run copythings nothing gets put in the text area
npm WARN addon-development@1.0.0 No repository field.
npm WARN addon-development@1.0.0 No license field.
npm ERR! path /app/node_modules/.bin/node
npm ERR! code EEXIST
npm ERR! Refusing to delete /app/node_modules/.bin/node: ../node/bin/node symlink target is not controlled by npm /app/node_modules/node
npm ERR! File exists: /app/node_modules/.bin/node
npm ERR! Move it away, and try again.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npm-cache/12.0.0/_logs/2020-04-12T02_33_01_168Z-debug.log```
weird
when i tried to install that api package
It still does not work
TheNoob, I can't confirm it, but it probably will be true.
or reload the cog
Yes
send the code again
im not good with html but try innerHTML 
@commands.has_permissions(administrator =True)
async def ban(ctx, member : discord.Member, *, reason=None):
await ctx.send(f'Banned {member.name} for {reason}')
await member.send(f'Banned {member.name} for {reason}')
await member.ban(reason=reason)```
nah nvm
@earnest phoenix its in glitch
How am I suppose to get the shard ID in ready event
? @edgy heron
did you ask me to restart> trash?
@outer niche wait is this in a cog?
mention names then multiple peeps asking for support lol
npm i dblapi.js
npm WARN addon-development@1.0.0 No repository field.
npm WARN addon-development@1.0.0 No license field.
npm ERR! path /app/node_modules/.bin/node
npm ERR! code EEXIST
npm ERR! Refusing to delete /app/node_modules/.bin/node: ../node/bin/node symlink target is not controlled by npm /app/node_modules/node
npm ERR! File exists: /app/node_modules/.bin/node
npm ERR! Move it away, and try again.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npm-cache/12.0.0/_logs/2020-04-12T02_33_01_168Z-debug.log````
and commands.
No none of my administrator commands are in a cog
Skullbite, i cant help you. Im sorry.
it's gucci

How am I suppose to get the shard ID in ready event? Helpppp
@outer niche go to discord.gg/dpy
Ok
How am I suppose to get the shard ID in ready event? Helpppp
How large is your Bot?
ping me when someone gonna reply
@outer niche did you install py global?
what
@grizzled raven so innerText, innerHTML and value don't change
yeah idk
You're fine
So yea, go to dpy server, they can help better
are you sure the func gets ran?
in what langauge
Js
idk
This guide in https://top.gg/api/docs#jslib is outdated
hyper told me? outdatedd?
wut
@ocean violet maybe...
<client>.shard.id?
Thats exactly the code in v11 but I am in v12
@ocean violet it's the exact same on v12 tho
@ocean violet can you help me with v12?
What do you need
its say 401 unauthorized error
Example
Example of posting server count with supported libraries (Discord.js and Eris)
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your top.gg token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})```
v12....
@ocean violet maybe try:
<client>.shard.shards.id...
Where did the error occurs
Oops! Error: 401 Unauthorized
Did you spam their api
Hmm Unauthorized... I never saw that error on dbl server count post before
401 Unauthorized Error Occur: This error may occur due to the reasons described below:
It may occur client does not provide the proper authentication credentials to the server within the request time.
It may occur when the server rejects the request of the client for some reasons even though the client provides proper authentication credentials.
When the client is banned for some reasons by the server.
I guess you spammed their api?
Probably wait 1 hour and try agian
I just accidentally spammed the api by not setting the interval time
i just copy pasted their code
did you alter anything
onst dbl = new DBL('SECRET', bot);
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
bot.shard.fetchClientValues('guilds.cache.size')
.then(results => {
console.log(`${results.reduce((prev, guildCount) => prev + guildCount, 0)} total guilds`);
})
.catch(console.error);```
i did
i putted

xD
Where is this file
also add an interval
if someone spams your guild event you'll most likely get ratelimited
Glitch only allows port 3000 connection
DBL doesn't like bots hosted on glitch and other similar platform
doesnt like
lol
@latent willow this bot is hosted in glitch, still he have total server counts in his top.gg bot page
your bot sent a bad request
hi
let GuildModel = require('../../models/Guild');
const guild = await GuildModel.findOne({ id: message.channel.guild.id });
console.log(guild.prefix);
console.log(guild.welcome.channel);
console.log(guild.welcome.message);
try {
if (!args.length) {
message.channel.createMessage(`Please provide a channel for me to greet new members!`);
}
let channel = guild.welcome.channel;
if (channel === null) guild.updateOne({ channel: args[0] }).then((e) => console.log(e));
await guild
.updateOne({ channel: args[0] })
.then((e) => message.channel.createMessage(`Successfully set the welcome channel to <#${args[0]}>`));
} catch (e) {
console.log(e);
message.channel.createMessage(errorInE);
}
``` i am trying to set a welcome channel and uh
its logging null when i set the channel, any ideas why?
my guildschema:
the welcome bit: js welcome: { message: String, channel: String }
what version of d.js are you using by any chance
how to make my bot save all emotes from all guilds its in to a file (python) because i cant do it bcoz im an idiot
umm
My bot is hosted on glitch
I would be able to help with the write file part but its python sooo
same Rag
its reliable-ish
just space is super lower compared to ram lmao
500mb of ram but my bot uses 40mb of ram 1% cpu usage and 196mb of the 200mb of storage an oof
I really need to get a self pinging script in mine, rn it's relying on uptime robot which goes down like every 2 hrs
i need some help, on my bot i entered a command and it does not say anything
but thats kinda a good thing kinda like auto restarts that you didnt ask for
I have to manually restart mine usually
why?
Idk why
What do I need in my package?
"scripts": {
"start": "node bot.js"
},
"engines": {
"node": "12.16.1"
},
start is the script that starts the bot
and node is just your node.js version that you want it to use
Yeah I have that
Although I wrote it in node 13, and glitch runs it at 10, idk if that affects it
why host on glitch?
Heroku is another free option AND python bots atleast continue working even after your hours are up
glitch and heroku r both shit
I'm really getting annoyed with this stupid thing, my bot keeps running two instances
my bot wont say anything when i use a command
u uh
token
delete
now
probably should send it without the token and regen another 1 tbh
import asyncio
from discord.ext import commands
bot = commands.Bot(command_prefix = '<')
@bot.event
async def on_ready():
print("ready")
@bot.command(pass_conetext=True)
async def ping(ctx):
await bot.say ("ping")
bot.run("heres my token b ru h")```
and i regen the token
tbh
nobody could even do anything to my bot
because it in one server with only me
and i could just
yknow
ban it
so
what am i doing wrong
@digital ibex I can show u an easier way to do that welcome
how?
holdon
blaine, i don't know python very well
oh
since i cant fetch more than 100 messages can i fetch 100 then use the oldest as the before parameter of another fetch?
i need more info on dat
language doesnt matter as im talking about the api in general
@ripe lantern Messageable.send
Messageable is any object you can message on Discord: users, members (in d.py at least) and text channels
ctx aka Context object inherits Messageable so you can do ctx.send
What's your code
import asyncio
from discord.ext import commands
bot = commands.Bot(command_prefix = '<')
@bot.event
async def on_ready():
print("ready")
@bot.command(pass_conetext=True)
async def ping(ctx.send):
await bot.say ("ping")
bot.run("token")```
i did put in the token i just edited the message
Actually hold up, what's your discord.py version
you can do print(discord.__version__)
ok
it says that "discord" is not defined
so whats up w dat?
oh wait
i just had to import discord lol
1.3.3
hi
ya?
try {
let guild = await GuildModel.findOne({ id: message.channel.guild.id });
let channel = guild.welcchan;
if (!args.length) {
message.channel.createMessage(`more args pls`);
} else {
channel = args[0];
await guild
.updateOne({ channel: channel })
.then((e) => message.channel.createMessage(`channel: ${channel}`));
guild.save();
}
} catch (e) {
console.log(e);
message.channel.createMessage(errorInE);
}
``` with mongoose, why is this not saving into compass?






