#development
1 messages · Page 998 of 1
wdym
line 26
function getCoins(message) {
con.query(`SELECT * FROM economy WHERE id = ${message.author.id}`, async function (err, result) {
if (err) throw err;
return result[0]
});
}
keys() is not a function
how do i make it a function?
he works on a pokebot clone.
as in the thing that's causing the error, not the bot's overall purpose
well this sums it up
Check your package.json
did u watched it from youtube @long yew
no
ok
console.log(Discord.version)
did it works now @earnest phoenix
nope
are you sure its the DB query that makes the issues?
try{
var coins = await getCoins(message);
if(!coins) coins = await newUser(message);
console.log(coins);
}catch(e) {
message.channel.send("Oops, there is a error !")
return console.log(e)
}
it says indefiened
and was looking back at it
function getCoins(message) {
con.query(`SELECT * FROM economy WHERE id = ${message.author.id}`, async function (err, result) {
if (err) throw err;
return result[0].coins;
});
}
my code is version ^11.5.1
nvm add async infront of the function
how do i make the bot v11?
async function getCoins(message) {
con.query(`SELECT * FROM economy WHERE id = ${message.author.id}`, async function (err, result) {
if (err) throw err;
return result[0].coins;
});
}
Probably do this in your code
console.log(Discord.version)
what do you even want to do with your client.guilds
does it say what line?
can you copy the error here or make a screenshot of it?
hmm
what does it return if you add a console,log(result[0]) inside of the DB query function?
How do i connect my github to Atom
then?
oh
read the docs like suggested on the page
i was doing int(25)
do int 255
or max but im not sure if your Mysql version supports it
I dont know how i can login in Atom with Github :/
What was guild.keys() in v11?
it will prevent duplicates
I dont know how i can login in Atom with Github :/
@surreal sage help?
what
@surreal sage use VSCODE
ok
@surreal sage open the github panel
ima use vscode
CTL+9
?
how i can stop the query
cuz when i want to create a new user
i need to stop the getData()
asd
cuz it says Handshake in Handshake
@lusty quest ?
Hi, I'm trying to do addrole command (addrole to all members), but I have one problem.. Bot sends a message, but he edits that.. I wanna do -> Bot sends message (adding roles), bot adds roles and THEN he edits message. (Done)
Csn anybody help me, please?
code?
.then(//edit)
@earnest phoenix i dont think its still the query
huh
i dont see anything in there that should cause it
const embedls = new MessageEmbed()
.setTitle(` Adding role ${role.name} to all members..`)
.setColor(red_light)
.setDescription(`This will take a while..`);
message.channel.send(embedls).then(async msg => {
await message.guild.members.cache.filter(m => !m.user.bot).filter(m => !m.roles.cache.has(role.id)).forEach(async n => {
await n.roles.add(role).then(async s => {
let all = await message.guild.members.cache.filter(m => !m.user.bot).filter(async m => !m.roles.cache.has(role.id)).size;
const success = new MessageEmbed()
.setTitle(` Done`)
.setColor(red_light)
.setDescription(`Successfully added role **${role.name}** to **${all}** members`);
msg.edit(success);
});
});
});
}
here
Help with discord.py
How do I make it so it checks if the bot has the permission to do something. like I have a say command which works like the carl bots echo command and it says anything you want it to say and deletes your original message but I want to make it so if the bot doesn’t have the permission to delete the message then it just says it and doesn’t delete the message?
have you heard about commas and periods
https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel.permissions_for
aka message.channel.permissions_for(message.author)
Nope
Since that function returns a Permissions object, get the manage_messages property and see if it's equal to True
Hi, I'm trying to do addrole command (addrole to all members), but I have one problem.. Bot sends a message, but he edits that.. I wanna do -> Bot sends message (adding roles), bot adds roles and THEN he edits message. (Done)
Can anybody help me, please?
@rustic sundial
Ok
i had done something like this but different
const inProgressEmbed = { title: 'Processing search...', color: 0xF1C40F }; //the embed
const sendmessage = await message.channel.send('', { embed: inProgressEmbed })//save the message Object and send the Embed
//Add Role
//Create your embed when done
sendmessage.edit(embed)
how to access glitch.com terminal through javascript?
@rustic sundial
@lusty quest hi your brain is super can you help me with mah problemo
i never used glitch
f
how to access the node.js terminal then
because thats what glitch.com is
atleast what we poor people use it for
client.on("message", (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
if (message.content.startsWith(`${prefix}ban`)) {
if (!message.member.hasPermission("BAN_MEMBERS")) {
message.channel.send("You don't have permission to use this command! :no:")
} else if (message.content.startsWith(`${prefix}ban`)) {
let member = message.mentions.members.first();
member.ban()
message.channel.send(member.displayName + " has been kicked! :chains:")
}
}
})
can somebody please help why does my bot say that twice?
did you have 2 instances running?
and it doesnt send the emoji at first but sends in the next message
wtf why did you call the event every time?
also can someone tell me how to add delay in commands
setTimeout(MS);
Help with discord.py
How do I make it so it checks if the bot has the permission to do something. like I have a say command which works like the carl bots echo command and it says anything you want it to say and deletes your original message but I want to make it so if the bot doesn’t have the permission to delete the message then it just says it and doesn’t delete the message?
And my code so far is
L
@client.command(aliases=['speak', 'echo', 's'])
async def say(ctx, *args):
mesg = ' '.join(args)
await ctx.channel.purge(limit=1)
return await ctx.send(mesg)
is MS in javascript 1000th of a second?
yea
so 5000 is 5 seconds right
Hmm
@fresh hatch i know why you get 2 messages
why?
it runs 2 command at the same time (kick and ban)
Why not use @commands.bot_has_permissions
Ah right
but the kick command checks after he sends the message the name of the command
Oh hat
That returns the permissions for the user
I used it
Oh
Wait
Let me try
if you dont have the permission to kick a member you get the error even if you run the Ban command
You could use the permissions_for thing
@rustic sundial
@lusty quest thank you so much, I'll try it
Also, why don't you use *, args
You could use the
permissions_forthing
@slender thistle How?
@fresh hatch copy the 3rd line from the Ban command and add it to the kick command. then rename it to kick
aka
message.channel.permissions_for(message.author)
Where do I use it
@lusty quest i used :
var randomguytohack = message.guild.members.random();
message.channel.send("Hacking "+randomguytohack);
setTimeout(5000); //the thing that is giving errors
message.channel.send("nope coudnt hack em");
But it is giving me the error TypeError: "callback" argument must be a function
😀
help with my problemo someone
console.log('boo')
}, 100)``` this will create a 100ms timeout
Does that return a list in which I need the find the manage_messages permissions value?
it returns an object where you access a property
aka returned_object.some_property
Oh
create a function where you send the message and call it
ok
that property then returns a boolean value
or replace the console.log with the message.send
so it is basically defining then i need to callit
Shiv what lib do you develop
dblpy
cool
finally fixed
Please use one message event
if ctx.channel.permissions_for(ctx.guild.me).manage_messages:
#Has permission
else:
#Doesn't have permission```
@fresh hatch i recommend getting a proper command handler
Like this?
or use a switch case
yup
🙂
im waiting for {TheSourceCode}'s command handler tutorial
@lusty quest didn't even need to call it it worked on its own
thanks
now i can hack people in my bot HHEHEHE
python Public Flags how to do it
@fresh hatch make your own, don't use code you dont understand
mee6 dab some music for meh
Thanks @slender thistle for the help :)
@tiny venture what
public flags Of python@slender thistle
@fresh hatch its not bad https://discordjs.guide/creating-your-bot/adding-more-commands.html#the-problem-with-if-else-if
i fixed it
What's discord.py version?
its just the style of wrting with the dots in between always suggests to me that the first thing is resolved before the next gets executed
@viral spade in mongo's case you get a "cursor" when you run find on a model, then you can extend the cursor's search with the extra methods and finally execute it to get the results
hi can anyone help me?
Just ask
Your on 12 right?
instead of what?
guilds?
can u help me change some of my code to v12?
also where did u find that cache thing on that link?
Managers/cache
Its a property
There is a guide that lists everything you have to change from v11 to v12, just use it lol
Yeah I gave it
is this also outdated?
to spawn a pokemon
It's a object or a array?
Smh
wdym u spelt it wrong so i was wondering what u meant
Oh yea, sry
function spawnMon() {
if (currentMon) {
despawnMon();
}
for (var key in trainers) {
trainers[key].currentBalls = Config.numberOfAttempts;
trainers[key].catching = false;
}
currentMon = {};
currentMon.id = Math.floor(Math.random() * Math.floor(dex.length)) + 1;
currentMon.name = dex[currentMon.id - 1];
currentMon.level = Math.floor(Math.random() * Math.floor(100)) + 1;
currentMon.catchChance = (Config.catchDifficulty / currentMon.level);
currentMon.spawnId = Math.floor(Math.random() * Math.floor(9999999 - 999999)) + 999999;
while (spawns.includes(currentMon.spawnId)) {
currentMon.spawnId = Math.floor(Math.random() * Math.floor(9999999 - 999999)) + 999999;
}
spawns.push(currentMon.spawnId);
updatePoke();```
that is the whole
actually nvm i'm gonna make a whole new bot in v12
Good choice

also
start with a proper DB from the Beginning
a json db is easy to make but horrible to maintain
I dont see where people are getting the tutorials for these json db's.
Most newbies seem to use them, but I dont understand why.
What guide, or tutorial is pointing people that way 
they probably find random youtubers that recommend them in a 4 years old video

MongoDB, Postgres or mysql (these are proper one) otherwise enmap or quickdb(upgrade to jsondb)
wait
Basically SQL and NoSQL databases
so what is the difference between mongoDB and quickDB?
quickdb is sqlite
what is SQL?
and mongodb is NoSql
what is squilite?
SQL ( (listen) S-Q-L, "sequel"; Structured Query Language) is a domain-specific language used in programming and designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS)....
sqlite is sql but the lite variant (usually local on the machine)
ok so should i use quickDB?
if you want. i never used it, but i can give you some hints with enmap
Just because its name contains "quick" doesn't really mean it's more performant compared to, say, mongo or any other SQL database
ok then i'll do mongoDB
its a sqlite database it will never beat a SQL or NOSQL db
hi, i have this code: js app.post( '/login', passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login', failureFlash: true }) ); does anyone know why im getting this error?
when i've used it before..
i've got no idea why this is happening..
if you want. i never used it, but i can give you some hints with enmap
ok ty
i did npm install quick.db
where do i put this?
var db = require('quick.db')
ohhhhhh
ik
wait @lusty quest what do i use?
const db = require('quick.db');
or
var db = require('quick.db')
How's it possible to change your bot host's ip so that the ip trackers see it's ip as whatever you want... For example... The ip tracker normally shows the ip... But how to make it show the text you want instead of your ip?
so you want a domain?
lol
Huh?
@lusty quest i mean just like this bot does
Shows BRUH instead of the real ip
lol havent seen this in a long time
but idk how they have done it. maybe they found some hacky workaround
@earnest phoenix have you got a webserver?
No
i'd assume you'd need a webserver to do something like that
im not sure tho, only because you can check when someone clicks on it
Hmm... How would that be modifying the ip even though you're screenshotting the website with puppeteer
Hmm
are you seeing this on the actual website?
or did someone just take a screenshot, and edit the screenshot to say BRUH

It probably recognizes the ip text and edits it out yea
It's the bot that has an screenshot command that literally takes an screenshot of the website and replace the ip with the text they want
OCR time
Smart but someone could easily spin up a web server and have the ip split onto 4 lines
I have no idea how's that still modifying the original ip from the website... The _root would be impossible for that but... This is just a tf moment

why not just canvas?
hm
It's a screenshot it's easy to edit it out
It's literally doing that to every possible ip tracker website
does anyone know why js app.post( '/login', passport.authenticate('local', { successRedirect: '/', failureRedirect: '/login', failureFlash: true }) ); is giving me the error: Error: Unknown authentication strategy "local" ?
yeah, thats not the issue tho
no, because i have to put my email and password in
so ig yeah, but a very slow loop
Oh wait... Holy shit... I know how they did that... They receive the html first and initialize though the _root path to see if it includes the ip then modifies it... Dude this is fucking genius

They could do that too but as i said someone can easily spin up a web server and have the ip split onto 4 lines so 12.56.12.123 becomes
12
56
12
123
Oh his bot didn't do that on a specific website what

He himself revealed it by using that website 
OfficiallyLost do you have passport-local installed?
Seperate package for passport http://www.passportjs.org/packages/passport-local/
yeah
i had that issue with my discord oauth
and i fixed that simply doing ```js
// old broken - giving same error but with 'discord' instead of 'local'
require('passport-discord').Strategy();
// new version - doesn't error or works as intended
require('passport-discord').Strategy;
and i doubled checked that, but it still errors
Heya
if (msg.mentions.has(bot.user)) {
msg.channel.send('My prefix for this guild is ' + prefix)
}
its not working
nvm
fixed

oh it gets the guild prefix
is your url correct?
its a hidden file
okay
const mongoose = require('mongoose');
module.exports = {
init: () => {
const dbOptions = {
useNewUrlParser: true,
autoIndex: false,
useUnifiedTopology: true,
poolSize: 5,
connectTimeoutMS: 10000,
family: 4
};
mongoose.connect('mongodb://localhost/yourdb', dbOptions);
mongoose.set('useFindAndModify', false);
mongoose.Promise = global.Promise;
mongoose.connection.on('connected', () => {
console.log('[NOTICE] Mongoose connection successfully opened!');
});
mongoose.connection.on('err', err => {
console.error(`[ERROR] Mongoose connection error: \n ${err.stack}`);
});
mongoose.connection.on('disconnected', () => {
console.log('[NOTICE] Mongoose connection disconnected');
});
}
};
``` this is what i use and i dont have any issues
how do I use MONGODB for prefix
@lusty quest local host adress is 127.0.0.0 - is that right?
Yes
ok thx
yes
@misty sigil the only thing i found for now is a small YT video series that is somewhat recent
hah
@misty sigil https://www.youtube.com/watch?v=RhRj4Rx39u0
he also got a Github Repo up with the code
Where can I find detailed information about BOT certification?
you mean certification like through discord?
ah sry I mean
get to be vertified developer
Discord
13+
the legal limit for Discord
Alright thanks
as you have to provide an Id, you will 100% get denied for lying about age
I was worried because I heard 18+ needed in somewhere :/
closes the ban tab
nah
not sure if you HAVE to be 18+ to get verification, though most of the official documents they'll accept you'll likely only obtain when youa re 18+
one exception is passport, they do accept that
you can get a ID here with 12 if you want
hey guys hope everyone is well today, im getting this error Error [SyntaxError]: Unexpected identifier when its trying to get the channel like this just wondered if anyone could give me some advice on it thanks a lot
.then((results) => {
if (results.find(r => r !== null)) {
const leftserverEmbed = new Discord.MessageEmbed()
.setTitle('Blacklisted Server! :warning:')
.setDescription('**__The Server__** ' + results.find(r => r !== null) + ' **__Has Been Blacklisted!__** :warning:')
.addField('Reason:', reason.replace(args[0], '').trim())
.setTimestamp()
client.shard.broadcastEval(`const channel = this.guilds.cache.get('714642375997259837');
if (channel) {
channel.send(${leftserverEmbed});
}`)```
is this the complete error?
yes
well this
Error [SyntaxError]: Unexpected identifier at Client._eval (C:\Users\jamie\Music\Bots\Project Bump\node_modules\discord.js\src\client\Client.js:391:17) at ShardClientUtil._handleMessage (C:\Users\jamie\Music\Bots\Project Bump\node_modules\discord.js\src\sharding\ShardClientUtil.js:185:82) at process.emit (events.js:322:22) at emit (internal/child_process.js:876:12) at processTicksAndRejections (internal/process/task_queues.js:85:21) { name: 'SyntaxError'
thats the channel id
client.shard.broadcastEval(`const channel = this.guilds.cache.get('714642375997259837');
if (channel) {
channel.send(${leftserverEmbed});
}`)```
what exactly are you trying to get putting const and if's inside this
it basically finds the channel and if it finds it it will send the embed within that channel
have you never seen a broadcastEval before?
not at all
It runs that code across all shards, they seem to be trying to send a message to a specific channel when the bot enters and leaves a blacklisted server
becuase when i blacklist a test server it does send the message to the guild owner which is with broadcastEval so that part is working
yes once a server is blacklisted it sends a embed to my blacklisted servers channel how it does currently with my main bot
can you show the entire file?
why would you need to see my whole file lol
Because you have a syntax error and it doesnt come from there
unless you didnt close the .then
I just assume you did
i can post the whole blacklist command if you wish
well one sec
this.then((results) => {
if (results.find(r => r !== null)) {
const leftserverEmbed = new Discord.MessageEmbed()
.setTitle('Blacklisted Server! :warning:')
.setDescription('**__The Server__** ' + results.find(r => r !== null) + ' **__Has Been Blacklisted!__** :warning:')
.addField('Reason:', reason.replace(args[0], '').trim());
client.shard
.broadcastEval(`const channel = this.guilds.cache.get('714642375997259837');
if (channel) {
channel.send(${leftserverEmbed});
}`);
};
});```
you just missed a ) in the end @earnest phoenix
there actually might be an error I didnt see in there
Yeah you need to close the if and the then if you didnt
hmm i never had this error
this is code
@opal plank i forgot to post the end part too
client.shard.broadcastEval(`const channel = this.guilds.cache.get('714642375997259837');
if (channel) {
channel.send(${blacklistedEmbed});
}`)
con.query(`UPDATE testing SET blacklist = 1 WHERE guildid = ${args[0]}`, (err) => {
if (err) console.log(err)
sendEmbed(msg, 'Successfully Blacklisted Server! ⛔.')
})
} else {
sendEmbed(msg, `${args[0]} is not a guild id!`)
}
})```
did you mean to use 127.0.0.1?
@earnest phoenix .............
you could aslo use localhost or 0.0.0.0 I assume
post the whole thing dude
okay haha
blacklist: (msg, prefix) => {
if (msg.author.id !== '318089600050528257') { sendEmbed(msg, 'You cannot execute this command') }
const reason = msg.content.substr(msg.content.indexOf(' ')).trim()
const args = msg.content.slice(prefix.length).trim().split(/ +/g).slice(1)
client.shard.broadcastEval(`const guild = this.guilds.cache.get('${args[0]}');
if (guild) {
const guildOwner = this.users.cache.get(guild.ownerID);
guildOwner.send('You Have Been Blacklisted For Violating Our ToS https://projectbump.xyz/ToS :warning: Please Join Our Support Server To Appeal! https://discord.gg/SrEUJ4z');
}
guild ? guild.name : null;`)
.then((results) => {
if (results.find(r => r !== null)) {
const blacklistedEmbed = new Discord.MessageEmbed()
.setTitle('Blacklisted Server! :warning:')
.setDescription('**__The Server__** ' + results.find(r => r !== null) + ' **__Has Been Blacklisted!__** :warning:')
.addField('Reason:', reason.replace(args[0], '').trim())
.setTimestamp()
client.shard.broadcastEval(`const channel = this.guilds.cache.get('714642375997259837');
if (channel) {
channel.send(${blacklistedEmbed});
}`)
con.query(`UPDATE testing SET blacklist = 1 WHERE guildid = ${args[0]}`, (err) => {
if (err) console.log(err)
sendEmbed(msg, 'Successfully Blacklisted Server! ⛔.')
})
} else {
sendEmbed(msg, `${args[0]} is not a guild id!`)
}
})```
how to use bot game stats
Hello,
i want a embed for my website on discord. I use this:
<meta property="og:title" content="Hxlper">
<meta property="og:type" content="website">
<meta property="og:url" content="LINK">
<meta property="og:description" content="Beschreibung">
<meta property="og:image" content="https://cdn.discordapp.com/avatars/704614453165031454/e99a05530d221beac75f65e82792d713.jpg?size=512">
<meta name="theme-color" content="#9F81F7">
But this doesn't work 😢
sry
@rustic sundial I use https://oliy.is-just-a.dev/44vbp9_4841.png but this is with the mongo driver, not sure how it exactly works with mongoose.
@earnest phoenix ```js
blacklist: (msg, prefix) => {
if (msg.author.id !== '318089600050528257') { sendEmbed(msg, 'You cannot execute this command') }
const reason = msg.content.substr(msg.content.indexOf(' ')).trim()
const args = msg.content.slice(prefix.length).trim().split(/ +/g).slice(1)
client.shard.broadcastEval(const guild = this.guilds.cache.get('${args[0]}'); if (guild) { const guildOwner = this.users.cache.get(guild.ownerID); guildOwner.send('You Have Been Blacklisted For Violating Our ToS https://projectbump.xyz/ToS :warning: Please Join Our Support Server To Appeal! https://discord.gg/SrEUJ4z'); } guild ? guild.name : null;)
.then((results) => {
if (results.find(r => r !== null)) {
const blacklistedEmbed = new Discord.MessageEmbed()
.setTitle('Blacklisted Server! :warning:')
.setDescription('The Server ' + results.find(r => r !== null) + ' Has Been Blacklisted! :warning:')
.addField('Reason:', reason.replace(args[0], '').trim())
.setTimestamp()
client.shard.broadcastEval(const channel = this.guilds.cache.get('714642375997259837'); if (channel) { channel.send(${blacklistedEmbed}); })
con.query(UPDATE testing SET blacklist = 1 WHERE guildid = ${args[0]}, (err) => {
if (err) console.log(err)
sendEmbed(msg, 'Successfully Blacklisted Server! ⛔.')
})
} else {
sendEmbed(msg, ${args[0]} is not a guild id!)
}
})}
whoops
same issue, forgot a } in the very end
oh okay
lol I just use notepad ++ as an editor is that bad then?
lol
so thats why becuase the .then is outside the first eval
@earnest phoenix collapse your categories to quickly find where your syntax is wrong
Or there's a problems section
And you can click on the problem to take you to the erroring location
¯_(ツ)_/¯
whats that one lol
i cant even find that ex
if you dont have a linter or anything of the sort, you doing vsc wrong
i have eslint
dont use two formatters
either use linter or prettifier
beautify is fine too
okay so is the problem because the .then is outside the first eval
.then is ON the eval
client.shard.broadcastEval()
.then((results) => {
If you having issues to see it, try removing all the stuff in between to make it clearer
This is repounceBody
{"701141875628834906":{"name":"comunity","enable":true}}
Hello,
i want a embed for my website on discord. I use this:
<meta property="og:title" content="Hxlper">
<meta property="og:type" content="website">
<meta property="og:url" content="LINK">
<meta property="og:description" content="Beschreibung">
<meta property="og:image" content="https://cdn.discordapp.com/avatars/704614453165031454/e99a05530d221beac75f65e82792d713.jpg?size=512">
<meta name="theme-color" content="#9F81F7">
But this doesn't work 😢
ffs yall keep spamming your questions instead of waiting
dont spam
dude
if it is then it's your cache
i get them there
you gotta be kidding me
oh shit
why the f would you share your key here
how did u even get bot aproved
a website that i know is using the same tags, and this work
huh
there is an id the key
i dont understand
Look it has NAME
and you want to get the name out of it?
yes
[0]
@earnest phoenix a nested property is name
return[0]
and that's not an array
yes it is not a array
It's an object
you'd need to access the property, it looks like an id: {name, enable}
you could recursively flatten it if you wont know the key on get
look
Object.keys
That could work
look output
do value
where
without deleting that line, right above it log the repounseBody because something has to be wrong
That wouldnt work
remember theres a typo up there
Object.values returns a value, not a key
object[objectvalue] wouldnt return anything
It doesnt matter, his code has the typo...
if it didnt it'd say cannot read property "x" of undefined
on the object
holdup
doesnt want to embed
whatever
The point being it's the name of the response variable
probably just a bad translation
I'm trying to deploy my discord bot to Heroku but heroku doesn't like the line import discord. It says: ModuleNotFoundError: No module named 'discord'. What can i do? (discord.py)
dude
@amber fractal if i do respounce instead of repounce it says undefiened
so the dev who created the Module has a bad translation
@languid pollen have you tried to install the module?
you mean installing discord.py, then yes. My bot worked just fine before
this error is annoying me hahah
any way i can get it to log something that will tell me whats happening with it
its not posting the embed in that channel for some reason and i dont get an error either lol
@still merlin cant help if you dont post code
ik
client.on("message", (message) => {
const args = message.content.split(" ").slice(1);
if (message.content.startsWith(prefix + "eval")) {
if (message.author.id !== "529770099285032980")
return message.channel.send(
"**error** Only the bot owner can execute this command!"
);
try {
const code = args.join(" ");
let evaled = eval(code);
if (typeof evaled !== "string") evaled = require("util").inspect(evaled);
message.channel.send(evaled);
message.channel.send(
"``:x: Error preforming eval command``" + "(" + err + ")"
);
}
}
});
and error is finally expected
there we go
but that does that mean??
@still merlin you're missing a catch or finally
it expects a finally
helpful I dont even know how to write a finally or a catch
the syntax of try/catch is
...
}catch(e){
}finally{
}``` or
```try{
...
}catch(e){
}```
so, where do i even start on this mongodb stuff
catch (err){console.error}
hi, does anyone know how can i get a html element in backend code?
..
you kept ...
I dont have a ,,,
ald you put that at the end of your try
It isnt just a copy paste solution
the ... is the code you put in the try
refer to the docs I sent
This is also performing not preforming 
again, it isnt a copy paste solution
refer to the docs I sent. you're doing try{}try{}catch(e){}
anyone know anything about using mongodb with my discordbot?
I still don't understand. I've said before I'm still learning to code
delete the second try block
just keep the catch after
so delete try{ }
the 2nd one
windows
not the one with your code
why would i use mac
because people scare me
mac users scare me too
do you already have the mongo server?
yup
and a mongo user
..
community edition or using atlas?
atlas
you kept the } from the old try
@opal plank i did the debugging thing and it always cancels out the two missing red dots in between https://gyazo.com/987bccc60d93fcadd5b5ee2dcd2d859d
What lang are you using?
js
ok, do you plan to use mongoose or the official driver
depends
I just know the official driver better, which is why I asked
ill use the official one
Do you have the url you need to connect to mongo from atlas?
yea
alright, the general way to connect is like this:
const {MongoClient} = require("mongodb")
MongoClient.connect(url, opts (if you want), (err, client) => {
})
``` You can also use a promise if you dont want to use a callback
and how would I get the prefix
were you able to successfully connect to the atlas database?
ok ill try
After you do, you need to select the db to use
you learn to walk before you start running. the same goes if you learn new stuff
https://cdn.discordapp.com/attachments/713054412414910520/726497939291242526/unknown.png
ctx.beginPath();
ctx.arc(170, 160, 120, 0, Math.PI * 2, true);
ctx.lineWidth = 6;
ctx.strokeStyle = '#ffffff';
ctx.stroke();
ctx.clip();
const avatar = await loadImage(user.displayAvatarURL({ format: 'jpg' }));
ctx.drawImage(avatar, 40, 40, 250, 250);
ctx.closePath();
ctx.beginPath();
ctx.arc(235, 235, 30, 0, Math.PI * 2, true);
ctx.lineWidth = 12;
ctx.fillStyle = statusColor;
ctx.fill();
ctx.strokeStyle = '#ffffff';
ctx.stroke();
ctx.closePath();```
Is there a way to only have it clip the avatar image?
okay now i done the debugging i got
[Project Advertising] JamieG#6884 >> pt%blacklist 707945698347450370 test bot.js:878 TypeError: Cannot read property 'broadcastEval' of null
@earnest phoenix you want a circle?
just i want it the status colour outside the clip
wdym why
why not just get the status itself
???
He doesnt want the status to be clipped I believe is what he means
yes
can you increase the radius of the circle or move the status itself?
how am I able to find an image inside of an image with x y coordinates in nodejs
I searched everywhere but no answer
can you increase the radius of the circle or move the status itself?
@amber fractal radius of the status?
I think you can extract pixels from canvas if that's what you mean @marble juniper
or are you trying to crop 
if I increase the radius of the status it doesn't fix the issue
@earnest phoenix of the pfp itself https://oliy.is-just-a.dev/ig2oar_4845.png
oh ok
may work
i want it outside of the clip
of not, you can try to move the status bubble
the status bubble is inside the clip because I initiate it before the bubble
context.drawImage(imageObj, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight);
i think im connected
inside of the callback I'd just put a if(err) return console.error(err) and a console.log("Connected") after that to be sure
so, i dont understand, why do people take screenshots of peoples avatar, and want status removed?
doesnt discord already provide just the raw avatar for ya
he doesnt
there we are
He explicitly puts it in
oh 
i'm connected
it's a rank card
but just have a node error
https://oliy.is-just-a.dev/5wp0ep_4846.png I expect he wants this to not be cut off
oh, crop the pfp, then lay the new status ontop
not possible
do it on seperate contexts if you gotta
because of the clip
what if you change ctx.arc(235, 235, 30, 0, Math.PI * 2, true); to ctx.arc(225, 225, 30, 0, Math.PI * 2, true);?
just moving it back 10 pixels
i see what you mean
just use seperate contexts?
i have
ie, draw the entire rank card, make a new context, put the status on top
but with the clip, I dont know how to overlay it easily
just the xy
oh then you'd have to overlay it
is it a function?
I've connected to my db
its a common way to do things on seperate layers, so they dont interfere
it also is used to save processing power
like, this is using 4 different unique contexts, so things can be edited without messing up other things(only want one char flipped, not drawing things every frame, only when needed etc)
https://cdn.discordapp.com/attachments/723921738462789682/724740453177753683/test.gif
@misty sigil Nice, the client it returns is an instance of MongoClient (http://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html) you'll want to actually access the db now, the method to do this is <MongoClient>.db("databasename") (http://mongodb.github.io/node-mongodb-native/3.6/api/MongoClient.html#db) you dont need to provide a database name if you provided one in the connection url
I normally link it to my client for easy access everywhere client.db = mongoclient.db("db")
There are some extra options, (noListener and returnNonCachedInstance) that you can use to control how the connection works
👀
Hello, I'm looking for a bot developer who could make me a little program (more information in private message)
I will boost you if you do me a favor
@earnest phoenix what you need?
But after that's all good, you can start to use it, this is where the docs I've been sending come in, but I'll send you the methods most used that I know of. insertOne, find, findOne, updateOne, updateMany, deleteOne, deleteMany
Cool, that could be, kinda easy
you'll have to identify the collection first though, so after you have client.db you'd need to client.db.collection("collectionName").method()
I am looking for a bot developer who could create a program assigned a role according to the status of the user. If you do this service I can boost your server
So I'd have to make a collection?
Collections are made automatically if you try to insert to a non-existing one
https://oliy.is-just-a.dev/dv1t0b_4847.png this is something I use it for
Oh, and these all return promises if you dont provide a callback
ah so i could just client.db.collection("prefixes").method()
and can I have 2 prefixes
how is this looking
you can make an array of prefixes for each guild if you want
I'm just thinking the default one and the set one
https://oliy.is-just-a.dev/xro94s_4849.png this is what I have in my guildCreate
@scenic kelp
@jolly pollen No.
ads
Why
It's ads
Ohh okok
@amber fractal I'll save that img for reference
@jolly pollen You're not allowed to advertise here
so I'll figure something out
Still not sure what's wrong with my error Steven lol
When using updateone, you'll need to use update operators I find https://docs.mongodb.com/manual/reference/operator/update/ to help a lot
and then I might listen out for @mentions so I can show a prefix embed
@scenic kelp c as n u tell me where
nowhere on this server
@amber fractal that broadcastEval error
If my bot will add in 75+ server then
Ah, yeah. can you show your code again?
How I get verified bot developer batch
Yeah
-verifybot
Hi! It seems like you are looking for information on how to get your bot verified.
Once your bot reaches 75 servers or more, you are eligible for bot verification. On October 7, 2020, bots with 100 servers or more that are not verified will not be able to be invited to any more servers. You verify your bot on your bot's application page, under the "Bot" section in the sidebar.
If you need more information, check out this article written by Discord about The Future of Bots on Discord and you can ask questions in the Discord Developer Server.
We cannot provide support on how to get your bot verified.
does .updateOne() create automatically like .collection()
What’s a
client.shard.broadcastEval(`const guild = this.guilds.cache.get('${args[0]}');
if (guild) {
const guildOwner = this.users.cache.get(guild.ownerID);
guildOwner.send('You Have Been Blacklisted For Violating Our ToS https://projectbump.xyz/ToS :warning: Please Join Our Support Server To Appeal! https://discord.gg/SrEUJ4z');
}
guild ? guild.name : null;
`)
.then((results) => {
if (results.find(r => r !== null)) {
const blacklistedEmbed = new Discord.MessageEmbed()
.setTitle('Blacklisted Server! :warning:')
.setDescription('**__The Server__** ' + results.find(r => r !== null) + ' **__Has Been Blacklisted!__** :warning:')
.addField('Reason:', reason.replace(args[0], '').trim())
.setTimestamp()
client.shard.broadcastEval(`const channel = this.guilds.cache.get('714642375997259837');
if (channel) {
channel.send(${blacklistedEmbed});
}`)
con.query(`UPDATE testing SET blacklist = 1 WHERE guildid = ${args[0]}`, (err) => {
if (err) console.log(err)
sendEmbed(msg, 'Successfully Blacklisted Server! ⛔.')
})
} else {
sendEmbed(msg, `${args[0]} is not a guild id!`)
}
})```
there you go steven
its doing everything but sending the embed to the channel i need it to
@misty sigil when using updateOne, if you want it to create on non-existent, use the "upsert" option, like I do, that creates it if it doesnt exist and updates it if it does
@earnest phoenix I'll look
What's the error now?
because that is syntactically correct
Error [SyntaxError]: Unexpected identifier
weird, it doesnt come from that then.
ah, but it wouldnt check the strings
so let me check those
its defo something here
client.shard.broadcastEval(`const channel = this.guilds.cache.get('714642375997259837');
if (channel) {
channel.send(${blacklistedEmbed});
}`)```
I wanted to create a login with discord feature on my site how can i do that?
yeah, I assume it's because blacklistedEmbed gets turned into [object Object]
@surreal notch OAUTH2
Yeah but i tried but can't know something
what if you turn it into a raw embed and use .send({embed: ${rawEmbed}})
Means at some step i got stuck
<MessageEmbed>.toJSON() should turn it into a raw embed
its just strange how thats not working i get the same with my warn command
what did you change it to
all you should have to do is change this channel.send(${blacklistedEmbed});
to channel.send({embed: ${blacklistedEmbed.toJSON()}});
if that idea works anyways
if I had a sharded bot I'd test it myself
Anyone know how to track the total network usage of a bot?
Is there a NPM package I can use for that?
let me try that steven thank you ill be back in a few moments
@amber fractal yeah i get the same error
What if you just log the string instead of evaling it
just to see if it turns into what we expect
@heavy anchor You can use your vps host for netword usage
@surreal notch I’m not using a vps
what you using then?
console.log(`const channel = this.guilds.cache.get('714642375997259837'); if (channel) { channel.send({embed: ${blacklistedEmbed.toJSON()}}); }`)
There's no real easy (free) way to monitor network usage on a per-process level that I know about
what you using then?
@misty sigil this https://witherhosting.com/servers/cart.php?a=confproduct&i=0
unless you're on windows
you cant even install node stuff on to that, can you?
@heavy anchor is that minecraft servers?
No there is one for Discord bots
Ok
yeah not sure how that works
maybe contact their support
Thanks
hi, does anyone know how i can access a html element in a separate file?
in a backend file
weird 512mb ram unlimited bandwidth, unlimited storage ryzen 5 2600x cpu (that you definitely dont have full access to, probably split among many clients) for $1.50/3 months
what an odd service
@amber fractal it did what you said btw lol
const channel = this.guilds.cache.get('714642375997259837'); if (channel) { channel.send({embed: [object Object]});
yeah gets turned into object Object for some reason, you did .toJSON() it right?
Can I see the code?
yeah
@amber fractal
.then((results) => {
if (results.find(r => r !== null)) {
const blacklistedEmbed = new Discord.MessageEmbed()
.setTitle('Blacklisted Server! :warning:')
.setDescription('**__The Server__** ' + results.find(r => r !== null) + ' **__Has Been Blacklisted!__** :warning:')
.addField('Reason:', reason.replace(args[0], '').trim())
.setTimestamp()
client.shard.broadcastEval(`const channel = this.guilds.cache.get('714642375997259837');
if (channel) {
channel.send({embed: ${blacklistedEmbed.toJSON()}});
}`)
con.query(`UPDATE testing SET blacklist = 1 WHERE guildid = ${args[0]}`, (err) => {```
(node:12560) UnhandledPromiseRejectionWarning: TypeError: Only absolute URLs are supported
at getNodeRequestOptions (C:\Users\kenra\Desktop\Frosty Rewrite\node_modules\node-fetch\lib\index.js:1299:9)
async run(message, args) {
let person = message.mentions.users.first() || message.author
const msg = await message.channel.send("Fetching a dog picture...")
fetch(`"https://some-random-api.ml/img/dog`)
.then((res) => res.json())
.then((body) => {
console.log(body)
let embed = new MessageEmbed()
.setTitle(`Dog for ${message.author.username}`)
.setImage(body.link)
.setTimestamp(Date.now())
.setColor("#9cc4e4")
msg.edit(embed)
})
}
it never gave me that error before
now it does
How are you storing it?
attached to the guild ID
Wait wait wait
I mean like what’s the structure of the data
its a string
Are you using mongoose?
official
fucking discord.json doesnt actually stringify the JSON
@amber fractal im not sure why nothing is working haha
I’m confused now
I think I know why
just mongodb
gotta be a way around it
instead of ${blacklistedEmbed.toJSON()} try ${JSON.stringify(blacklistedEmbed)}
Oh yeah I used mongoose so I’m not sure how to read data from mongodb
but I dont think that'll work either
can i have some help.
if (command === "balance")
^
ReferenceError: command is not defined
at Object.<anonymous> (C:\Users\Jon\Desktop\Pokedex\client.js:9:1)```
How do I use command without getting a undefined error?
db.collection("x").findOne(filter) filter is an object
@amber fractal well i didnt get the unexpected error that time but it didnt post the embed hahah
Yeah, because it doesnt accept raw embed content
@still merlin you need to show your code, from that error is looks like you just didn’t define command
I know that.. But how do I define it?
depends on how you are using it
client.on("message", msg => {
if (msg.content === "cmsgt") {
const TestMessage = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor('Some name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')
.setDescription('Some description here')
.setThumbnail('https://i.imgur.com/wSTFkRM.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addField('Inline field title', 'Some value here', true)
.setImage('https://i.imgur.com/wSTFkRM.png')
.setTimestamp()
.setFooter('Some footer text here', 'https://i.imgur.com/wSTFkRM.png');
channel.send(TestMessage);
}
})
Error is with channel.send(TestMessage); it's saying: "channel is not defined" but if I remove that, command don't want work and there's no error in terminal
I wanna use it like this.
if (command === "balance")
message.channel.send("Your balance." + message.author.balance);
else if (command === "duel") {
const args = message.content.split(" ").slice(1);
if (message.author.bot) return;
//finish soon
else if (command === "leaderboard") {
if (message.author.bot) return;
if (!args[2])
return message.channel.send(
"Homie there is no second arg on the msg get a second args!1!!11!"
);
//finish soon
else if (command === "search") if (message.author.bot) return;
const replies = [
`You search around and find no pokemon!`,
`${Eevee}`,
`${Bulbasaur}`,
`${Pincurchin}`,
`${Rotom}`,
`${Pichu}`,
];
message.replytext = Math.floor(Math.random() * replies.length + 0);
return message.channel.send(replies[message.replytext]);
}
}```
@earnest phoenix I can think of one workaround
ingore half the code, just trying to test things-
define the embed inside the eval
then you can use it as a variable inside the eval itself
but it will build the embed for every shard, which isnt ideal, but that's all I can think of
or
just put it in the if 
how do i attach my db to my client
so something like ```
client.shard.broadcastEval(`const channel = this.guilds.cache.get('714642375997259837');
if (channel) {
const blacklistedEmbed = new Discord.MessageEmbed()
.setTitle('Blacklisted Server! :warning:')
.setDescription('**__The Server__** ' + results.find(r => r !== null) + ' **__Has Been Blacklisted!__** :warning:')
.addField('Reason:', reason.replace(args[0], '').trim())
.setTimestamp();
channel.send(blacklistEmbed);
}`)
@misty sigil did you try client.db = <MongoClient>.db("name")?
but you'll also need to define the reason and results in there too so not sure how you would tbh @earnest phoenix
client.on("message", msg => {
if (msg.content === "cmsgt") {
const TestMessage = new Discord.MessageEmbed()
.setColor('#0099ff')
.setTitle('Some title')
.setURL('https://discord.js.org/')
.setAuthor('Some name', 'https://i.imgur.com/wSTFkRM.png', 'https://discord.js.org')
.setDescription('Some description here')
.setThumbnail('https://i.imgur.com/wSTFkRM.png')
.addFields(
{ name: 'Regular field title', value: 'Some value here' },
{ name: '\u200B', value: '\u200B' },
{ name: 'Inline field title', value: 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here', inline: true },
)
.addField('Inline field title', 'Some value here', true)
.setImage('https://i.imgur.com/wSTFkRM.png')
.setTimestamp()
.setFooter('Some footer text here', 'https://i.imgur.com/wSTFkRM.png');
channel.send(TestMessage);
}
})
Error is with channel.send(TestMessage); it's saying: "channel is not defined" but if I remove that, command don't want work and there's no error in terminal
you probably meant msg.channel.send
How do i define command??
you should probably learn js tbh
If you dont know how to define a variable, you shouldn't be making a bot
client.db = MongoClient.db("discordprefixes")
TypeError: MongoClient.db is not a function
I know how to define a varible but what would i put..
@misty sigil you need the actual instance of the client returned from the connect function
how would i get that?
@amber fractal even with that it doesnt work vs seems to think its assigned a valuable but never used obvs becuase its in string
the line is inside the connect block
you can use promises instead
@earnest phoenix yeah I'm not sure how you would, I'd just use a discord webhook at that point
simplifies the process a lot
removes the need for the broadcast eval
you probably meant msg.channel.send
@amber fractal oh thanks, i forgot about it
@amber fractal I made it like that as it's easier tbh
My main bot is working fine (without sharding) but as we are on 1.3k nearly I'm implementing sharding
Is there a way for me to bypass perms for myself for my prefix command? For example, right now I have an if (!hasPermission'MANAGE_GUILD') return, but I wanna be able to access it too without having the permission
don't do checks if the message author's id is yours
Don't do checks or do do checks?
Just for me
yeah
if (!hasPermission'MANAGE_GUILD' || msg.member.id !== yourid)
Makes sense
O shit tru
wait
Lol
if author id != my id
permission checks
no else because you don't need an else
tbf I would probably mix up that logic if I hadnt read it wrong anyways

wait wait wait. their doing a fail check arent they?
because !hasPermission
Wait wait wait wait.
Whats the diffrance between if(!) and if?
Inveting
NOT operator
Inverting
it inverts the state of the bool
Yeah but more in Yoda speech
so would it not be && because
return because no perms
would return if their id is not my id?
! You are going to that party
?
!true == false
damn did people here never take cs
!false == true
It makes bools go from false to true and viceversa 
if(evaluates to true) will run if(evaluates to false) will not
wait till they discover boolean algebra and monotone laws

Bitwise operations 
yo so how do I get the amount of bots in a server kinda like what this bot does http://prntscr.com/t7lt04 ik users is bot.users.size
filter out users that aren't bots



