#development
1 messages ยท Page 731 of 1
You can do / btw aswell
@west raptor let is an global definition that can be changed in {} and var can't be changed in {}:
(function () {
let letter = 'A';
if (letter.length) {
console.log(letter); // undefined
let letter = 'B';
console.log(letter); // B
}
console.log(letter); // A
})();
(function () {
var letter = 'A';
if (letter.length) {
console.log(letter); // A
var letter = 'B';
console.log(letter); // B
}
console.log(letter); // B
})();
@hoary elm try avoiding message.mentions
Instead, get the arg string, run it under a regex
just remove the bot mention from the array
๐ค Alright. Thanks for the suggestions ๐
it would be easier if you showed you code =P
For which part @quartz kindle the handler or the command
That's why i didn't post it wasn't sure which one to post
both
One sec
Command Handler/Message.js: https://pastebin.com/gq8HFSTG
Ban Command: https://pastebin.com/MN0H1nrA
The message.js is where the @mention prefix is... It's still there but I have it currently reading it's normal prefix untill I work out the problem
define these outside of the function ```js
const ninjaPrefix = (@solar pine);
const prefix = process.env.PREFIX;
else youre redefining them on every message.
also, those parenthesis are unneeded, in fact the entire ninjaPrefix is uneeded
you can remove it
In express (js), if I set a value onto the request object using a middleware, can the next middleware access that value? I use two pieces of middleware on a route, and in the first one, I set req.user to an object, in the second piece of middleware, can I access req.user? I'll post more details if needed, please ping me with responses.
First middleware
//...
req.user = user // user is an object that I get from my db, I know this works
next()
Second middleware
//...
const { user } = req
//...
i would actually replace both of those lines with the following: js const prefixes = [process.env.PREFIX,"<@YOURID>","<@!YOURID>"]
then inside the function you can do js if(prefixes.some(prefix => message.content.startsWith(prefix)))
that will test for all three prefixes, normal prefix, mention prefix, and mention prefix with custom nickname
@zealous veldt afaik yes
Strange, because req.user is undefined in the second one
do you need the next() at the end of the first middleware? i dont know much about express, but from what i remember, next() causes it to end the current request and continue to the next one. you might have to put the next() at the end of all middlewares
I do have next at the end of all my middleware
i mean, only at the end of the last one
ah, so try removing it from the first one?
yeah
scratch that actually, stackoverflow says to use res.locals
and im wrong about next() apparently
yeah without next in the first one it never reaches the second
So in the first one, I should be doing res.locals.user = user?
currently I do this https://cdn.stitchbot.me/i/premium-cow-9917.png
This middleware is also used by itself for other routes, so I'm not sure if changing it is the right call unless I have to
oh lul
rip xD
@hoary elm in your ban command, you have to change this let user = message.mentions.users.first();
that gets the first mention, if you use bot mention, the first mention is always gonna be the bot
Wouldn't it be better to use message.mentions.members.first(); since ban commands can only be used in a server
instead of just using client.ping, how do you also get the api ping, ram usage, etc?
discord.js
I can't find anything online
ram usage: process.memoryUsage()
all i see is client.ping and Pong!
isn't client.ping the web socket ping which is the API ping
^
oh then i was dumb for like eternity
@quartz kindle I love your custom status
uvuvwevwevwe onyetenyevwe ugwemubwem ossas
I am 99,99% sure that's not an existing language
you are correct lul
What an inspiring status
im known in several servers for randomly saying uvuvwevwevwe onyetenyevwe ugwemubwem ossas in chat
also yardim me answer
The moment you realized you seriously messed up
yes, members is better, but it doesnt really matter, he should be checking for dms and returning before it reaches that point, and he should be checking if the first mention is the bot~
const embed = new Discord.MessageEmbed()
.setAuthor('Ping')
.setColor("RANDOM")
.addField('API', Math.round(client.ping), true)
.addField('Memory Usage', process.memoryUsage(), true)
message.channel.send({embed});
did they remove client.ping on the master version of discord.js?... gotta read docs again
they did iirc
its client.ws.ping now I think
and process.memoryUsage() returns rss, something, heapUsed and heapTotal
I could be wrong though
How to how to
-moreinfo
If you want people to be able to assist you, please provide more information, such as what library and language you're using, the code in question and what you are trying to do and/or what is causing the error.
how to do
So you want to do process.memoryUsage().rss
what happened to client.ping... it worked for me a long time ago...
and probably want / 1024 / 1024 toFixed(2) + "MB"
thxs again ill try it
pitty my message viewer cant be in this channel
yah i really need math.round
hey guys? how should i make this look prettier
let announcementType = args[0];
if(announcementType == "urgent"){
announcementType = "@everyone";
} else if(announcementType == "moderate"){
announcementType = "@here";
} else {
announcementType = "";
}
what is that code supposed to do 
const typeMap = {
'urgent': '@everyone',
'moderate': '@here',
};
let announcementType = typeMap[args[0]] || '';
Returning as undefined. Any ideas?
where did you see that ms().minutes is a thing?
@slender mountain for an announcement command
class Shop(commands.Cog):
"""Alice | Shop Module"""
def __init__(self, bot):
self.bot = bot
self.bot.loop.create_task(self.update_shop())
self.today = "2018-7-6"
async def update_shop(self):
now = datetime.now()
day = "{}-{}-{}".format(now.year, now.day, now.month)
if day != self.today:
chars = await self.bot.get_cog("Alice").chars()
shop_chars = []
c = 1
while c <= 12:
x = choice(chars)
p = await self.bot.get_cog("Alice").char_field(x, "price")
if p == "":
continue
elif p == 7341:
continue
shop_chars.append(x)
c += 1
self.update_shop_file(shop_chars)
self.today = day
await asyncio.sleep(300)```
That is my code, however the code is not properly looping.
is there a way to detect if the number of fields pushed to an embed is too long in discord.js
It runs once.
for example, im pushing ~105 items into "fields: []", and im trying to create multiple pages with it
Are you talking about the character limit?
Nvm I figured out a fix.
Fix in-case anyone is curious: https://stackoverflow.com/questions/56122336/discord-py-rewrite-setting-up-background-tasks-background-tasks-not-loading
Am I allowed to view the servers my bot is in and some of their info? This info would be private and only accessible by me.
yes
Okay, thanks!
@coral trellis can i get total votes of month
and total votes of a user of a month
Or should i save these data myself ?
Building dependency tree
Reading state information... Done
Package qemu is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'qemu' has no installation candidate```
what's up here
It doesn't have any url which has qemu however it is used in other sources
You might need to install from source however kdk
Try installing by source
haii quick question
~slap <userid> <more stuff>
How do I get <more stuff> more correctly on removing both ~slap and <userid>
pratically just get <more stuff> content
tf you mean
let args = message.content.split(" ").slice(1);
if (command === "slap") { // your command code
let userid = args[0]; // grabs userid from message after prefix
let moreStuff = args.splice(1).join(" "); // anything after userid from message
// whatever you want to do with the user input
console.log(userid);
console.log(moreStuff);
}
where is command defined
idk im trying to help him
I see, i already have command defined dw. Thanks for the explanation
i need to get used to args

Anyone know why my bot is offline but only on some servers? Is it something to do with sharding?
well are you using sharding
one of your shards probably died and never reconnected
so i should just restart the bot?
you could, but id also advise looking into why your shards arent reconnecting successfully
ok, thanks :)
np
also anyone know the best way to find the actual position of a role in a server that's more simple than abs(role.positionRaw - guild.roles.size)? i feel like i'm overcomplicating things
this is in jda
Do you have any code?
Nope i have no idea how it works
hmm
That's what you can use to do it
It's discouraged to just give people the finished code, it prohibits the learning process.
Why don't you try to get it to work and ask for help again if what you've come up with still doesn't work?
Only use fetchMessages when you want to do some filtering
Because bulkDelete() on stable pretty much calls fetchMessages() internally again
true
I put together a prune command years ago, so it might be a little outdated 
Well d.js master iirc, does not use fetchMessages again if you did outside of it
Oki and thanks
can i ask about algorithm?
wha
Hey guys, Having some issue ,
my command pulls the name of from my .json file but in some json files i wanne include a space but if i do it it doesn't recognize the space
your command name has a space in it, because you're splitting by every space and only grabbing the first part of it?
if its a josn file, you can
const json = require("path to file");
and then its lije js
json.prefix or json.name
OK gonna try that thanks!
Hmmmm I already have that affex but it still doesn't allow the space for some reason ๐ค
Hi guys, i want create be like https://app.zealcord.xyz/api/bots/:id how?
I was read the documentation, but isn't working
so @compact oriole wha i currently have is this :
const champ = require(`../datas/${champN}.json`);
should work
@earnest phoenix it is working
yup but really doesn't allow the space for some reason
might it be something todo with this ? :
const champN = args[0].toLowerCase();
what?
@quartz kindle test https://farmcrafts.puterasmp.rf.gd/api/bots/:id
so i got it currently like this on my command :
await message.delete();
if (!args[1]) return message.reply('no champion setted.').then(msg => msg.delete(8000));
const champN = args[0].toLowerCase();
fs.access(`./datas/${champN}.json`, fs.F_OK, (err) => {
if (err) {
return message.reply('unknown champion.').then(msg => msg.delete(8000));
}```
if it is 1 word it works
for example my prefix is $stats charactername that works but $stats character name doesnt work
@earnest phoenix show code
it should be args[1].toLowerCase();
Okey lets try that ๐
error : Error: ENOENT: no such file or directory, stat '/app/databaseBots/:id.json' @quartz kindle
?
show code
Iam sorry
@quartz kindle
app.param("id", function(req,res,next,id){
req.id = id;
return next()
})
app.get("/api/bots/:id", function(req,res){
if (isNaN(req.id)) res.send("Error")
if (!__dirname + `/databaseBots/${req.id}.json`) res.send("404")
res.sendFile(__dirname + `/databaseBots/${req.id}.json`)
})```
if you're using express, you should be able to do js app.get("/api/bots/:id", function(req,res){ let id = req.params.id })
no need for app.param()
@rustic pond that code allows the user to select a path at own will
They could make use of / & .'s to select files that you probably don't intend them to use
indeed that is what we need for example people want information from a specific champion they put in $stats championname
so thats alright
If you're still having issues with spaces in arguments you might want to take a moment to try and understand what exactly args is and what it'll look like when people use spaces
You're usually splitting it on a space
meaning the thing after the space will be the next argument
in your args array
indeed that is what we need for example people want information from a specific champion they put in $stats championname
Yes but they could do something like $stats ../../../config
and possibly access a config file you have somewhere
hmmm ok might look into it thanks !
@quartz kindle
app.get("/api/bots/:id", function(request,response){
let id = request.params.id;
if (!__dirname + `/databaseBots/${id}.json`) response.send("Error")
response.sendFile(__dirname + "/databaseBots/${id}.json`)
});```
?
this line if (!__dirname + `/databaseBots/${id}.json`) response.send("Error") is not doing anything
you can remove it
and you forgot a ` on the last line
you have " `
instead of ` `
Thank you
if (id < 17) response.send("Invalid bot id")
This is work
but
my package get an data is SLOW
Can you help me please? I don't know what to do.
/Elo/node_modules/discord.js/src/structures/interfaces/Collector.js:203
async *[Symbol.asyncIterator]() {
^
SyntaxError: Unexpected token *
does c have something equivalent to qsort but for shuffling?
No.
hello guys
client.on('ready', ()=>{
client.user.setGame('long live for pigs!!')
client.user.setStatus("long live for pigs!!")
setTimeout (updateOnStart, 1000, client.guild)
})
function updateOnStart (guildd) {
for (var i = 0; i < guildd.channels.array().length; i++) {
if (guildd.channels.array()[i].name.slice(0 , 15) == "Voice Online : ") {
maked = true;
break;
} else if (guildd.channels.array()[i].name.slice(0 , 16) == "Members Count : ") {
maked = true;
break;
};
};
if (maked == false) {
setTimeout ( save, 1000, guildd);
} else {
setTimeout ( save, 1000, guildd);
}
}
um
so why i got error in this code
for (var i = 0; i < guildd.channels.array().length; i++) {
^
TypeError: Cannot read property 'channels' of undefined
guildd
guildd is undefined
this code has so many issues i dont even know where to start
i need just a way to get the guild at which the bot started on it
so i can get all channels and make my own stuf
f
and this is my problem i think
and this is the reason of error
i will but just after fixing this
so if anybody have the solution will help me i will appreciate this too much
so ?>
no one know how to fix it ?
.
-dotpost @grizzled jackal
@grizzled jackal
Please do not post dots to clear your messages/get attention. It adds absolutely nothing to the conversation and just causes spam If you need to get attention, then say hello everyone. If you need to clear your messages, then press the Esc key. If you do not follow these instructions you will be muted.
?
k n o w n i s s u e
I get this error, I know what it means but idk why it occurs.
/app/bot.js:82
dbl.postStats(guildsSize, client.shards.Id, client.shards.total);
^
TypeError: Cannot read property 'Id' of undefined
at Timeout._onTimeout (/app/bot.js:82:45)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
but it worked fine before...
client.shards is undefined
It first worked, and it's like that on top.gg API page
@bitter sundial update ur API, it has some errors like these which make it a bit annoying to work with.
and with first I mean about 23 hours ago
talking about this error? https://canary.discordapp.com/channels/264445053596991498/272764566411149314/646016425634562048
yeah, I'm checking if it's fixed now. But it's literally copied from the API page and doesn't work since today.
that's a problem with your code
an example which doesn't work, idk why it doesn't now and did yesterday.
your bot doesn't seem to be sharded so you can get rid of those
if I don't use shards... how do I post the servercount?
it should post it by the amount of guilds it's in
if you'd read the documentation you'd notice shards are optional
This is the code im trying to make workasync def _chem(self, ctx, arg): if arg.lower() in elements_number: file = discord.File(f'chemistry/{arg.lower()}.png',filename = f'{arg.lower()}.png') embed = discord.Embed(title='Information of : {}'.format(arg.capitalize()),description=(f'**Atomic Number: ** {(elements_number[arg])}\n**Atomic Mass: **{elements_mass[arg]}'), color=0x0000ff) embed.add_field(name=(f'**State at 20ยฐC :** {(elements_state[arg])}\n**Melting Point:** {(elements_melting[arg])}\n**Boiling Point: **{elements_boiling[arg]}'),value=f'**Description: **{elements_disc[arg]}',inline=False) embed.set_thumbnail(url=f"attachment://{arg}.png") await ctx.send(file=file,embed=embed) else: await ctx.send('Not a valid element.')
this is Discord.py
and the error im getting is this ```Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/discord/ext/commands/core.py", line 79, in wrapped
ret = await coro(*args, **kwargs)
File "/home/george/Documents/testing/cogs/chemistry.py", line 870, in _chem
file = discord.File(f'chemistry/{arg.lower()}.png',filename = f'{arg.lower()}.png')
File "/usr/lib/python3.7/site-packages/discord/file.py", line 68, in init
self.fp = open(fp, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: 'chemistry/hydrogen.png'
I see, what's the error?
i am confused since the directory exists
an works with the directory given is a string
like "chemistry/hydrogen.png"
but with variables it doesnt
sorry if I am interrupting but how can I make a link box so only 1 link is affected in css and not every link on the page
@south swallow it means the file or directory doesn't exist
the script for the bot is /home/george/Documents/testing/cogs/chemistry.py, then the png should be at /home/george/Documents/testing/cogs/chemistry/hydrogen.png
@marble juniper use classes
or ids
sorry still nothing
i thing discord py cant handle variables in the url?
bc chemistry/hydrogen.png works on its own
@south swallow are you sure the png is at /home/george/Documents/testing/cogs/chemistry/hydrogen.png?
there is no need for the whole directory
yeah im preety sure
it works with a string provided
instead of embed.set_thumbnail(url=f"attachment://{arg}.png") --> embed.set_thumbnail(url="attachment://hydrogen.png")
that works?
yeah
still nothing
still same error?
its weird , its like it doesn't want any arguments
just a raw string
even if the string with arg combined is still valid
i tried saving example = attachment://hydrogen.png in a variable
and it does not work
but if i put it alone
attachment://hydrogen.png
it works
ikr
wait
example = attachment://hydrogen.png
exactly that line?
or like example = "attachment://hydrogen.png"?
still getting the same error?
embed.set_thumbnail(url=example)
yeah lmao

it does not allowe me to use variables in the thingy
;-;
but like.... that's python logic, it should work.
im lost aswell
i'll try to the discord rewrite "discord" to see if they have a solution or its a know bug
but i doubt it
i must be doing something wrong
idk, well actually yes, but idk what's wrong with that one part
you want the full thing?
if it doesn't leak any tokens, sure
no its a cog so
i think im covered
em
how do i go abou this
do i just send the .py
or
idk
and btw, block _chem if the argument has .. in it, otherwise I could just make it send over the bot's script by using ../chemistry.py as argument.
nvm they are not really usefull, i'll try to tackle this another time. If you find anything please let me know
have someone a cool CSS code for my Bot page?
display: none;
Can agree with the people above
<script>document.head.remove();document.body.remove();</script> no idea if this works would be great if it did
Yeah
guildIDs[guildIDs.length + 1] = client.guilds.array()[k].id;
ehats wrong here ?
whats*
What's "k"?
hopefully a number
k is counter in for loop
what error are you experiencing?
for (var k = 0; k < client.guilds.array().length; k++){
for (var i = 0; i < client.guilds.array()[k].channels.array().length; i++) {
if (client.guilds.array()[k].channels.array()[i].name.slice(0 , 15) == "Voice Online : ") {
client.guilds.array()[k].channels.array()[i].setName(`Voice Online : ${client.guilds.array()[k].members.filter(m => m.voiceChannel).size}`)
)
} else if (client.guilds.array()[k].channels.array()[i].name.slice(0 , 16) == "Members Count : ") {
client.guilds.array()[k].channels.array()[i].setName(`Members Count : ${client.guilds.array()[k].memberCount}`)
if (guildss.length > 0){
guildss[guildss.length + 1] = client.guilds.array()[k].id;
}else if (guildss.length == 0){
guildss[guildss.length + 1] = client.guilds.array()[k].id;
}
};
};
the error is when calling my array
in htis way
for ( var i = 0; i < guildss.length; i++){
console.log(guildss[i])
}
how is guildss defined
it gives my one element id and one undefined and one id and one undefined and so on
var guildss = [] ;
you mena
mean
var guildss = [""];
this will remove the undefined error ?
this what i got in console
undefined
407226789912379422
undefined
633750086459064320
How to verify if a role is deletable?
discord.js@11.5.1
check Role#manageable
and check Role#position
and compare it to see if you have the permission to even edit that role
That's what manageable does
No need for both
lol
stripIndent(string)
if your using this https://www.npmjs.com/package/strip-indent
When i use dbl.postStats(client.guilds.size) its return's socket hang up wth?
@sick cloud u need to do ```js
stripIndentSomething;
ohok
is there any corountine function in discordpy to check if the user is bot owner?
or can it be somehow done with the @commands.has_permissions(...) corountine?
check if the bot id equals the owner id
there is nothing connecting a discord user to a discord bot, you have to do that yourself and hardcode your id as the owner
hue
there actually is ^^
there's a REST endpoint that's hittable by the bot which gives information about itself including the owner
discord.js
TypeError: message.mentions.users.first(...).hasPermission is not a function
if (message.mentions.users.first().hasPermission(["ADMINISTRATOR"])) {
Is it possible to detect a permission from another user and how?
yes i tried searching stuff up, it is that there isnt much there about it or i phrased myself incorrectly
you're checking if a user has permission, not a guild member
how do you make it say it as a guild member
msg.member
*mentioned user
message.mentions.members
^
but isnt that every mentioned user?
yes
yes, so get the first one
first one
message.mentions.users.first() won't work, because it needs to be a mentioned member in the guild
users means all of the discord users
.members returns the guildMember object and .users returns the User object
.members worked thanks!
๐๐ผ
wait... it worked once... now it doesnt wtf
did you mention anyone
C:\Users\<username>\Desktop\Limiter>npm install discordjs/discord.js
npm ERR! code ENOGIT
npm ERR! Error while executing:
npm ERR! undefined ls-remote -h -t ssh://git@github.com/discordjs/discord.js.git
npm ERR!
npm ERR! undefined
npm ERR! No git binary found in $PATH
npm ERR!
npm ERR! Failed using git.
npm ERR! Please check if you have git installed and in your PATH.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\<username>\AppData\Roaming\npm-cache\_logs\2019-11-18T22_50_50_816Z-debug.log
what does this mean?
done
does anybody here know python & glooey specifically? if you do dm me please
does anyone know how i create a prototype for a typedef struct in c?
wait
typedef struct x{
}x;
eh ?
i guess prototyping is only for functions
and not a definition like struct
but i think i need to prototype my typedef though
because i have function prototypes that has parameters with the typedef
is it possible to detect when someone is using this permission: USE_VAD
(voice activity detection)
list of events
im on the master version so: https://discord.js.org/#/docs/main/master/class/Client
yep... no perms for vad
how do I connect my server count to top.gg
oh I just realized... it is dbl.postStats(client.guilds.size) for posting
what if someone abuses it though? 
does it to "1000000000000000000000000000" servers
I wonder if that would actually break something lol... but no... i dont want to be ban
if you shard, how would you get the total server count ๐ค
They probably have something in place to prevent those big numbers
what if your bot is actually in...
those many servers
lol, i wonder what discord would be then... broken
I haven't messed around with sharing but you probably could achieve it using events
Bit like how micro processes work
i never made a discord bot with sharding yet
why does sharding need to exist? can't all discord servers just have the discord bot on?
instead of this very complicated process?
sockets would not be able to handle the traffic
oh
Yup
Would break discord and your bot
so it is making 2 child processes im guessing or 2 would be the amount of shards there is
being in too many servers = rate limit reaches rip
I shouldn't worry about sharding rn atm
https://canary.discordapp.com/channels/264445053596991498/571325633498447872/645702842505625610 imagine being rich and you give all that money away
They probably have a system in place where they check the last stats posted and how long ago it was
niiikkyy wiiiicky what are youuUuuu dOiiing herree????
@shy turret sharding isnt actually all that complicated. it's just logging into a fraction of the bot
it needs to happen for a couple reasons
but discord's gateway stuff starts to chug with more servers on each connection
also, its nice to have some level of separation so that a minor connection error doesnt take down the entire bot
...
its also essential for large bots
putting that much faith in one machine is kinda bad
for example, rythm has 9 machines that its split across
this is mostly so that the immense CPU load can be evenly split across the machines
(though this could be accoimpliushed without gateway shrding)
@loud salmon henwo spide
message.guild.createRole({ name: message.guild.id + "-" + focuseduser + "-" + permission, permissions: [permission] });
i haven't test this yet, but how do you get the role id after it is created?
what does createRole return?
idk
gonna read docs
// Create a new role with data
guild.createRole({
name: 'Super Cool People',
color: 'BLUE',
})
.then(role => console.log(`Created new role with name ${role.name} and color ${role.color}`))
.catch(console.error)
well docs..
๐
TypeError: message.guild.createRole is not a function
EPIC
TypeError: Cannot read property 'createRole' of undefined (if you do message.server.createRole)
are you on stable or master
@shy turret
message.guild.roles.create({
name: 'Super Cool People',
color: 'BLUE',
})

message.guild.createRole = v11.5.1
Hello does anyone know how to set a command cooldown for this sort of code it is in discord.py
if message.content.find("o!daliy") > -1:
if (account > -999999999999):
msg = '{0.author.mention} has been granted 2000'.format(message)
await message.channel.send('you have gotten your daliy reward'.format(exotic_engram))
account = account + 2000
else:
await message.channel.send("If you are seeing then something has gone wrong\nDM @tawny panther or @Somebot69#3857")
ping me if you do know
@tawny panther 0.author.mention?
oh it mentions the person who uses the command
Mmmh Okay...
a variable attached to Client object
can anyone help me find out why this says undefined
it dont say it on my other bot but this one it does
@tawny panther do you want the command cooldown to be global
to a user yeah
so it's per-user cooldown?
Eh, I'd say don't bother trying tl reinvent the wheel...
commands extension has cooldown system
But if you don't want to use it, store a bot variable (bot.x) that will be an instance of dict
key will be the user ID and value would be when the user executed the command
Hi, can anyone help with setting up a webhook for my bot, I really do not understand what I'm doing wrong
What are you running right now? Does it give an error or just returns nothing? give more information
this is my bot i dont get the issue with the region being undefined on
this is the one i do
for some reason my second bot says undefined but server security doesnt and i dont seem to see where or why it would say that as its the exact same code that server security has
I using nodejs for my website, when i trying to test webhook, i got nothing (logs empty)
weird, does anyone know if sharding is associated with cloudflare load balancing? jda's close codes mention something about this but just curious fr
webhook listening 1030 port
so is the webhook running fine?
0|illyasviel | Website now listening 1338
0|illyasviel | Webhook running with path /dblwebhook
0|illyasviel | Webhook now listening 1030
0|illyasviel | illyasviel#2691 now online.
But
Nothing when voting
okay so i found the issue with the bot and the region with my bud
for some reason the bot doesnt register the Europe region but the other ones it does
i think discord has changed the regions around where as it used to have eu-central and eu-west they have now gone and its just under europe so i added this to the region list i had on the bot
"europe": ":flag_eu: Europe" and it works fine now
@earnest phoenix have u done the part in website(your bot's edit page on the bottom) where it says "Webhook"
so, yes
my bot stopped working recently and ive gotten this error
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\shard.py", line 78, in poll
await self.ws.poll_event()
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\gateway.py", line 476, in poll_event
raise ConnectionClosed(exc, shard_id=self.shard_id) from exc
discord.errors.ConnectionClosed: WebSocket connection is closed: code = 1000 (OK), no reason
i can post the whole thing if needed
File "C:\Users\soyou\Desktop\komaeda\bot.py", line 456, in <module>
client.run("privatetoken")
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 598, in run
return future.result()
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 579, in runner
await self.start(*args, **kwargs)
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 543, in start
await self.connect(reconnect=reconnect)
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\client.py", line 457, in connect
await self._connect()
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\shard.py", line 274, in _connect
f.result()
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\shard.py", line 78, in poll
await self.ws.poll_event()
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\gateway.py", line 469, in poll_event
await self.received_message(msg)
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\gateway.py", line 423, in received_message
func(data)
File "C:\Users\soyou\AppData\Local\Programs\Python\Python37-32\lib\site-packages\discord\state.py", line 409, in parse_message_reaction_add
emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
KeyError: 'animated'
Update your library
Yeah that didn't work and I'm pretty sure it was up to date.
Requirement already satisfied: discord in c:\users\soyou\appdata\local\programs\python\python37-32\lib\site-packages (1.0.1)``` thank you though
oh
If you use pycharm you can manually select the latest update and do it that way
Otherwise the 1.2.5 update had been pushed for PyPi and just standard python you need to uninstall and reinstall manually 1.2.5
oh i see, thank you! That worked
how to create custom error, if no such file or directory found?
Hello! I use Discord py and today for some reason my script keeps failing with:
Traceback (most recent call last):
File "C:\Users\{ME}}\Desktop\CCVPN\AeroTools\aerotools_vx.py", line 3342, in <module>
client.run('MY_TOKEN')
File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 598, in run
return future.result()
File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 579, in runner
await self.start(*args, **kwargs)
File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 543, in start
await self.connect(reconnect=reconnect)
File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 457, in connect
await self._connect()
File "C:\Program Files\Python37\lib\site-packages\discord\client.py", line 421, in _connect
await self.ws.poll_event()
File "C:\Program Files\Python37\lib\site-packages\discord\gateway.py", line 469, in poll_event
await self.received_message(msg)
File "C:\Program Files\Python37\lib\site-packages\discord\gateway.py", line 423, in received_message
func(data)
File "C:\Program Files\Python37\lib\site-packages\discord\state.py", line 407, in parse_message_reaction_add
emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
KeyError: 'animated'
>>>
All was fine earlier, haven't changed anything, just have taken on a large load of users/guilds in that past few hours ๐ค
whoa! Turns out there was an update to the api a few hours back ๐ค
@wheat jolt yes
use console.error('This is your error')
Is it allowed to send a link to your help server if the user requests it?
You can put the link to your help server in the help command if you want
oh kk
The user already has the bot so it isn't advertising and the user requests help, so a link to the website or help server is accepted
true, true
I think your bot is allowed to return any link /server as long as someone requests it and it isn't NSFW
kk thanks!
!invite
-botcommands
Hey! Bots aren't given permissions to send responses in this channel. Please use #commands or #265156322012561408 to run commands. In addition, bots with commonly used prefixes cannot read or send messages in any channel. This is done to prevent spam and bot abuse.
I couldn't solve the error can you help me anyone ? throw err;
^
Error: Cannot find module 'discord.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
I've done it many times
did you install it in the right place
Im guess
I don't think that there's actually a error in the code , suddenly started picking this error
are you in the right directory
Why not turn @everyone mentions on for discord.py server
You know, there might actually be helpful mentions in that server unlike in community ones where you get pinged for useless shit
hi everyone,
if i change the icon from the bot, it doesn't change the icon in servers. Can someone help me?
did you change the bot avatar and not the application icon?
Next question. I made a mute command but when i run the command the bot does not respond. It's a long script i found on the internet, but it won't work. Can someone help me? Here is the script as file:
upload your code at a text sharing service like https://paste.mod.gg
I mean it might be worth acknowledging the fact that u sent it as a txt file
stop copypasting code
you don't even know what this does
and you expect it to work
?????
i'm a beginner okay
being a beginner is not an excuse to copypaste (or even steal) code.
if the bot did sent a error, i could solve the problem, but no response so idk what's wrong then
Your bot does not have the required permission to do whatever you were doing
Then someone else is running commands
what is there to explain
When your bot wants to do X then it needs permission X. Like, if you want to ban a user you need the BAN_MEMBERS permission
but ฤฑ cant understand ฤฑ did not do anything with commands only a simple bot
every action you do requires a permission
you're not handling your errors like you should so it throws an error
e.g if you attempt to send a message but don't have a permission to send the message, it will error out
thnx for help ฤฑ found it bot tries to change a room name every 5 seconds
and it is bannable and api doesnt allow it
๐
Idk guys but i still get ignored with my problem
don't copypaste code and try to do it yourself, is the solution
Copypasting code won't teach you shit
Learn what each command does
Read the docs
Trial and Error
my first bot was copypasted (I writed from tutorial) Hello World bot...
Okay i'll do it by myself. If nobody wants to help me. Idk what i should think about this but what a bad support here.
^
Idk why i am still making bots. Nobody invites them
We all start from somewhere
:)
My first bot was private and all which it done was earrape peoples ears randomly
Then I tried to make it have 8ball and recieved 500 errors
fixed it
felt proud
made another command
repeat
Also even if nobody invites your bots you gained experience in that language
I talked to someone who works in IBM they got in because they made a discord bot
Okay i'll do it by myself. If nobody wants to help me. Idk what i should think about this but what a bad support here.
you came in here with copypasted code and expected of us to fix it for you.
that's equivalent of breaking something you made, going to a workshop and asking them to fix it for you without knowing the structure, dimensions or anything.
And if i make a bot, people joins the server to say it's bad. It took 1 month to make a bot with a lot of command and then people are saying this is my support server. I havent studied javascript, Idk how it works and if i finnaly have a working bot people gives negative reactions. Then i am completely done
with 2 months, when im developing bots, i can say i learned soooo much python. I remember when I tried to make command, that mention user, but now im making pokemon bot, that will be soon ready with duels...
this is not the channel to ask for pity
there is always haters, just ignore/kick/ban/"ok boomer" them and move on
if they dont like your bot, tell them to get another one
Or take their words as possible feedback
Also, amount of commands doesn't usually equal to the quality of the bot
People told me what is bad about it
yeah, you can ask them "what exactly is bad about it so i can improve"
But okay i will try to make a mute command by myself
most errors doesn't show whats wrong. Only where
I had once an error which i couldn't solve so i removed the code
they do show whats wrong
but you need a basic understanding of the programming language you're working on to understand it
Not everytime
for example, one of the most common errors is cant read property X of undefined
it means that you're trying to access a property of an undefined object, for example accessing object.property when object is not defined, invalid, empty, null, etc..
(in javascript)
Once i had the error: x is not a function
But i have written a function to that command but still he was saying it
that means it is not a function in the scope where it exists
And thats why i don't study coding. One letter or character wrong and the whole script doesnt work
for example, you will get that error if you try to do this ```js
runFunction();
client.on("message", message => {
function runFunction() {
// do something
}
})
because its trying to run a function that doesnt yet exist
since it will only be created at a later point
(that example is super bad by the way, just for illustration purposes)
Coding might be interesting if you like it
There's nothing wrong if you do not like it
Huh JS? I suggest python, this easier...
I like coding (only if it works)
How to do "[insert bot name] is typing..."?
It's matter of preferences
If you like coding without debugging, I'm sorry to disappoint you
most libraries have a method to send a typing presence
@earnest phoenix you send a typing event. its in the channel object
like channel.beginTyping()
or something like that
Oh ok
check the docs for it
@earnest phoenix https://discord.js.org/#/docs/main/master/class/TextChannel?scrollTo=startTyping @earnest phoenix
Thx
yeah startTyping not beginTyping lul
But is 2 pings necessary?
Does it really matter that much when you're reading the channel already
when there are multiple conversations going on, we usually use pings to tell who we are talking to
he used it twice
x mentions is still one ping per message
probably an accident lul
oh i just noticed lul
someone didn't pay enough attention and Tim wasn't the only one to do that
http://prntscr.com/pz6poj this is occuring in #commands
the channel id matches that channel
if (!serverprefix.get(message.guild.id))
var command = args.shift().toLowerCase();
if (serverprefix.get(message.guild.id))
var command = args.slice(serverprefix.get(message.guild.id).length).toLowerCase();
im trying to make it so it removes the prefix
so the command can get executed
but I can't get it to work since I am dumb
if args is an array
slice will cut a number of items from it
can you show a usage example of both situations? with and without serverprefix?
It is possible to post shards with a +1 to avoid having a shard 0
https://top.gg/api/bots/:BOT_ID/stats
Yes, but in the API the shards ids are displayed
Why would you want to change that
You'd start counting at 1 for things that end users get to access
Because they'll get confused if it starts at 0
The API is used by developers that are expecting it to start at 0
http://prntscr.com/pz7on6 the channel in this is #commands
no it isn't
you know, you have to look at the whole id, not just at the first few digits
people want to clutter as much information as they can on one page
but the point of a paginator is to split that cluttered information into multiple pages so it's easier to read
๐คทโโ๏ธ
not but like the code for a paginator
some examples are some freaking 500+ lines long
because you have to handle reactions, keep track of pages, keep track of the message
+- if you want to do checking the command executor is the one who is reacting
@earnest phoenix i'm blind, it's #265156361791209475
the one channel that gets muted that destroys my bot
should be fuxed
is there a better way to do shit like this? https://luca.is-inside.me/08DuXZkY.png
if yes, it should be able to support aliases
what language is that
that's C#
and you're using discord.net?
I'm just asking in general (this project for example isn't a discord bot), i've been looking for a better solution for bots aswell though
if C# has anything equivalent to in-memory key-value stores, and a way to loop over its keys
you can easily make a command handler
That's actually a good idea
Why when i use my bot it the clien.run() returs future.resume() and an error
Dm me for help
as this server notifs are broken
raceback (most recent call last):
File "C:/Users/dell/Desktop/CorHDI games/Yikes/main.py", line 2141, in <module>
client.loop.run_until_complete(client.start(TOKEN))
File "C:\Users\dell\AppData\Local\Programs\Python\Python36-32\lib\asyncio\base_events.py", line 466, in run_until_complete
return future.result()
File "C:\Users\dell\Yikes\lib\site-packages\discord\client.py", line 543, in start
await self.connect(reconnect=reconnect)
File "C:\Users\dell\Yikes\lib\site-packages\discord\client.py", line 457, in connect
await self._connect()
File "C:\Users\dell\Yikes\lib\site-packages\discord\client.py", line 421, in _connect
await self.ws.poll_event()
File "C:\Users\dell\Yikes\lib\site-packages\discord\gateway.py", line 469, in poll_event
await self.received_message(msg)
File "C:\Users\dell\Yikes\lib\site-packages\discord\gateway.py", line 423, in received_message
func(data)
File "C:\Users\dell\Yikes\lib\site-packages\discord\state.py", line 407, in parse_message_reaction_add
emoji = PartialEmoji.with_state(self, animated=emoji_data['animated'], id=emoji_id, name=emoji_data['name'])
KeyError: 'animated'
ok ty
I'm here with the same question xd
@thin jacinth update to latest dpy version
I read the docs but i don't understand what await means. can someone explain what that means so i can use it in my mute command?
Nop still broken
How did you update
@past pike Await is a couroutine caller
async await
You call async functions with await
Read more on async functions
@loud salmon ikr ty
okay
my mute command does still not work, i need to search further i think then
the bot still does not respond
Mute is -- Add a muted role with no speaking perms to a member
use
member.add_roles
member.add_roles(*roles)
@loud salmon I'm sorry for disturbance but what is the fastest way to update discord.py
pip install
Well how did you install it
I tried pip3 install discord and nothing changed
I swear to God
do pip install -U discord.py
okay
pip install -U discord.py worked thank you very much
Is there some stupid fucking guide that tells people to install discord instead of discord.py
Question is closed now, have a nice day
Oh well we're lucky somehow hoo ray
Shivu, dont be hard on others
hard
calm down a bit and go to #memes-and-media
With the crap I'm gonna give I'd rather keep it to myself
I'm just curious
is it people just guessing randomly or is there an actual guide encouraging to install a stupid package
who knows
@slender thistle question is closed have a nice day
finally my bot responds to my command
Got it
he gives an error but at least a respond
yay
Why do you want to mute yourself
whats on cmd_bot.js line 287?
never seen this error before
let me check
message.channel.send(:white_check_mark: <@${tomute}> has been muted for ${ms(ms(mutetime))});
this is a good oportunity for you to learn how to read errors
the first part shows you what is the actual error, and a description of it. the following lines that start with at tell you exactly where the error happens
in your case, the first error comes from the ms package, you can see its a package because its located in the node_modules folder
the second line tells you where in your actual bot file does the error happen
whenever you get an error, look for the first line where your bot file is mentioned
and look the number right after, which is the line number in the file
so then you know where the error is, and you can post the relevant code for people to help you solve it
in your case, as Vysion mentioned, the problem is most likely that you have ms(ms(something))
so try removing the extra ms
okay i will try later, now i'm gaming with friends
Is there a way to turn discord js message.member.displayColor into hex?
Nesting both ms(ms(value)) is actually valid. It convert it to as if you passed the value (ex: ->mute @Kinolite#0001 1h mean -> 3,600,000 ms -> 1h).
The problem might be what mutetime is.
message.guild.roles.create({
name: permname,
permissions: [permission.toString()]
});
this still isn't setting the name and permissions...
let me try to debug
Is there a special way to working with REALLY HUGE numbers in C
Depends on what youโre gonna use em for
@shy turret name and permissions are in the data parameter
it isnt some long thing...
i just checked
645714324815347713-276497792526974996-KICK_MEMBERS
what
ok
@quartz kindle ty fam
Whats the best way to make this work on guilds with a lot of roles
@commands.command(name="roles")
async def roles_info(self, ctx: Context) -> None:
"""Returns a list of all roles and their corresponding IDs."""
# Sort the roles by the order as shown in the client's Roles UI
roles = sorted(ctx.guild.roles, key=lambda role: role.position, reverse=True)
#roles = [role for role in roles if role.name != "@everyone"]
# Build a string
role_string = ""
for role in roles:
role_string += f"`{role.position}` - {role.mention} - `{role.id}`\n"
# Build an embed
if len(roles) < 10:
embed = discord.Embed(title="Role information", colour=Colour.blurple())
embed.add_field(name="Roles", value=role_string)
embed.set_footer(text=f"Total roles: {len(roles)}")
await ctx.send(embed=embed)
else:
await ctx.send("`" + role_string + "`")
truncate your embed
don't make the format so long
mention and position is enough
all i see is https://discord.js.org/#/docs/main/master/class/Client?scrollTo=e-roleCreate in docs
ok
done
message.guild.roles.create
ikr...
your answer is incorrect Dany
@earnest phoenix your example was one way to do it, on the docs it's more explained
@quartz kindle for v12?
And I think that was for v11, your example
You need
data: {
}
too
V11.5.1 = message.guild.roleCreate
making the role worked at least... thanks!
v11 is guild.createRole()
v12 is guild.roles.create()
but the role data has to go into options.data
not just options
createRole* yeah
message.guild.roles.create({
data:{
name: 'Super Cool People',
color: 'BLUE',
}})
yup

`permission: { [permission] }, how does something like this work...
currently reading https://discord.js.org/#/docs/main/master/class/Permissions
permissions:[permission.toString()] gonna try this
no error... didn't work
rip
what is permission?
permission.toString() = "KICK_MEMBERS"
(ofc i didnt write it like that in the code)
let me try it without the variable once
I have a question about changing my bots status to DoNotDisturb but to be honest I don't remember how because before I used normal Discord.NET api and now I'm trying to use .NET Core 3.1 but I just can't find the right command to run it
didn't work
what are you trying to do
show the full code
huge command
not even the full command
let argstart = "edit ";
let args = cmd.slice(argstart.length).split(" ");
how args are defined
not in an async function
ok
wait... im actually... blind wtf
data: {
name: permname
permissions: [permission.toString()]
},
permissions: [permission.toString()]
^^^^^^^^^^^
SyntaxError: Unexpected identifier
wait ikr
,
done fixed
Thanks! it worked
by the way, instead of checking if permission is a valid permission one by one
you can use this
ikr
i was reading a docs
i think i read it for a hour already lmao
i'm working on
focuseduser.roles.add(role).catch(console.error);
rn
Exactly
Supplied roles is not an Array or Collection of Roles or Snowflakes.
well, that sometimes happens...
well, no error again after 10000000 times restarting
i think i know why
Bruh you can just use focuseduser.roles.add("1234").catch(console.log.error);
I think
fixed
@earnest phoenix no, what i was doing was:
- create role
- find role by name
- give the role to the user
without an async function
Oh Custom Roles Command ??
which sometimes it went by too fast so it runs that find role by name first (no async)

Mmmh
- create role
- then, give role
- error, log error
Okay
im not making a custom role cmd
Okay
im making some type of discord bot that i never saw before
so im guessing im inventing it





