#development
1 messages · Page 935 of 1
still wrong
wdym?
what else can i do then, i've tried like loads of other stuff and this one seems to work
you cannot use .includes(array), thats why you use .some in combination with .includes
also, dont map and sort inside the filter function, its not actually doing anything, just adding work to your cpu for no reason
you said you have 2 arrays, what arrays are those? is the first array your guild.mod.roles? what is the second one?
why do you need that array?
how are you getting the guild.mod.roles from it?
how do you define guild.mod.roles?
do you search for roles that have admin permissions? or do you manually define them beforehand?
guild is the guild in the db, and mod is a property of it
ok so guild.mod.roles is an array of pre-defined role ids, correct?
so you dont need to get guild.roles
no, i do ```js
const g = require('guild model');
const guild = await g.findOne({ 'guild.id': message.channel.guild.id }).lean();
guild.mod.roles /* returns an array */
oh
yea
it is
whatever happened to the code i told you about yesterday and before yesterday?
guild model is that npm package?
members.filter(member => member.roles.some(role => guild.mod.roles.includes(role)))
i couldn't get it to work correctly, idk y, me being me
lets break it down
members is your guild.members from discord.js, its a collection of GuildMember objects (these are full member objects)
when you do members.filter() you give it a function that must return either true or false, if it returns false, that members is skipped, if it returns true, that member is kept. the final result is a new collection with only GuildMembers that passed the filter
i'm using eris, not d.js lol
now filter function executes once for every single member, to determine if this member passes the filter or not
eris uses collections
no, its role ids
but you'll see why you dont need anything else
.filter(member => do something with member and return true or false)
so here we use member.roles.some()
why?
member.roles is an array of role IDs in eris
.filter(member => do something with member and return true or false) returns an array, a collection
and .some() iterates over an array, and returns true or false if a condition is met
collection.filter() returns a new collection
as i said above
but member.roles is not a collection, its an array
so when you do member.roles.some() you're gonna check each role of this member against a condition, and if the condition passes, it returns true and if it returns true this member has passed the filter
so roles.some(role => here is a role id. we want to check if this id exists in guild.mod.roles)
so we use guild.mod.roles.includes(role)
ok, so would i do, ```js
let role = message.channel.guild.members.filter(member => member.roles.some(role => guild.mod.roles.includes(role))).map((e) => e.roles);
guild.mod.roles.includes(role)
wait
idfk
so confused
i need help. bot widget on my website shows undefined instead of servers amount (sry for bad english)
this is a collection of members that have one of the roles
now what do you want to do with those members?
map them?
map them to what? what do you want out of them?
their roles
why do you want their roles?
to check if their roles include that, then say that persons a mod
you already checked
if it does
this is ok?
let rol = member.guild.roles.filter(x => x.name === 'Muted').sort((a, b) => a.position - b.position).first();
member.roles.includes(rol)
but why do you want to map them into their roles?
you already have a collection of members who are mods, you already know if they are mods or not
is for, "The mentioned is already muted"
OH
let role = message.channel.guild.members.filter(member => member.roles.some(role => guild.mod.roles.includes(role))).map((e) => e.mention);
yes, that will map them into their mentions and give you an array of mentions of mods
so you understand what the code is doing? for each member, check each of its roles, and for each of its roles check if the role is a mod role
if mod.roles includes the role, the role is a mod role, and if one of the roles is a mod role .some() returns true, and if .some() returns true, the member passes the .filter()
I was wondering, if you use __dirname on a parent, and the child who inherits the class, will it get the child's directory, or the parent's?
@earnest phoenix that is redundant, unless you have multiple Muted roles
if you only have one Muted role, just do let muted = member.roles.find(x => x.name === "Muted")
👍
let rol = member.roles.find(x => x.name === "Muted")
member.roles.includes(rol)```
? @quartz kindle
?
yes you can do that
no need to sort
but i can?
ok
if( member.roles.find(x => x.name === "Muted"))
@earnest phoenix this work with the event memberGuildRemove?
if the member is cached, yes it should work
https://hasteb.in/fedasali.js
(node:2338) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
how do i make a bot leave a specific guild?
<client>.guilds.get('id').leave()
can I add that in the ready event?
wdym?
im using discord.js version 12.2.0
https://hastebin.com/unezocovip.cs
gives no error it says i dont have permission to use it but my id is in there
@iron scroll how are you loading your commands?
@hardy vector which line?
bruh
@iron scroll you are not setting the aliases
https://hasteb.in/atazexef.coffeescript ful error
@quartz kindle need yall help
can someone help me
const filter = m => m.author.id === message.author.id;
let embed = new Discord.RichEmbed()
.setColor(color.purple_light)
.setTitle("Question here")
.addField("Answer A: ", "Some text")
.addField("Answer B: ", "Some text")
.addField("Answer C: ", "Some text")
.addField("Answer D: ", "Some text")
message.channel.send("hello", embed)
message.channel.awaitMessages(filter, {max:1, time: 10000, errors: ['time']}).then(collected => {
console.log(collected.first())
}).catch(err => {
console.log(err);
});
When i console.log() it says undifined
ahm . . .
@clever garnet .includes(whitelist) not .includes.whitelist
d.js
ok
also, its the other way arround
?
me ?
whitelist.includes(id) not id.includes(whitelist)
oh
so why did you say .includes(whitelist)
because you were using .includes.something
which is invalid
so first i said how to use the includes function properly
@hardy vector which line?
@quartz kindle https://hasteb.in/atazexef.coffeescript ful error
then i noticed your order was incorrect
k testing rn
@earnest phoenix collected.first() returns undefined? what version of djs?
v11
@quartz kindle theres a new error
TypeError: Cannot read property 'includes' of undefined
Has anyone else noticed the glitch where a different member will be pinged on a very rare occasion
i thought they fixed that
Apparently not
Dank memer, my bot, and multiple others have been having that problem lately, I've noticed
At first I thought it was something I screwed up, but then dank memer did it
@clever garnet what did you write?
if(message.author.whitelistforannounce.includes(id)){
message.delete();
announcementwebhook.send(embedforaccept);
}
if(!message.author.id.includes(whitelistforannounce)){
message.channel.send(embedforfail)
}
@hardy vector sorry, cant find anything wrong. console.log m.author and message.author in your filter, you might be getting something weird from somewhere
@clever garnet you still have id.includes()
and you're still doing it wrong
ok
oh ok
whitelist.includes(id)
what is whitelist and where does whitelist come from? whitelist is the array you defined: whitelistforannounce
what is id and where does id come from? id is the id that you get from message.author.id
read what i said
I think discord is broken again
not the right channel
if if id is message.author.id
and whitelist is whitelistforannounce
then whitelist.includes(id) is xxxxxxxxxx
find the xxxxxxx
I just do if(this.client.config.whitelist.includes(message.author.id))
wtf
Define your config.js at the beginning of your file, and change whitelist to whatever your arrays name is
?
that answer is out of context
Hes trying to confirm that the author ID is contained inside the whitelist correct?
yes, but dont tell him to rewrite his entire code into your preferred style, give him an answer that fits his current code
while trying not to spoonfeed
let rol = member.roles.find(x => x.name === "Muted")
member.addRole(rol)
why this dont work?
Ye, I was recommending that because if he ever wants to reuse the whitelist, then he can use it anywhere, unless hes doing a index only bot
(node:1369) UnhandledPromiseRejectionWarning: TypeError: Supplied parameter was neither a Role nor a Snowflake.
Have you defined member?
member is for guildMemberAdd
is member.user.addRole(rol) ?
member works if that in inside guildMemberadd event
i know
client.on('guildMemberAdd', async (member) => {
if (member.user.bot) return;
let count = await entrada.obtener(member.guild.id);
if(!count) return;
let rol = member.roles.find(x => x.name === "Muted")
You need the role search inside the guild, not the members roles
member.guild.roles.find(x => x.name="Muted") ?
will work
Ye, if you want to find a role, unless the member has it already it will return false
@earnest phoenix yeah i want to be able to reuse the whitelist
Are you making a bot with separated command files?
no
So one that it is all housed inside index.js?
yes
Ok
after im done then ill make a command handler
You can just define whitelist inside the index if you dont plan on extending it to the command handler
How do you have whitelist defined?
wdym
Do you have the whitelist contained inside an array?
So,
"Value 1",
"Value 2"
],
yeah like
const whitelistpeoplexd = [id1, id2, id3]
like that
Ok, do you have the ids quoted?
ill do that
you need to define the whitelist outside of your event handles, for example at the top of your index file
that way it can be accessed by all events
hey, im attemting to get a global chat into my bot but when anyone types in it, it repeats. i do have bot protection on
if you define it inside an event, it will only exist inside that event
thats what im doing
k testing
TypeError: Cannot read property 'includes' of undefined
lemme find the line
TypeError: Cannot read property 'includes' of undefined
heres the code in that line
if(message.author.whitelistpeoplexd.includes(id)){
testing
You can't use message.author.includes(), that will result in a TypeError every time, you need to make the arrayName.includes()
why am i getting this error
(node:106) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
at /home/container/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
at /home/container/node_modules/snekfetch/src/index.js:215:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:106) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:106) [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.
discord.js v11.5.1
empty message iirc
But unless we know the event that caused it we can't help, sorry
i forgot the ! in the second part so it gave me the error and the sucsess embed lol alr imma test it now
im trying to run a global chat
global chat ? wdym?
chat accross servers
Is it an opt in?
yeah
uhhhh
@earnest phoenix
message.delete();
announcementwebhook.send(embedforaccept);
}
if(!whitelistpeoplexd.includes(message.author.id)){
message.channel.send(embedforfail)
}```
it gives me the error message but it still works
find channel and fetch messages in it
What are you trying to do with this?
me?
Ye
i have an announce command and it will send a webhook in an announcement channel this is just for a spefific server
Ah
Send me an invite to your testing server please, I want to see what youre doing when the error message pops up
i dont have a testing server i just test it in a private channel that i made
Ah
what r u doin 4 it 2 error?
Try moving the if(! Above the success, and put a return in front of message.channel.send
if(!whitelistpeoplexd.includes(message.author.id)){
return message.channel.send(embedforfail);
}
if(whitelistpeoplexd.includes(message.author.id)){
message.delete();
announcementwebhook.send(embedforaccept);
}
Can you send a screenshot of the channel you're testing in?
it sends the announcement in a different channel
Kk
Ah
i could change the webhook to the testing channel for a moment if u like
Are you the only person In the whitelist array?
no theres multiple i added the hrs to the whitelist
ok
@quartz kindle Are you able to help him, I can't help rn, got to go into work
show your full code
for the event or the entire code
for the event
//announcement
bot.on('message', message=>{
const announcementwebhook = new Discord.WebhookClient('712005281327874179', 'LF1cIM5EYNwqk04qa0aUXozEFSeg3s2o6stGlNEb9RHwrOAAdKoaiBraTiVvUWkv5dWx');
const announcementwebhooktext = message.content.split(" ").slice(1).join(" ");
const embedforaccept = new Discord.MessageEmbed().setDescription(announcementwebhooktext).setFooter(Sent from ${message.author.username})
const embedforfail = new Discord.MessageEmbed().setTitle('Missing permissions').setColor('#F04947').setDescription('You are not on the whitelist to execute this command.').setFooter('If you think you should be on the whitelits DM Qu1ckIy#5965')
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]){
case 'announcement':
if(!whitelistpeoplexd.includes(message.author.id)){
return message.channel.send(embedforfail);
}
if(whitelistpeoplexd.includes(message.author.id)){
message.delete();
announcementwebhook.send(embedforaccept);
}
}})
You can use ```
oh good idea
bot.on('message', message=>{
const announcementwebhook = new Discord.WebhookClient('712005281327874179', 'LF1cIM5EYNwqk04qa0aUXozEFSeg3s2o6stGlNEb9RHwrOAAdKoaiBraTiVvUWkv5dWx');
const announcementwebhooktext = message.content.split(" ").slice(1).join(" ");
const embedforaccept = new Discord.MessageEmbed().setDescription(announcementwebhooktext).setFooter(`Sent from ${message.author.username}`)
const embedforfail = new Discord.MessageEmbed().setTitle('Missing permissions').setColor('#F04947').setDescription('You are not on the whitelist to execute this command.').setFooter('If you think you should be on the whitelits DM Qu1ckIy#5965')
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]){
case 'announcement':
if(!whitelistpeoplexd.includes(message.author.id)){
return message.channel.send(embedforfail);
}
if(whitelistpeoplexd.includes(message.author.id)){
message.delete();
announcementwebhook.send(embedforaccept);
}
}})
How can I do this with my music bot?
so you said that it still sends the webhook even if it fails?
i dont see how that could happen, but why dont you start with reorganizing your code in a way that makes more sense
first of all, check the command
prioritize the correct things to improve performance and efficiency
for example
if(message.author.bot) return
let args = message.content.slice(prefix.length).split(" ");
if(args[0] === "announcement") {
if(whitelist.includes(message.author.id)) {
let webhook = new Discord.WebhookClient(...)
let embed = new MessageEmbed()
webhook.send(embed)
}
}
hello, i can't add color my bot name on my bot's page
How do i program a music bot? @-@
because the way your code is now, you are creating new webhook clients, and new embeds on every single message
because you create first and check later
thats a huge waste of cpu
you should always check the conditions first, and only create if all conditions are right
???
wwho
jake
so you have no experience with programming? never programmed in your life?
no
search it up on yt i suggest watching the starter thing by codelyon to start understanding then read the docs
so you should start by learning a programming language
for example, javascript, python, c#, java
@-@
pick one of those, and look into online courses and guides
you need to know basic programming before starting a bot
im still confused but okay.....
ik that
you can have emotes in your role names
but i dont think you can have custom emojis
not afaik
wot
bruh
If possible, how can I do this with my music bot? Please, help me. [discord.js]
deafan your bot?
how i do that?
https://gyazo.com/52ca7ad55629be2ec1b886a6c496f0ec
1s cooldown
channel settings
that would be an #topgg-api question
channel settings
@earnest phoenix https://gyazo.com/ae48c7f4249674974762037ee9183f74
yes that
i want 1s not 5s
deafan your bot?
@earnest phoenix I meant to make sure that when it connects to a voice channel, my bot has mutated audio input.
Why does not work
@earnest phoenix
in the data object you pass you can pick however many seconds you want
@balmy knoll so you want to mute the bot when it joins the voice channel?
message.channel.setRateLimitPerUser(1000)
.then(algo => console.log("spanish here xd"))
.catch(console.error);
@earnest phoenix
@earnest phoenix I'm not sure how to explain it to you, but maybe this command (.setSelfDeaf(deaf)) is the one for me. Isn't it?
well, it will show the icon, which i guess is what he wants
oh btw I wanted to delete a role if the bot left a server
but i got this error DiscordAPIError: Missing Access
you want to delete a role when your bot leaves a server?
ye
in the server it leaves?
but if you leave the server, how are you gonna delete the role?

lmao
You cant do that in theory.
tim is too smart
@quartz kindle thx u
how do i make my bot like slice a mention off
like i have a command like $inv <args> @user but doing .content.slice includes the user mention
have you tried just taking the user as a first argument

@quartz kindle @earnest phoenix TypeError: client.setSelfDeaf is not a function Why do i get this error?
oh
@balmy knoll what did you wrote?
you said you wrote the function right?
client.setSelfDeaf(); this is supposed to self-defean the bot?
wrong context i think, client does not include setSelfDeaf
voice.setSelfDeaf(true) when the bot joins a voice channel ?
well there is
if voice represents your voicestate then yeah
Ok i try
@earnest phoenix i said client does not includes setSelfDeaf, we were not talking about voicestate
i never said it was from client lol
so why did you send it in here saying "well there is"?
yeah but that was never out of question
All works thanks
np
In CSS, why does justify-content: center get ignored if I use flex-direction: column; in a flexbox?
maybe no free space? i dont have any code in front of me
do you want to center vertically or horizontally?
Horizontally
I want columns to be in the center of the page, if that's what you mean
use align-items instead
justify-content applies to the main axis, when you use column, the main axis becomes vertical instead of horizontal
which causes justify-content to apply vertical centering instead
Oh
align-items works on the cross-axis, vertical if row, horizontal if column
took me a while to understand that too
yes
can bots set users status?
like the custom status
no
bots can have activity
but they can't have custom status
if you're asking if bots can set someone else's status
also no
ok
get the channel
send the message
browse the docs to see an example
get doesn't take a prop name
just the id
since it's a collection and you're getting by key
is there a better way to get to work a music bot without google api key?
use something that scrapes youtube
e.g. youtube-dl
not like the actual string "id"
just the numeric id
i keep forgetting js has 53bit ints and it's infuriating
Is there a way to log the server name in the console (for some reason console.log(msg.guild.name) doesn't work)
.cache.get() takes a string.
shouldnt it be fetch?
and are you sure the channel will always exist
hi, with d.py, how can i get the clients uptime?
i've checked the docs but idk if i'm missing it or
https://discordpy.readthedocs.io/en/latest/api.html#client is where i'm looking at
it's a thing you implement yourself
Right after creating the client/bot object, create a property uptime (or whatever you want), value of which will be the either timestamp or datetime object
ah, ok. ty!

Someone asked me what they can do to fix an API Error...
let unbanMember = i know this is a nooby question but how would i get a bannedMember's id?
i've tried fetching but random errors like 404
i just want an alternative
does anyone know if digital ocean has student deals
ikr
im going to apply for it but im going to ask my teacher first before i apply bc they require you to submit your school schedule or ID
i just submitted my school email and got accepted almost instantly
What is a config.json file used for in d.js
configs
ok ty
You get alot of free shit with Github student tho i doubt many use most of it
I dont use any of the hosting stuff but i make use of the free git kraken pro, sql stuff and some others
and quite a few ask for a credit card
i dont wanna put my credit card into sites even if it says it will charge nothing thank you
whats a good cooldown time in miliseconds
what
Can home educators get student passes on github (asking for a friend)
no
you need to be enrolled in an official school and only students are eligible for the pack
ok
for teachers see https://education.github.com/teachers
for having a command cooldown you use timeout
mines 750 and its like it dosent exist
is there a pass for uni students and home eders
go look at their site
for having a command cooldown you use timeout
@astral yoke cause 750 is pretty much nothing in MS 1000 = 1s
there is no "good cooldown"
it all depends on your command influx, what you're doing in the command etc
If an error is occuring within a module (meaning my catch block doesn't catch anything) how should I handle it?
^
there are too many variables for there to be a "good cooldown"
@true ravine how are you using this module? does it return a promise?
Yeah it does
how are you catching the promise?
imgdim = sizeOf('test.png').then(dimensions => {
console.log(dimensions.width)
console.log(dimensions.height)
if(dimensions.width<1){
reject(err);
}else{
resolve(true)
}
}).catch(err=>{
reject(err)
})
at RequestHandler.execute (/rbd/pnpm-volume/0edd064e-b617-4b7c-bbcb-437d7187c37d/node_modules/.registry.npmjs.org/discord.js/12.2.0/node_modules/discord.js/src/rest/RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
(node:3346) 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: 1)
(node:3346) [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.```
can someone fix this for me https://hastebin.com/huceqefetu.py
docs say nothing
yt tutorial is outdated
version for rewrite was never uploaded to youtube
@true ravine is that code inside another promise?
Yeah it is
show the full promise
Was there ever an official tutorial for ytdl in Python, though?
async function downloadImage(url) {
return new Promise((resolve, reject) => {
const writer = fs.createWriteStream("test.png");
axios(url,{responseType: 'stream'}).then(response => {
response.data.pipe(writer);
let error = null;
writer.on('error', err => {
error = err;
writer.close();
reject(err);
});
writer.on('close', () => {
if (!error) {
imgdim = sizeOf('test.png').then(dimensions => {
console.log(dimensions.width)
console.log(dimensions.height)
if(dimensions.width<1){
reject(err);
}else{
resolve(true)
}
}).catch(err=>{
reject(err)
})
}
});
});
});
}
and where does the error happen? in sizeOf() ?
Yeah, and it says unhandled promise rejection there
and how are you using downloadImage()? do you catch it as well?
No I'm just awaiting it
anyone know why the code
client.on("message", (message) => {
let args = message.content.substring(prefix.length).split(" ");
switch (args[0]) {
case "uptime":
message.channel.send("I have been online for") + client.uptime + "!";
break;
}
});
comes out as:
You have some stray brackets
hey so anyone here who knows python?
where are the stray brackets?
cause i have a discord.py issue
@true ravine you're defining imgdim as a global variable?
Would that affect it?
your code could be done in a better way, but other than that it looks fine. if the promise rejects, you need to catch the rejection in downloadImage()
anyone have any idea what this error is caused by? ERROR: DiscordAPIError: Missing Access
https://discordapp.com/developers/docs/topics/opcodes-and-status-codes doesn't provide much information about this but i could be blind
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
the error stack doesn't even mention the line that invoked this error
so either try{ await downloadImage() } catch() {}
or await downloadImage().catch(() => {})
Oh okay thank you
I was trying to reduce callback hell as much as possible because I need to collect the result of multiple of that function run in a loop
if you want to reduce it further, you can use async/await in sizeOf
also, no need for the function to be async, since you're returning a promise, which makes the returned value a promise by default. just make the promise itself async
anyways ill just share my problem
Oh okay thanks ^
im trying to page a help class
anyone have any idea what this error is caused by?
ERROR: DiscordAPIError: Missing Accesshttps://discordapp.com/developers/docs/topics/opcodes-and-status-codes doesn't provide much information about this but i could be blind
@steel drum bot is most likely missing access to the channel it is trying to send messages to that's usually what's wrong when I get this error
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
but i always get the error that 'channel has no bot attribute'
ctx = self.get_destination()
embed = discord.Embed(title='The Abilities of Jarvis the Bot', colour=0x0000ff)
description = self.context.bot.description
embed.set_thumbnail(url='https://cdn.discordapp.com/attachments/706546902446899250/712095658324262922/4mgj2eykdi.png')
if description:
embed.description = description
for cog, commands in mapping.items():
name = '**__Miscellaneous__**' if cog is None else f'**__{cog.qualified_name}__**'
filtered = await self.filter_commands(commands, sort=True)
if filtered:
value = ' | '.join(c.name for c in commands)
if cog and cog.description:
value = '{0}\n{1}'.format(cog.description, value)
embed.add_field(name=name, value=value, inline=False)
await ctx.send(embed=embed)```
heres one example
i dont have the paging part in this
@hoary elm can you show us the code?
@hoary elm i have my bot explicitly ignore channels that it doesn't have SEND_MESSAGES in but ill test it around further, thanks!
you can also use async/await in axios
oh lol misread, sorry 
Lol all good
helium.on("message", async(msg) => {
let chatmoderators = ['539195184357965833', '550170362248429568', '437019658374348801', '641795527444529152']
if (msg.author.bot)return;
if(msg.channel.name !== 'helium-global-chat')return;
msg.delete()
let e = new Discord.RichEmbed()
.setTitle("Helium Global Chat")
.setAuthor(msg.guild.name, msg.guild.iconURL)
.addField("Message content", msg.content)
.setColor("RANDOM")
.setThumbnail(msg.author.avatarURL)
.setTimestamp()
.setFooter(`Helium Global Chat System || SECURITY | Guild id: ${msg.guild.id} | msg author id: ${msg.author.id} | code by Airbus A350-1000#0001. thanks to him, this bot will have a functioning global chat.`);
if(chatmoderators.includes(msg.author.id)){
e.addField("Sent By", `🛠️ Chat Moderator | **__${msg.author.tag}__**`)
}else{
e.addField("Sent By", `**__${msg.author.tag}__**`)
}
await Promise.all(helium.channels.filter(c => c.name === 'helium-global-chat').map(c => c.send(e)))
await Promise.all(helium.channels.filter(c => c.name === 'helium-global-chat').map(c => c.setTopic(`Last message is sent by <@${msg.author.id}>`)))
gcauthor = msg.author.tag
gcauthorid = msg.author.id
gccontent = msg.content
})
error is
(node:194) UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Message
at /home/container/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15
at /home/container/node_modules/snekfetch/src/index.js:215:21
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:194) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:194) [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.
discord.js v11.5.1
did you read error message?
@silent berry i don't think that error throws because of that event
Hi im trying to set a custom background to my top.gg bot page
but this in css its not working
body {
background-image: "blob:https://imgur.com/f57af399-73d7-4b01-8b2d-1ff93b346691" !important;
}```
but if i replace the image with a color it works fine
```css
body {
background-color: #102030 !important;
}```
@wheat jolt that error only comes up when typed in global chat
that url isn't good
then it repeats the said msg over and over
blobs aren't actually urls
Still doesnt work
url()
^
Nice it works, thaks a lot guys!!
np
holy shit github developer pack gives you so much
aws credit, azure, digital ocean
damn
courses
and more
im applying
The only thing I have from the pack are the IDEs from JetBrains
dude use everything else lol
too much work
student dev pack?
then yes
like a lot
no shit
i used the domains, nothing else is really great for me
github studetn pack is great
someone mak me a music command because nothing works
https://hastebin.com/amuquxuteb.py
what does not work about it
i try searching for stuff to tell me how to do it in the rewrite and its really stupid
text is too tiny, literally no mic and has a download that you have to pay for to get the code
really stupid shit
then you don't know how to do research which is a you problem ™️
Why are you searching on YT
im trying to get make a snipe command js client.snipes = new Map() client.snipes.set(message.channel.id,{ content: message.content, author: message.author, }) if(message.content.startsWith(prefix + 'snipe')){ const msg = client.snipes.get(message.channel.id) if(!msg) return message.reply('No recently deleted messages') message.channel.send( new Discord.MessageEmbed() .setAuthor(`Message deleted by ${msg.author.tag}`, msg.author.displayAvatarURL()) .setDescription(msg.content) ) } it should grab the last deleted message but it grabs the last message not the last deleted message
are you declaring that in your message create event
wdym
so basically, I'm trying to get my stop command to end my queue, but when I stop It, I get "serverQueue.connection.dispatcher.destroy is not a function"
the code is serverQueue.songs = []; serverQueue.connection.dispatcher.destroy('Stop Command Used') const successfullystopped = new Discord.MessageEmbed() .setColor('#58eb34') .setTitle(' Successfully Stopped and left Voice Channel') return message.channel.send(successfullystopped) } }
V12?
yes
and serverQueue is defined as queue.get(message.guild.id)
@slender thistle not searching on yt google is just a shitty company with a shitty search engine
anyone think they could help me with my snipe command
just post your question
I mean it's the only reliable source in terms of being up-to-date
ah right
sorry
anyways i was going to ask how to add two pages to the same class
i.e:
async def format_page(self, menu, page, list2):
embed = discord.Embed(title='Example', colour=0x7f03f1, description=page)
embed.add_field(name=''.join(value for value in list2), value='', inline=False)
return embed```
im sure you understand what i mean
Unable to import 'alpha.exceptions'pylint(import-error) why is it giving me this random error lol
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x00000164073EE040>``` guys help
@lime cypress i dont think u can execute commands here
lol
ye
nice py or js
js
nice
(node:30904) 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().
To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 33)
(node:30904) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message``` anyone know why i keep getting this
.then() or await
i honestly wish it could show me where the error is occuring
@earnest phoenix the bottom says DiscordAPIError: Cannot send an empty message
i see that
the bottom part still does not answer the problem https://canary.discordapp.com/channels/264445053596991498/272764566411149314/712454711466262561
or, it says there is a problem, but not where
literally spamming my terminal
I mean it can with some flags but you may be passing an empty string or object without the correct key/values
hey
ctx = await super().get_context(message, cls=cls)
i get error with get context
anyone got idea why?
what's the error
File "c:\Users\Jassm\Desktop\Alpha\alpha\client.py", line 87, in get_context
ctx = await super().get_context(message, cls=cls)
File "C:\Python38\lib\site-packages\discord\ext\commands\bot.py", line 865, in get_context
raise TypeError("Iterable command_prefix or list returned from get_prefix must "
TypeError: Iterable command_prefix or list returned from get_prefix must contain only strings, not dict```
so okay i got rid of super()
and now i get this error
ctx = await get_context(message, cls=cls)
NameError: name 'get_context' is not defined```
@sudden geyser ??
How long does it even take bot verifing?
my bot crashes everytime my computer goes to sleep
obviously it wwould
says something about networking
is there a way to stop that without preventing the computer from sleeping?
because when your computer sleeps its network turns off
usually when computer goes to sleep majority of stuf gets closed
to prevent battery drain
@astral yoke like bot
Are you using your computer as the actual host or just for local development.
me?
no
Me?
and kino u got answer for my situation thing
NameError: name 'get_context' is not defined
This is self-explanatory.get_contextis not a variable. I also don't know whatsuper()refers to as in what it's an instance of + I have little knowledge on Python.
oh k ig ill figure it out myself
say i have a number like 13221323912838 how do i crop 9 digits off the end of that?
@hardy vector was the command used in a guild.
When i receive a shard's ready event discord.js, can i assume that all guilds (not the members, only the guild list) has been cached completely?
I get an error when I transfer the files in Glitch to VDS. How can I transfer the modules?
sup guys, i'm working with sequelize and i keep getting this error:```
UnhandledPromiseRejectionWarning: Error: WHERE parameter "user_id" has invalid "undefined" value
at SQLiteQueryGenerator.whereItemQuery (/Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2184:13)
at /Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2173:25
at Array.forEach (<anonymous>)
at SQLiteQueryGenerator.whereItemsQuery (/Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2171:35)
at SQLiteQueryGenerator.getWhereConditions (/Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2583:19)
at SQLiteQueryGenerator.selectQuery (/Users/daydream/Developer/ava/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1315:28)
at QueryInterface.select (/Users/daydream/Developer/ava/node_modules/sequelize/lib/query-interface.js:1122:27)
at /Users/daydream/Developer/ava/node_modules/sequelize/lib/model.js:1757:34...
just for context, this is the code that is having the actual issue: ```js
const target = msg.mentions.members.first() || msg.member
const user = await Users.findOne({ where: { user_id: target.id } }).catch(err => { console.error(chalk.red("[Ava][Error]"), err)})
const items = await user.getItems()
how to get ping in discordjs v12 they removed client.ping
msg.guild.shard.ping?
oh
Cannot connect to host discordapp.com certificate verify failed
help
will literally paypal someone $5 if they help in getting my bot back up lool
How can i get this badge please answer?
@eternal gazelle, https://support.discord.com/hc/en-us/articles/360040720412-Bot-Verification-and-Data-Whitelisting
okay ty
@halcyon ember client.ws.ping
oh
When i receive a shard's ready event discord.js, can i assume that all guilds have been cached at least so far, that they appear in the guilds.cache collection? How about guildmembers?
Members are never all cached at startup unless you specify so in the client options
But afaik guilds are always cached
thx
i kno how to broadcast info from the manager to the shards. can i also send info from the shard to the manager, without using something external like ipc?
Wdym send info
hey so just one question about dpy
in a help class, how do i have the help command be guild only
i tried using guild_only in command_attrs, but i couldnt get it to work
br e um bando de macaco
@smoky spire So i can redirect db queries to the manager, who holds a connection pool. So i dont have to close clonnections all the time / keep a connection per shard
Would this work for you https://discord.js.org/#/docs/main/stable/class/Shard?scrollTo=eval
@viral spade
nvm i just set up an is instance
maybe. but with this, how can i trigger a function in the code/process my shardingmanager is in?
hmm the last one looks promising
so after sending, how can i set up the"onMessage" event in the master to process the message?
ye i saw this, but then again this is a Shard not the ShardingManager
ShardingManager#shards
So i have to set the event for each shard separately?
ig idrk
well thanks anyways you helped me a lot
File "c:\Users\Jassm\Desktop\Alpha\alpha\client.py", line 87, in get_context
ctx = await self.get_context(message, cls=cls)
File "c:\Users\Jassm\Desktop\Alpha\alpha\client.py", line 87, in get_context
ctx = await self.get_context(message, cls=cls)
File "c:\Users\Jassm\Desktop\Alpha\alpha\client.py", line 87, in get_context
ctx = await self.get_context(message, cls=cls)
[Previous line repeated 984 more times]
RecursionError: maximum recursion depth exceeded```
help
Stackoverflow
k wait up
self, message: discord.Message, *, cls=commands.Context
) -> commands.Context:
ctx = await super().get_context(message, cls=cls)
if ctx.command:
ctx._ = functools.partial(
cog=ctx.command.cog_name,
)
return ctx``` @turbid bough
TypeError: Iterable command_prefix or list returned from get_prefix must contain only strings, not dict thats the error now
How would I make a warn command with quick.db? I know the database code like db.get db.set db.fetch but how would you make it so it would make multiples instead of just going on top of the first one for a warn command that shows the persons warns?
for 11.6.1
if cashBal and addedCash are both numbers shouldn't it add it together? right now it just puts it like cashBalladdedCash instead of actually adding the 2 numbers together...const newCash = cashBal + addedcash; it works on another command...
so say if both are 1 it puts it as 11 and not 2
it works if one of them is an actual number...
nvm it started working randomly 🤷♂️
use parseInt()
nope...not how I fixed it
My bot's offline, but I can't figure out why. I'm not getting any console errors.
Did you turn it on
@smoky spire Yes, at the moment, it is on glitch
lol
Glitch isn't a 24/7 host, it goes down regularly
you can use uptimerobot to host 24/7
or actually get a proper host
@torn nebula Yes i use uptimerobot to ping the code every 5 minutes, but the bot is always offline
does uptime robot say its offline
if you type in refresh in the console?
Nothing happens
@honest perch https://zws.im/
you have been ratelimited
@honest perch So what am I supposed to do?
you're supposed to read
just give your question, no need to have permission to ask
oh thx
It's a noob's problem sry °-°" : I would like to add an object in a json file (data of my bot).
But my code actually overwrite my existing code (sry again for bad english).
Here my code ^^ : ```js
const fs = require('fs');
let rawdata = fs.readFileSync('data.json');
let dataBot = JSON.parse(rawdata);
console.log(dataBot);
let newserver = {
name: "Server's name",
serverbotprefix: "!",
cmdchannel: '(ex)645644648984796489964',
langage: 'English',
};
let data = JSON.stringify(newserver, null, 2);
fs.writeFileSync('data.json', data);
Thx for helping ^^
ow, it's a friend said to use a json file
then your friend is an idiot
no
oh
i mean, nothing wrong using json, but json has a lot of problems you will need to develop solutions for, while proper databases already do it for you
if you want to keep using json, the reason your code is not working is that json can only be processed the entire file at a time, so you need to read the entire file, change the entire file and save the entire file.
otherwise try learning how to use a database like SQLite
thx I'll learn how it's work ^-^
Why can't i install the heroku package on my project?
npm ERR! path /app/node_modules/tar/node_modules/.bin/mkdirp
npm ERR! code EEXIST
npm ERR! Refusing to delete /app/node_modules/tar/node_modules/.bin/mkdirp: ../../../../../../mkdirp/1.0.4/node_modules/mkdirp/bin/cmd.js symlink target is not controlled by npm /app/node_modules/tar/node_modules/mkdirp
npm ERR! File exists: /app/node_modules/tar/node_modules/.bin/mkdirp
npm ERR! Move it away, and try again.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npm-cache/12.0.0/_logs/2020-05-20T09_48_07_160Z-debug.log
what package? what are you trying to install?
@quartz kindle npm i heroku
or what?
is your bot in heroku?
hosted in heroku?
it exists
How to get existing express app from dblapi.js
@quartz kindle Now i try to export my project form Glitch to GitHub, then i try to host the project with heroku
@earnest phoenix webhookServer: server
where server is your express.js server instance
in your dblapi.js webhook options, there is a webhookServer option
if you're trying to add an existing server to dblapi
okie i will see documentation
@balmy knoll is there a reason you want to install the heroku package? you dont need it
did you just post your token
@balmy knoll If that token is valid, please regenerate it immediately
@slender thistle My error in paste the token
Sorry
@quartz kindle I wanted to install heroku directly on glitch without going through github. But I can't install heroku on glitch.
thats not how it works
Hello guys, I want to make a game that can PvP, but I don't know to build a matchmaking, can someone help me? I'm using discord.py
heroku is a hosting service, a competitor of glitch
the heroku package is simply a tool to communicate with the heroku server
it doesnt do anything else
if you want to move to heroku, you need to create a heroku account and project, and upload your bot there
remove webhookPort since webhookServer replaces it
k
express doesnt start automatically
then do this
const server = app.listen(process.env.PORT)
....
webhookServer: server
Does anyone using discord.py here?
Error: FFmpeg/avconv not found! How can i fix this error? If i host on Glitch, i haven't any error, while on heroku, i get this error
Go to settings and then add buildpacks
And add this link 'https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git'
Should work
Hello, I forgot to add some administrative commands to the bot, can I work on the bot because I added it to a top.gg
You can
of course you can
Okay thanks
the emote is flashy
this is goed?
👍

@haughty night I try | Edit: All work, thanks
Np
.addField("Nickname", `${target.nickname !== null ? `${target.nickname}` : " None"}`, true)
why at nickname it says undefined?
because it's undefined?
in v11 it worked :/
u in v12 then?
yes
you should do !target.nickname ?
hey 🙂
just do target.nickname || "None"
^
ok
and one more thing
const verlvl = {
0: "None",
1: "Low",
2: "Medium",
3: "Hard",
4: "Epic"
}
.addField("Nivel Securitate", verlvl[message.guild.verificationLevel], true)
at security level it says undefined aswell
np
@earnest phoenix did u sort out the nickname?
@zenith terrace yes
alright
funny cause I have
.addField("Nickname", `${member.nickname !== null ? `Nickname: ${member.nickname}` : + "None"}`, true) and it works fine lol
.addField("Nickname", `${target.nickname !== null ? `${target.nickname}` : " None"}`, true)
Oh you didnt have the + after the : thats why lol
Hello I'm looking for someone who could help me? Dm me
what do you need help with?
I'm looking for code to learn because I'm starting
don't ask to ask - just ask your question
just google language_name course
Ok thank you I'll try
i'd personally recommend codecademy if you're willing to spend a few bucks or your school has a partnership with them
No thanks I'm already paying for my minecraft server
At the moment I entered my project on github and then I host it with Heroku. The problem is mainly one: restarting heroku or updating the code, the json files in which save some data are reset. How can I fix it? Maybe save the contents of the json file before making changes?
don't use heroku or glitch
heroku has ephemeral filesystem
it'll reset every time the dyno restart
if you have no other option, use a remote database
otherwise don't use heroku or glitch
@pale vessel Remote database like?
mysql postgres

I'm really a noob in code I would like to know if you know and mp me so I learn please
no one is going to teach you for free
Ha damage
see youtube
huh?
no
or google
Ps: I'm on Android
youtube is not an option
I don't have a computer.
thats sad
uh, if you want to do anything related to CS (programming etc.) you need some form of a pc
Ha it's problematic
indeed it is
phones cannot be used as development machines
Yes I suspected it
firstly because they're too weak, and second because ARM
Yes indeed
@earnest phoenix actually, it could work like this:
const verlvl = {
"None": 0,
"Low": 1,
"Medium": 2,
"Hard": 3,
"Epic": 4
}```
oh wait, nvm
firstly because they're too weak, and second because ARM
@earnest phoenix arm
How do i get channel youtube name using ytdl-core?
check the author field
[object object]
if you're sending it as a message, you need to serialize it
JSON.stringify(video.author)
and second because ARM
What makes ARM contribute to not being able to develop on mobile?
bUser.hasPermission is not a function
code:
let bUser = message.mentions.users.first();
if(!bUser.hasPermission("MANAGE_MESSAGES")) return message.channel.send(":no_entry_sign: **Nu pot bana un moderator!**");
bUser is an instance of User. You're looking for an instance of GuildMember
If you look in the docs about message.mentions, you can replace .users for .members
oh, ok
@sudden geyser can i use const bUser = getUserFromMention(args[0]); instead?
I don't know what getUserFromMention does or is supposed to do.
Try it out and see.
ok
@earnest phoenix v11 or 12
v12
Its not .hasPermission anymore in v12
Its permissions.has I believe
Lemme check here
hasPermission is still a method.
.hasPermission still works on some of my commands like kick/mute/addrole etc but idk why at my ban command it don't work
Ah
sorry for my language, i'm in hurry 🙂
for some reason I'm getting cannot send an empty message
if(msg.content.startsWith('test')) {
try {
get('https://blox.dev/embed.html').then(res => {
msg.channel.send(res.body)
});
} catch(err) {
return msg.channel.send(err.stack);
}
}
});
You should await get if it returns a promise.
you need to await the body
To go along with that, what is body supposed to be?
what package are you using?
snekfetch
uh
isn't snekfetch kinda ded
or axios
ok i installed node-fetch
alright now read the docs for an example http request
get is not a function
const res = await fetch(url);
const body = await res.text();```
that's an example
you can provide options after the url if you need to
e.g. method and headers
make sure to handle errors
hm
hmm?
get is not defined
there's docs too
there's nothing that says "get" in the example either
good luck dude
let muterole = message.guild.roles.cache.find(role => role.name === "Muted");
let tomute = message.mentions.users.first();
await(tomute.addRole(muterole.id));
Cannot read property 'id' of undefined
if(!muterole){
try{
muterole = await message.guild.createRole({
name: "Muted",
color: "#000000",
permissions:[]
})
message.guild.channels.forEach(async (channel, id) => {
await channel.overwritePermissions(muterole, {
SEND_MESSAGES: false,
ADD_REACTIONS: false
});
});
}catch(e){
console.log(e.stack);
}
}
i forgit this
=))
forgot*
idk, i just updated to v12
link please?
oh my god


