#development
1 messages · Page 925 of 1
Something like class Utility {...} and each method should be prefixed with the keyword, static. So you can just do Utility.somemethod()
Are some IDs even 16 in length
just for safe keeping
looks like they are already starting with a length of 10
@grizzled raven 7/10 but Clyde's ID is 1 and no clyde support 
oh no wait, discord didn't exist 1 Jan 2015
how i do that but in 11v?
newRole.permissions.toArray().join(" - ")
fixed it
idk how
what happens when you try it
same thing
(node:2692) UnhandledPromiseRejectionWarning: TypeError: newRole.permissions.toArray is not a function
not you pls
me?
star eval let mentions = []
@grizzled raven @safe geode @earnest phoenix
message.content.replace(/<@(!)?(1|\d+{16,20})>/g, (s, _, id) => {
mentions.push(id)
return s
})
--silent message.author.send(mentions.join(", "))
bruh ok
Bruh
lets pretend that worked
We know it didn't
help plz
wait
ok
oops forgot to comment the pings
lol
star eval let mentions = []
// @grizzled raven @safe geode @earnest phoenix
message.content.replace(/<@(!)?(1|\d+{16,20})>/g, (s, _, id) => {
mentions.push(id)
return s
})
--silent message.author.send(mentions.join(", "))
Lil marco it looks fine according to the docs. Can you show what newrole is
see that definitely worked
wrong section pls
ok im done lol
client.on('roleUpdate', async (oldRole, newRole) => {
if(oldRole.permissions !== newRole.permissions){
let embed = new Discord.RichEmbed
let msgChannel = await logs.obtener(oldRole.guild.id)
if (!msgChannel) return;
let channel = client.channels.get(msgChannel);
embed.setTitle('Spanish letters here');
embed.addField('Mmm', newRole.permissions.toArray().join(" - "))
embed.setColor(amarillo);
channel.send({ embed });}
})
let me try
nvm array is on the Permissions class
see it worked
Hi i needs invite manger bot link from were i can get it
success
Or at least I thought.
(node:2762) UnhandledPromiseRejectionWarning: TypeError: newRole.permissions.array is not a function
@grizzled raven u r 11v?
permissions.toArray()
you're going to have to use new discord.Permissions(newrole.permissions).toArray()
wait let me
@earnest phoenix if you want to use the permissions class you'd need to create a new instance of the class or use the .serialize() method on the Role instance and loop over its properties to get the ones you want.
is 11v? @warm marsh
Yes
just make sure you have const discord = require('discord.js'); at the top or something
@sudden geyser it doesn't seem a class it what I mean, it should just be simple and I yeah a class is not the simpleness I need. I just want to do things like
toCode(str) {
return '`' + str + '`';
}
Not really this, but things like this
oh a role
@warm marsh i have const Discord
A class is very simple once you understand it.
then change the discord to Discord
thought you meant a guildmember
I need this bot invite manger bot from were i can get it
If you don't want a class just keep an key/value object instead.
Alright
are classes better than objects in some way?
thanks
Like I said the method needs to be static if you don't have to make a new instance.
in some ways yeah
for example your client uses classes
i can do ```js
variableofperms[new Discord.Permissions(newRole.permissions).toArray()]
variableofperms = [ ...(new Discord.Permissions(...))]
are classes better than objects in some way?
@nocturne grove classes are objects' casts
okay thanks. I will just read a bit more about it @sudden geyser
i say
variable = {
perm1: "Perm1xd"
}
variable[...(new Discord.Permissions)(...).toArray()]
@warm marsh
you can't have an object without class
I've made enough objects without the word class in it, tho 🤷
objects are data storage basically
classes are machines you build on top of objects
mention me plz
Link: #development message
thats not possible
@earnest phoenix what are you trying to do?
Who should you allow editing guild settings on a dashboard.
I would have used manage_guild, but then I noticed that I don't know if that user has that permission without my backend asking my bot about it on every request that needs that information
@quartz kindle array perms
to the event roleUpdate
i want this (#development message) beacuse im spanish
does anyone know how to make a mute command for my bot?
@earnest phoenix <user>.addRole('id role')
ok thx
np
@earnest phoenix you need to explain better because what you showed makes no sense
@onyx summit when you get the access token you can ping for user info for their guilds then just filter what guilds they have that perm in. No need for your bot to know.
yeah I fetch the guilds and then cache it, but I thought then that info is kinda stale
like what if they have their permission removed, or get that permission on a server
I wouldnt know
so my few options are:
- refetch the data from discord sometimes
- annoy my bot about it
- dont care and use the old info
if youre using oauth2, standard practice is just let the token expire (stop refreshing it on session end) and refetch the data when the user visits again and reauths
@quartz kindle is like
trueorfalse = {
true: "bot",
false: "human"
}
trueorfalse[message.author.bot]
but with this #development message
that's.....very wrong
@quartz kindle how does that solve my problem?
I don't think you can use booleans as object keys
@lyric mountain me?
yes
this work
you can index objects with booleans
js is weird af
@onyx summit idk what your problem is, im assuming you're talking about oauth2 on a website/dashboard
but i dont remember if is true or "true"
@onyx summit on my old bot i personally never cached discord data for bearer tokens, always fetched it directly from discord
as long as you respect the ratelimit if and whenever you get ratelimited, you're fine
uff
@lyric mountain
if (command === "test") {
let falseortrue = {
false: "Human",
true: "Bot"
}
let user = message.mentions.users.first() || message.author;
message.channel.send(falseortrue[user.bot])
}
^^
this work
now I need to worry about ratelimits huh
as I said, js is weird af
hey i've made a color array (hex color) and i'm trying to pick a random color like this :
var random = Math.floor(Math.random() * colors.size)
console.log(colors.size)
console.log(random)
var color = colors[random]``` Which prints me "undefined", and "NaN" out in the console. Does anone know why ?
oh ok
if you're using a library, chances are the lib handles ratelimits for you
many libraries automatically pause your requests, put them in a queue and then send them when the RetryAfter header says so
@earnest phoenix you cant do that with an array. you need to process each item of the array individually. Also depends on what you want to output
there are libraries for handling oauth requests?
if you have {perm1:"permOne",perm2:"permTwo"}, and the role has both perms, what do you want it to say?
you're confusing oauth with sending requests to the api
the perm but in spanish @tim
yeah I know, I get a token from discord with which I can then make requests to the api
correct
but they're not the same
there's no libraries to "handle oauth requests" because you have to implement that yourself, oauth requests are not API requests
what is the perm 'USE_VAD'?
what i assume you meant with your question is if libraries support making calls to Bearer token endpoints
which, yes, almost all of them do
yes yes I didnt really mean oauth requests (my bad), but the typical requests to get e.g. the guilds from a user are not the paths a normal lib made for bots would call
so you just want to translate the perms? then do something like this: ```js
let spanish = {
"SEND_MESSAGES":"Enviar Mesaje",
...
}
permissions.toArray().map(perm => spanish[perm])
@quartz kindle ty
hey i've made a color array (hex color) and i'm trying to pick a random color like this :
var random = Math.floor(Math.random() * colors.size)
console.log(colors.size)
console.log(random)
var color = colors[random]``` Which prints me "undefined", and "NaN" out in the console. Does anone know why ?
@earnest phoenix do you know any js libs for this?
the array is too long
...don't put a field
it has like ~50 hex color codes
show just a part of it then
you don't
fields are optional in an embed
then colors.length should work
show the code where you used colors.length
https://discord.com/developers/docs/resources/channel#embed-object everything is optional
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
??
discord is buggin man
make your title a zero width space
i dont want that
?
i think it's just your internet
it's fine on my end
@quartz kindle
var size = Math.floor(Math.random() * 15) + 20
var random = Math.floor(Math.random() * colors.lenght)
console.log(colors.lenght)
console.log(random)
var color = colors[random]
console.log(size)
var rotate = Math.random() * 5
console.log(rotate)
ctx.font = `${size}px Impact`
ctx.fillStyle = color```
change your field title to a zero-width space
that
🤷♂️
@hasty lotus length not lenght
that's not how you spell length, Nini
@earnest phoenix this is the unicode for a zero-width space in js \u200b
idk how its in py, or whatever you use
im using py
save the file as unicode
ill try in vsc
its a "?" now
it's because you're editing in notepad
or some IDE that doesn't support unicode
k one sec
ill use vsc
if you reopen the file you'll see that it placed a question mark
it worked
in vsc
#!/usr/bin/python -tt
# -*- coding: utf-8 -*-
dunno, did u use that on your code? but, anyway, it works now, ig
why does discord temp-ban my bot for an hour?
because you're spamming API requests
as in, reactions and other stuff?
depends what
as in literally anything
my bot typically sends 100k bytes/s but every so often it jumps to 500k and thats when it gets temp banned, i have no idea why it jumps to 500k because it has never done it before
messages, reactions, fetches
anything that makes a REST request contributes to that
you mainly get API banned if you spam requests while you're ratelimited
This means that you need to send 25,000 requests in 10 minutes that result in a 401, 403 or 429 in order to be auto-banned.
where does description go
well atm youre just making a var called description and doing fuck all with it
you're either not respecting ratelimits or you're not doing permission checks before you do a certain action, neelio
im asking where it goes not what its fucking doing
ah ok
would these requests that result in a 401, 403, or 429 code be logged in stderr?
because from what im seeing, they dont
@earnest phoenix idk why ur asking us where to stick that var :P
how i join the arguments with +?
let filter = (msg) => msg.author.id === message.author.id
message.channel.send("Que quieres buscar?").then(e=> {
e.channel.awaitMessages(filter , {
max: 1 ,
time: 155155,
errors: ["time"]
}).then(async collected => {
let embed = new Discord.RichEmbed();
embed.setTitle('Ok Google')
embed.addField(`Busqueda completa`, `[Link](https://www.google.at/search?ei=uCVsXrqEEIWbsAefxZDYDw&q=${collected.first().content})`)
embed.setColor(amarillo)
await message.channel.send({ embed })
await message.channel.send("Aqui tienes!")
e.channel.awaitMessages(filter , {
max: 1,
time: 1212,
errors: ["time"]
})
}).then(async collected => {
console.log(collected.first().content + " relleno")
})
})
if you mean to set the embed description you gotta set that embed attribute to that
wtf are you saying
is there a djs way of logging? isnt there a bot.on('debug') in djs, or a node process.on('warn') event i can set up?
@earnest phoenix its not hard, you have an embed object
description is a attribute of that object
embed=discord.Embed(description="hi")
v12 has bot.on("ratelimit")
set description attribute -> set embed description
🤔
dont be rude xD they did not understand what you asked, that happens sometimes
help: #development message
ik what they were talking about
lol what you gave me didnt work either
@earnest phoenix , https://stackoverflow.com/help/how-to-ask
but i was actually getting them to think with their brain instead of giving them an easy way out
it works for me
yo i have a line in my code and it says i need an async for await to work but i have async. and i saved it
message.guild.channels.forEach(async (channel, id => {
where do i drop it
really? sry, but this is so easy :/ I can not write the whole code for you
don't use forEach, it's extremely slow
@earnest phoenix i say: how i join the arguments with +?
do a for loop instead of .forEach
ok
how many languages are you writing this bot in marc? ive seen you ask for help in atleast 2 rn
how i join the arguments with + ?
let filter = (msg) => msg.author.id === message.author.id
message.channel.send("Que quieres buscar?").then(e=> {
e.channel.awaitMessages(filter , {
max: 1 ,
time: 155155,
errors: ["time"]
}).then(async collected => {
let embed = new Discord.RichEmbed();
embed.setTitle('Ok Google')
embed.addField(`Busqueda completa`, `[Link](https://www.google.at/search?ei=uCVsXrqEEIWbsAefxZDYDw&q=${collected.first().content})`)
embed.setColor(amarillo)
await message.channel.send({ embed })
await message.channel.send("Aqui tienes!")
e.channel.awaitMessages(filter , {
max: 1,
time: 1212,
errors: ["time"]
})
}).then(async collected => {
console.log(collected.first().content + " relleno")
})
})```
stop spamming your code
nobody knows what you're talking about
refer to the link above and see how to properly ask your question
like
a+e+i+o+u+1+2+3+4+5
my code still isnt working
cool
there are no arguments
thats 1 line
if (message.member.hasPermission(["KICK_MEMBERS", "BAN_MEMBERS"])) {
if(message.guild.me.hasPermission("KICK_MEMBERS", "BAN_MEMBERS")) return message.channel.send("Uh oh! Looks like i do not have permission to do this!")
let mutee = message.mentions.members.first()
let reason = args.slice(1).join(" ");
if(!reason) reason = "No reason given"
let muterole = message.guild.roles.find(r => r.name === "Muted")
if(!muterole) {
try{
muterole = await message.guild.createRole({
name:"Muted",
color: "#514f48",
permissions: []
})
message.guild.channels.for(async (channel, id => {
await channel.overwritePermissions(muterole
SEND_MESSAGES: false,
ADD_REACTIONS: false
SPEAK: false
})
})
} catch(e) {
console.log(e.stack);
}
}
}
mutee.addRole(muterole.id).then(() => {
message.delete()
mutee.send(`You have been MUTED in ${message.guild.name} for ${reason}`)
message.channel.send(":mute:" + ` ${mutee.user.username} has been MUTED!`)
})```
thats not 1 line, thats like 50
and what is the problem?
it says i need an async
but i have it
message.guild.channels.for(async (channel, id => {
on this line
channels.for doesnt exist
ok
you need a for loop, which is a top-level loop, its not a property of anything, its standalone
for discord collections, you can use a for of loop
How i can use emoji on canvas? (JavaScript)
get an image of the emoji
custom emojis or default emojis? for custom emojis ^ what he said
does anyone have the kick or ban or mute or music script? for a discord bot
there are a million different ways to code and execute something like that
custom emojis or default emojis? for custom emojis ^ what he said
for discord unicode you can use this https://static.emzi0767.com/misc/discordEmojiMap.json
code is written for a very specific context, it will only work in the program it was coded to work on. copying and pasting code is bad practice and will likely never work "out of the box" because it has to be adapted to fix the rest of your code and context
does this work then?
then how do i go back to older version
v11 will stop working in october
no point going back to it
and even in v11, it wont work out of the box
is the bot down?
ok
you still need to define a channel id, and you need to process the ban command itself
that code doesnt check what command was used, it only does the banning logic (for v11) for after the ban command was processed
do u know a script for ban?
Hi guys, I've been into this problem for a while and couldn't fix it, hopefully you guys can help.
I have an array of objects, every object contains a voice channel id under the property 'hall'
I need to check once in a while if some of these IDs do not corrispond to any channel anymore 'cause maybe the channel got deleted
This is what I tried but it doesn't work properly
// Check halls
let index = 0;
let newHalls = halls;
if(halls){
halls.forEach(e=>{
let ccc = message.guild.channels.cache.get(e.hall);
if(!ccc){
let i = newHalls.indexOf(e);
newHalls.splice(i, 1);
}
})
halls = newHalls;
await client.guildSchema.updateOne({id: message.guild.id}, {$set: {'halls': newHalls}})
}```
This is an example of an object of the array
as i said, there is no scripts you can copy and paste, thats a bad idea 99 times out of 100
i dont know any script, i code my own script if i need it
ok
you should not add commands to your bot by copying and pasting them, you should learn how to code them yourself
else you will run into tons of problems
alright
would a good way to deal with ratelimits be using bot.on('ratelimit'), logging ratelimitinfo.path (for my reference), and then forcing the bot to wait until ratelimitinfo.timeout has finished before allowing it to make any actions again?
or is there a more optimal way, like throttling?
the optimal way is not letting your code reach them in the first place
what are you doing that is hitting the rate limit?
so my bot uses reactions for everything, and i just released a new update last night that blew up in popularity. i think its sending out way too many requests for reactions and so it is getting temp-banned, if that makes sense
Can i upload inside-me domain to image from an command? Is this possible?
thats my hunch, at least
I want my (prefix) command to allow me to execute it but otherwise restrict it to only people with the "Manage Server Permission"
@opaque seal you can just halls = halls.filter(e => message.guild.channels.cache.get(e.hall))
Anyone ?
@near ether how many are we talking about and how frequent? because my help command uses 10 reactions and i dont get rate limited
@earnest phoenix yes
turn based battles use at minimum 5 reactions every 5-ish seconds,
and then i used a page system with my embeds where you can react with forward or backwards to flip through pages
show your reactions code
you probably need a way to pass image data to upload
does your bot auto-unreact people's reactions?
yes
but u can just post to ur image server
no, the most it does is clear the reactions on a message once used
and i cant really send the code since the reaction code is dispersed everywhere
are you properly awaiting all reactions?
yea i make sure to await every time i react
how do u do that i dont know
did you change the restTimeOffset client option?
I don't know,how can i post an image to there
then i'd need to see your code
anyone know how to turn py into exe
you need a way to compile it
pyinstaller
look into python builder/compiler
itd be hard to send it because the reaction code is not in a few locations, its in a lot of files spread across a lot of functions. is there anything you would recommend i should look for in my reaction code?
@earnest phoenix Auto PY to EXE
you're using discord.js right?
me? yep
discord.js has a pretty good control over rate limits
for example, once i had an april fools event where my bot reacted with "H" "I" to every single message
that was hundreds of reactions per minute, they automatically got lots of delay due to the rate limit queue
and i didnt get a single rate limit error
no library is immune to causing 429s
so for you to be getting rate limit errors, there has to be something wrong in your code
you should be very careful when doing stuff that could potentially surpass discord ratelimits
i have been ratelimited before with libs that seemingly had this internal limit
if u setup ur code properly u can easily avoid getting ratelimited
preemptive ratelimiting
what stuff
yea thats what my bot goes through, it gets delayed all the time
which is intended behaviour
it may not even be reactions tbh, it might just be messages?
@opaque seal you can just
halls = halls.filter(e => message.guild.channels.cache.get(e.hall))
@quartz kindle thank you so much
is your bot sharded?
Is discord.py better than discord.js?
What’s the line of code needed for the bot to tag the command user eg “prefix.support, bot returns @x.y.z here’s the support link”
when it spikes, thats when i get ratelimited
@indigo cloud they are different
and yes, my bot has 20 shards
you cant compare them
are you sure you dont have an infinite loop somewhere?
they serve different languages
Alright
@indigo cloud all programming languages are good
some libs and langs are better for specific things
im sure i dont but ill check once more
@near ether so one thing: afaik, shards do not sync rate limits among themselves, so if your code is doing cross-shard stuff, it can interfere with each other's rate limit system
i wouldnt make a game with js and electron
ah ok, my code uses broadcastEval almost everywhere
u can but its bad in performance and in general
so u pick something better for it like c#
Is there versions to discord.py like discord.js?
yes
of course
everything like this has versioning
Alright
but still, that doesnt explain why it spikes to such a high bytes sent/s
what the hell is this ```js
Response: Internal Server Error
at RequestHandler.execute (/home/thenoob27/Starboard/node_modules/discord.js/src/rest/RequestHandler.js:158:11)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
internal server error
all software has versions
blame discord
my bot is stable
it receives roughly the same amount of bytes
everything has versions
ohh
yeah its a server error it has nothing to do with your bot
500
the drops are when it got ratelimited
blame discord
more activity than usual but not so significant as to quintuple the sent bytes
grafana
i use google cloud platform and i use their monitoring system
Error: input stream: Too many redirects I played a playlist, and uhhhhh
its extremely useful
so basically
if a rate limit is 5 per 5
and shard 1 sends 4, and for some reason, it sends a broadcastEval that makes shard 2 send to the same channel
shard 1 will not know that shard 2 sent to the same channel, and shard 2 will not know that shard 1 already sent 4 times
causing a rate limit error
my bot plays 5 songs and then gives me the error Error: input stream: Too many redirects
so i would start investigating your broadcastEvals
alright, this only started happening after my new update so ill just look in the new code
thanks for the help!
How do I get my dbl token?
well actually tim now that i think about it, my bcEvals dont broadcast code that require the api except once when the bot is launching
what about stuff like fetching a channel from another shard
nope
the only time it fetches with broadcast evals is when someone votes
and that doesnt happen enough to warrant a rate limit obv
what kind of stuff did you add on your new code?
hi hello
honestly it uses the same design as the old code; bot sends a message, bot reacts, waits for user reaction, then edits embed depending on the user's choice, then bcEvals the important info across shards (does not make an api request)
const cooldowns = new Eris.Collection();
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Eris.Collection());
}
const now = Date.now();
const timestamps = cooldowns.get(command.name);
const cooldownAmount = command.cooldown * 1000;
if (timestamps.has(message.author.id)) {
const expirationTime = timestamps.get(message.author.id) + cooldownAmount;
if (now < expirationTime) {
const timeLeft = (expirationTime - now) / 1000;
const p = await message.channel.createMessage(
`${message.member.mention}, You are being rate limited, slow down! (**${timeLeft} seconds**)`
);
}
timestamps.set(message.author.id, now);
setTimeout(() => {
timestamp.delete(message.author.id, cooldownAmount);
p.delete();
}, cooldownAmount);
}```
which is why im so stumped
Does a webhook require hosting just like a bot?
@wise quartz no
@quartz kindle its free to use right?
weebhook lmao
well, the webhook still needs something to send it
Whats it?
so in that sense, it does require some hosting, or a website, or webservice to do it
Aha..
a bot can send webhooks, what big bots do it simply have their bots send it
Aha
otherwise, webhooks can also be sent by github, twitter, etc
And how can i do that?
those dont require your bot
right now it says n/a
use the top.gg api
@wise quartz you go to the service you want, like twitter, and in their settings look for webhooks, and use your discord webhook as the url
Imma see some youtube tutorials if there is.. that'd help me understand them better
But thanks
(node:5076) UnhandledPromiseRejectionWarning: TypeError: fields.flat is not a function
``` - I am confussed with this error
Alright
import dbl
import discord
from discord.ext import commands
class TopGG(commands.Cog):
"""Handles interactions with the top.gg API"""
def __init__(self, bot):
self.bot = bot
self.token = 'dbl_token' # set this to your DBL token
self.dblpy = dbl.DBLClient(self.bot, self.token, autopost=True) # Autopost will post your guild count every 30 minutes
async def on_guild_post():
print("Server count posted successfully")
def setup(bot):
bot.add_cog(TopGG(bot))
i have this code
but it doesn't show the server count on my bot page
im assuming u didnt change the dbl token
as text or as embed?
you type it?
you're using py or js? i dont remember
py
do you mean categories like this?
no.
actual categories
where you have to type +help moderation
to see moderation commands
omg im dumb
holly shit
nvm i got it
ill just make a new command
i did respond but discord died and decided not to send but meh
const Discord = require('discord.js')
module.exports = {
name: 'hug',
description: 'hug people',
execute: async(client, message, args) => {
const gifs = ["https://i.imgur.com/cZWWATV.gif", "https://i.imgur.com/NdUPLO9.gif", "https://i.imgur.com/lyJfpE7.gif"]
let gif = gifs[Math.floor(Math.random()*(gifs.length)-1)]
let personebeinghugged = message.mentions.users.first()
let personhugging = message.author
if (!personebeinghugged) {
message.channel.send("who you hugging")
} else {
let embed = new Discord.MessageEmbed()
.setColor("RANDOM")
.setImage(gifs)
//.setTitle(`${personhugging.user} hugged ${personebeinghugged}`)
message.channel.send(embed)
}
},
};``` when i do =hug and mention a user it tells me "who you hugging"
no !personbeinghugged
it should only send that if nobody is mentioned
i dont see anything wrong with the code as it is
why does Array.indexOf not work on objects
objects dont have indexes?
ah
cos this happens
aaaa then how do i check if an object already exists in an array of objects
you'd need to stringify it
dont think so
do you want to match the entire object? like an exact copy?
array.find(item => JSON.stringify(item) === JSON.stringify(myobj))
and if i want to make sure it doesnt exist in the array just do !== instead right?
oh wait no
!array.find
considering i managed to get this beauty out of it
(await client.getMessages(message.channel_id, 10)).reduce((accumulator, curr) => {
if (curr.author.username !== message.author.username && !curr.author.bot && !accumulator.some(item => JSON.stringify({ u: curr.author.username, i: curr.author.id }) === JSON.stringify(item)))
accumulator.push({ u: curr.author.username, i: curr.author.id })
return accumulator
}, [])```
what i do is i save their stringified versions
so its fast to compare
and then json.parse when i need to use them
surely there has to be a better way than this lmao
but i guess i can expand this for my future needs
wait so what about mine did i do something wrong?
wait you're doing that on messages?
me?
ye
well yea
ah nvm
i fetch last x messages and grab every unique authors username and id not including bots and the author and other criteria in the future
yeah its better if you push strings
but then i will just have to deserialize them again later
well i suppose i could just .map(d => JSON.parse(d)) afterwards
yeah but better deserialize them later once, than serialize them about 90 times?
for all the comparisons
fair enough
actually, its would be even faster to simply compare the object contents
since its only 2 keys
and since 1 is the username i really just need to compare the ids
!acc.some(item => item.u === curr.author.username && item.i === curr.author.id)
no?
well, yeah
idk why you need both username and id, i thought you were comparing id and message for a while
index of object seems to work from my experience
i need username and id for later use
actually maybe uts my use
i usually use indexOf objects in these scenarios ```js
let exists = arr.find(a => a.key === "3")
if (exists) {
arr.splice(arr.indexOf(exists), 1)
}
howdy- does anyone know how to get a for loop in an embed in discord.py?
@dusty onyx wdym a for loop in a embed?
ill send mt code
because when you use array.find() you get the reference of an existing object, and you're comparing references, but if you use a new object, its a new reference, even if the content of the object is the same
`for e in ultimates:
ms = discord.Embed(
'<@!' + str(e) + '>' + " is the Ultimate " + str(ultimates[e]) + '!'.format(message),
colour=0x008000
)`
ah sorry
came out bad
but essentially i have a dict that im listing the key and content on each line, for how many items there are in the dict
it works fine out of an embed, but id just m u c h rather have it in an embed bc it looks way cleaner
the initial for statement doesnt work btw, i was just experimenting
is just make the embed object first
with discord.Embed()
and then do embedobject.description = "some description"
and we can iterate round that description
without making a new object every time
whats the error
well in pycharm i get a red sqiggly line with 'expression expected'
and when it runs its invalid syntax
ms.description = for e in ultimates: '<@!' + str(e) + '>' + " is the Ultimate " + str(ultimates[e]) + '!'.format(message_clone)
ah yeah that wont work like that
you basically need
for somthing in some_list:
some_embed.description += some text
the += is basically taking the current description already then adding what ever you give it to the end
like doing x = x +1 we can do x += 1
ur a genius
okay so if i have this let blacklist = bot.db.get(`blacklist_${user.id}`) ? bot.db.get(`blacklist_${user.id}`): "❎ - Not Blacklisted" how would I make it so that if it finds it, aka its true, it would make it say "✅ - Blacklisted"
so id go for e in ms ?
your original for loop was fine in terms of for e in ultimates
@astral yoke replace the second db.get() with that
db.get() ? blacklisted : not black listed
But how would I put it so that if he is it would make it say That it is blacklisted? Cause for now it just says "true"
I want it so if like if(blacklist === "true")
would that work?
no, you need to save the result
const Discord = require('discord.js')
const id = "467030554131562506"
const beautify = require('beautify')
const { MessageEmbed } = require("discord.js")
module.exports = {
name: 'eval',
description: 'eval code',
execute: async(client, message, args) => {
if(message.author.id === id) {
if (!args[0]) {
message.channel.send("You need to evaluate something")
}
try {
if (args.join(" ").toLowerCase().includes("token")) {
return;
}
const toEval = args.join(" ")
const evaluated = eval(toEval)
let embed = new MessageEmbed()
.setColor("#00FF0")
.setTimestamp()
.setFooter(client.user.username, client.user.displayAvatarURL)
.setTitle("Eval")
.addField("To evaluate", `\`\`\`js\n${beautify(args.join(" "), { format: "js" })}\n\`\`\``)
.addField("Evaluated", evaluated)
.addField("Type of:", typeof(evaluated));
} catch (e) {
let embed = new MessageEmbed()
.setColor("#FF0000")
.setTitle("\:x: error!")
.setDescription(e)
.setFooter(client.user.username, client.user.displayAvatarURL)
message.channel.send(embed)
}
} else {
message.channl.send("no")
}
},
};``` my eval command isnt rlly an eval command it only does like sending messages so if i do _eval message.channel.send("no") it will say no it wont do anything else i tried to do _eval message.guild.id but nothing happens and no errors why
holy
let result = db.get()
let blacklisted = result ? "blacklisted" : "not blacklisted"
if(result) {
msg.channel.send(blacklisted)
}
but if you're going that route, its better to do without ternary
I'm doing it in an embed.
result = db.get()
if(result) {
...send("blacklisted")
} else {
...send("not black listed")
}
Thanks Tim!
@hardy vector you never send the embed lol
im blind
PS C:\Users\xAutentiqz\Desktop\Discord Bot> node run index.js
internal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module 'C:\Users\xAutentiqz\Desktop\Discord Bot\run'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
how to fix this?
node index.js
how do you find how much servers your bot is in
or nodemon index.js
same thing
check how big the guild cache is
in discord.js v12 it would be client.guilds.cache.size
ok
@indigo cloud do you have an index.js file in your Discord Bot folder?
thx
yes
Mode LastWriteTime Length Name
d----- 5/13/2020 10:43 PM node_modules
-a---- 5/13/2020 11:16 PM 244 index.js
-a---- 5/13/2020 10:43 PM 3902 package-lock.json
-a---- 5/13/2020 10:46 PM 287 package.json
and when you type node index.js you get an error?
which error?
should be a different error than the last one
Error: Cannot find module 'discord.js'
Require stack:
- C:\Users\xAutentiqz\Desktop\Discord Bot\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\xAutentiqz\Desktop\Discord Bot\index.js:1:17)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\Users\xAutentiqz\Desktop\Discord Bot\index.js' ]
}
did you install discord.js?
yes, do npm install discord.js
ik
how do i install discord.js v11.4.2
you shouldn't
you shouldnt install v11 because it will stop working in october
because they're all outdated
alright
because the tutorials are outdated
nvm i will go to my last project
@quartz kindle ty for that, i changed it a little but thanks for the help
👍
help
help
at timeout.client.setTimeout (/rbd/pnpm-volume/5b146d33-2649-47dc-b5df-4bb5db586bdc/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/ClientManager.js:40:57)
at Timeout.setTimeout [as _onTimeout] (/rbd/pnpm-volume/5b146d33-2649-47dc-b5df-4bb5db586bdc/node_modules/.registry.npmjs.org/discord.js/11.6.4/node_modules/discord.js/src/client/Client.js:436:7)
at ontimeout (timers.js:498:11)
at tryOnTimeout (timers.js:323:5)
at Timer.listOnTimeout (timers.js:290:5)
(node:3087) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
(node:3087) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
why ?
help me ?
that happened to me as well earlier
discord.js v11 has that bug if some guild is offline
i had very high bot ping and had to restart my bot more then once to get the ping to stay down
you should upgrade to v12 if you can, as v11 will stop working in october
LOL is that really an error that djs fires???
that is the most useless thing i have ever seen
its unclear what is the exact reason, but thats one of the symptoms of a dead server
because v11 will wait for it until a global timeout happens
v12 will only wait for 15 seconds, then automatically assume its dead and connect anyway
of course this can also happen for other reasons, such as an infinite loop
or stupidly slow files loading
okey
thx
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/rbd/pnpm-volume/5b146d33-2649-47dc-b5df-4bb5db586bdc/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/index.js:8:11)```
v12
I updated the version gave such an error
?
@quartz kindle
you need to update your node.js
v12 requires node.js v12 or higher
on glitch you can do so by changing your engine settings in your package.json
ok i tried to make ban and kick script tbh took some stuff from google but still can u see if it will work?
if (message.content.startsWith("$kick")) {
// Easy way to get member object though mentions.
var member= message.mentions.members.first();
// Kick
member.kick().then((member) => {
// Successmessage
message.channel.send("👋 " + member.displayName + " has been successfully kicked 👉 ");
}).catch(() => {
// Failmessage
message.channel.send("Access Denied");
});
}
});
client.on("message", (message) => {
if (message.content.startsWith("$ban")) {
// Easy way to get member object though mentions.
var member= message.mentions.members.first();
// ban
member.ban().then((member) => {
// Successmessage
message.channel.send("👋 " + member.displayName + " has been successfully banned https://gfycat.com/playfulfittingcaribou 👉 ");
}).catch(() => {
// Failmessage
message.channel.send("Access Denied");
});
}
});
can you use code blocks please
bruh two message events?
can someone help me with user storage
don't tell me you have an event for every command?
Resolving: total 393, reused 393, downloaded 0, done
ERROR ENOENT: no such file or directory, chmod '/rbd/pnpm-volume/5b146d33-2649-47dc-b5df-4bb5db586bdc/node_modules/node/bin/node'```
help
@indigo cloud
Resolving: total 393, reused 393, downloaded 0, done ERROR ENOENT: no such file or directory, chmod '/rbd/pnpm-volume/5b146d33-2649-47dc-b5df-4bb5db586bdc/node_modules/node/bin/node'```
help
``` code here ```
this is code blocks: ``` code here ```
just do that
help
@earnest phoenix what did you do?
k
@quartz kindle node
// Easy way to get member object though mentions.
var member= message.mentions.members.first();
// Kick
member.kick().then((member) => {
// Successmessage
message.channel.send(":wave: " + member.displayName + " has been successfully kicked :point_right: ");
}).catch(() => {
// Failmessage
message.channel.send("Access Denied");
});
}
});
client.on("message", (message) => {
if (message.content.startsWith("$ban")) {
// Easy way to get member object though mentions.
var member= message.mentions.members.first();
// ban
member.ban().then((member) => {
// Successmessage
message.channel.send(":wave: " + member.displayName + " has been successfully banned https://gfycat.com/playfulfittingcaribou :point_right: ");
}).catch(() => {
// Failmessage
message.channel.send("Access Denied");
});
}
}); ```
there
@earnest phoenix
if it doesnt work, try using 12.x
@indigo cloud without seeing your full code idk but it looks like it should work
Türk varmı
@quartz kindle
node v10.15.3, with pnpm
Installing...
Performing headless installation
ERROR ENOENT: no such file or directory, chmod '/rbd/pnpm-volume/5b146d33-2649-47dc-b5df-4bb5db586bdc/node_modules/node/bin/node'```
Alright
stop sending your code
@earnest phoenix var
@earnest phoenix Arda benim bot ilidebir vds de olmasına rağmen offlineye düşüyor
hmm
vds belki kapanıyor olabilir ?
@quartz kindle
node v10.15.3, with pnpm Installing... Performing headless installation ERROR ENOENT: no such file or directory, chmod '/rbd/pnpm-volume/5b146d33-2649-47dc-b5df-4bb5db586bdc/node_modules/node/bin/node'```
help ?
Onu nasıl yapabilirim
then try with v12
onu aldığın yeri söyle @earnest phoenix
hi, what command, in terminal, can i use to restart my bot?
can someone help me make a levelling system
Tamam
kk, ty
then try with v12
@quartz kindle ok
i accidentally put z ._.
that doesn't restart ur bot
ctrl c?
wdym restart though
@quartz kindle I did v12 but it still doesn't load all commands
node .?
why ?
ok
@quartz kindle I did v12 but it still doesn't load all commands
help
and
help
oh that
why my bot is lagged?
@sullen portal what ?
@sullen portal where ?
i do it at the front
it worked for me
i just put that the front
and that error didnt come anymore
@earnest phoenix put ; at the end
bot.setMaxListeners(100);
yes
@sullen portal where should i put this?
like at the front
lag
its slow?
is there a way to pull in json as a variable from a url? I have a url that just has some raw json on it and I want a embed to contain the value of one of the items inside that json is there a way to do that?
his went past his max listeners
@halcyon ember make a request to it
kk
@quartz kindle There are 94 commands
O_O
and which one doesnt load?
that command might be the problem that caused it to not start in v11
Can anyone help me make a partner bot in discord.py? The bot should have a command where you can choose a channel for the Partner message. And should send a message every 6h in all partner channels. Can anyone help me there? :D
@quartz kindle can u help me make a levelling system
I dont think he gonna help 
@quartz kindle sorry
i really need help
but if your bot gets mtued dont run to me
whats that
a package
but
how do you use it @astral yoke
yeah but a beginner one
your bot got approved
dont attack users
ima just read the description
@quartz kindle all commands loaded but does not send the message I loaded all commands to the console
what message?
poor tim with the pings
console.log('Komutları yükledim!')
console.log(`${client.user.username} ismi ile giriş yaptım!`)
console.log(`Oyun ismimi ayarladım!`)
console.log(`Şu an ${client.channels.size} kanala, ${client.guilds.size} sunucuya ve ${client.users.size} kullanıcıya hizmet veriyorum!`)
console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] BOT: Aktif, Komutlar yüklendi!`);
console.log(`[${moment().format('YYYY-MM-DD HH:mm:ss')}] BOT: ${client.user.username} ismi ile giriş yapıldı!`);```
file : events/ready.js
@quartz kindle
@astral yoke can i use a command handler for it
those console.logs do not work?
@quartz kindle why ?
are you saying that the code you just posted is inside the ready event and it doesnt work?
it is necessary to throw these articles into the console after the commands are loaded
but not throwing
google translate from turkish to english is very bad lmao
show your index.js
or whatever your main file is
@earnest phoenix
how do you do the categories you did
that u showed me
@earnest phoenix he says show your main file. not your main file's name.
lol
How do I know how many servers my bot is in
All the answers I got before were too basic and then I got confused when I tried to do what they said
by checking the size of your guild cache
on discord.js v12 its client.guilds.cache.size
V11 - bot.guilds.size / client.guilds.size
Tim ya beat me to V12
I was gonna do both lol
What if I don’t use discord.js
What do u use
what are you using then
Hey guys, I need some advice. Need my bot to run a python script. How would I do that? Tried googling but no result.
that doesnt help us
that doesnt help on what language it is
@humble plaza firstly, what language is the main
secondly
what is le python script
It’s an app that doesn’t use a known language
3rdly why
then we cant help with it if we dont know the language
lol
then how do you code it?
It has an easier code system
no? lmao
does it support scripts?
Not rly
well then there u go
im not sure how you're expecting us to help you then
how do you make commands on it?
Like this:
send screenshot

@quartz kindle would you mind if i dmed you about a few things in relation to the discord bot developer verification process?
Bruh
Discord bot maker?
breh
whats the name of the app?
discord bot designer i reckon
@steel drum sure
Never seen so much people here
@lusty furnace app name?
We all just lurk
@zenith terrace thats discord bot designer
unless someone says an app is an 'easier code system`
its this useless shit https://fbi.is-inside.me/ArORjguk.png
@modest maple
Is it possible to have a bot run some python commands to talk to my raspberry pi. Basically I have an automated plant feeder and I want my bot to water them on command lol.
eh I tried that before
also
js
yo wtf i dont even own a sony device https://fbi.is-inside.me/2dyuiZFI.png
@humble plaza You should be able to (I dont know much nodejs) create a sub process and execute the py script with a command e.g python myscript.py
guys
im trying to pull in a json from url using fetch
it can display a value
but how to I make it send a value inside a value inside a value
{"time":1589406571,"global":{"workers":2,"hashrate":0},"algos":{"primesr":{"workers":2,"hashrate":4151801719.4666667,"hashrateString":"4.15 GH"}},"pools":{"riecoin":{"name":"riecoin","symbol":"RIC","algorithm":"primesr","poolStats":{"validShares":"152182","validBlocks":"34","invalidShares":"1468","totalPaid":"765.60657390000000211"},"blocks":{"pending":3,"confirmed":31,"orphaned":0},"workers":{"RSA3aZhFTKABYLGbQBcwcakQDrDtD125VB":{"shares":97,"invalidshares":0,"hashrateString":"2.31 GH"},"RTVUASUkHjMLUae1ZDa2tVwKjyTTwSQVXZ":{"shares":77,"invalidshares":6,"hashrateString":"1.84 GH"}},"hashrate":4151801719.4666667,"workerCount":2,"hashrateString":"4.15 GH"}}}
I want the hashrateString to be printed
but when I do algos[0].primesr[0].hashrateString it says cant print empty
[{
bla:1
}]
``` you see the object is inside of an array, so you have to do [0].bla
but if its just ```js
{
bla:1
}
in the json you posted there is only objects, no arrays
when i do algos.primesr.hashrateString it says cant read property of undeifined
const Discord = require('discord.js')
module.exports = {
name: 'avatar',
description: 'Ping!',
execute: async(client, message, args) => {
let embed = new Discord.MessageEmbed()
.setTitle(`${message.author.username}'s Avatar`)
.setImage(message.member.avatarURL)
message.channel.send(embed)
},
};``` my embed only has the title its not sending it with the user avatar
try console.log(yourjson.algos)
yep that worked thanks

