#development
1 messages · Page 1026 of 1
i just want to see if i can
for (r in results) try {
client.users.cache.get(id).tag
} catch{
client.api.fetch(id).then() => {}}
@earnest phoenix
something like this
okay
if its not cached, get it
hey, im messing around with discord.py, any idea on how i can delete all channels?
for channel in guild.channels:
channel delete()
await bot.message.add_reaction('👍')
if reaction.emoji == '👍':
;-; 
What do you think bot.message is
fetch checks cache first
i think this is the method @earnest phoenix client.api.users(userid).get()

I know but if I was to do that, I can't put it directly into the embed description
why not 🤔
Here is the question this time, the one that you are on about @solemn latch
Is there a way to cache all members in a guild on the ready event?
yes
i still dont understand why you need to do it directly in the description of an embed tho
even if thats true
why not?
`${put all your code here, it makes no diffrence}`
parse your stuff before putting into the embed
¯_(ツ)_/¯
make a string, use concat to add the new stuff after that loop
done, add string onto embed after
@earnest phoenix
@median star
some_message = await ctx.send("REACT TO THIS MESSAGE WITH THUMBS UP PLEASE WITHIN 30 SECONDS OR AN ERROR WILL APPEAR")
# line below will also need a check to restrict the reaction to the same channel where the command was used
# refer to https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for for info on check function
reaction, user = await bot.wait_for("reaction_add", timeout=30)
if str(reaction.emoji) == "👍":
# do stuff
else:
# don't do stuff```
/rbd/pnpm-volume/a89bee78-e8f1-4401-87e1-5e9285a987ce/node_modules/.registry.npmjs.org/quick.db/6.3.2/node_modules/quick.db/node_modules/bindings/bindings.js:135
throw err;
^
Error: Could not locate the bindings file. Tried:
How do i fix this?
looks like quick.db error, I think they have a support server
yeah
they have a support server
They do but im banned for dming someone i asked for help an invite to a server to help me test a bug
yikes
But if I was to make it easier than that, would It be better to cache all members on the ready event?
preloading users will be a privlaged intent
it wont work in a few months
and will dramatically increase bot ram usage
Doesn't matter about performance
😛
so
in a few months
honestly, your making it harder than it needs to be.
you could theoretically make sure the top 10 users are always cached by fetching them every once in awhile.
or just do it the normal way and parse all the data beforehand.
/invite
if str(reaction.emoji) == "👍":
"""Create instant invite"""
guild = ctx.guild
link = await ctx.channel.create_invite(max_age = 300)
chan = bot.get_channel(729403688455635014)
await chan.send(f"problem in {link}")#sending
@slender thistle Await outside function, unexpected indent
link = await ctx.channel.create_inv
ite(max_age = 300)
^
SyntaxError: 'await' outside function
where did you even move that
@bot.command()
async def problem(ctx, message):
await ctx.send('are you sure you want a staff to join and help, you have 30 seconds to react')
line below will also need a check to restrict the reaction to the same channel where the command was used
refer to https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for for info on check function
reaction, user = await bot.wait_for("reaction_add", timeout=30)
if str(reaction.emoji) == "👍":
"""Create instant invite"""
guild = ctx.guild
link = await ctx.channel.create_invite(max_age = 300)
chan = bot.get_channel(729403688455635014)
await chan.send(f"problem in {link}")#sending
else:
await ctx.send('no one will join')
is on_guild_changed an event
me?
yes
What does your code look like rn?
i am pretty sure
let i = 0;
[ { first: 0, last: 2 }, { first: 3, last: 4 } ].forEach((test_data) => {
for (let index = test_data.first; index < test_data.last; index++) {
console.log(`${i} | ` + index);
}
i++;
});
```i think i'm currently brain afk as fuck
i expect the output:
```prolog
0 | 0
0 | 1
1 | 3
1 | 4
```but i get ```
0 | 0
0 | 1
1 | 3
xD
lmao
he didn't
put spaces/tabs before all the other crap that's related to your command
2 spaces to be exact
await too
i mean yeah but meh
oh also you STILL forgot to add a check
despite my comment telling you to add it
i added reaction
discord.ext.commands.errors.MissingRequiredArgument: reaction is a required argument that is missing.
😩
???
why
Actually where is that error even coming from
guys i am having a hard time with the rulesbot. i've added it to my server but i dont know how to make it to where my members accept the rules to unlock the rest of the server. please help as I am new to making a discord server
i think i am supportsed to add rection and use r but it stil not workng
;-;
You're not supposed to enter anything in the command argument
the reaction, user stuff comes as returned values from wait_for
make your bot add the reaction to some message then
is there a way if the guild gets changed, then it goes back?
how do i add a reaction to the message the bot sends
okay im trying to make a sticky messages command but
msg = await ctx.send
await msg.add_reaction
if (msg.channel.id === StickyMessages.get(`sticky.${msg.channel.id}.chID`)) {
if (!msg.member.hasPermission('MANAGE_CHANNELS')) {
let dlt = await msg.channel.messages.fetch(StickyMessages.get(`sticky.${msg.channel.id}.msgID`))
msg.channel.bulkDelete(1)
dlt.delete()
let newID = await msg.channel.send(StickyMessages.get(`sticky.${msg.channel.id}.content`))
StickyMessages.set(`sticky.${msg.channel.id}`, ({
content: args.slice(1),
chID: msg.channel.id,
msgID: newID.id
}))
}
}
its not working, and im getting the unknown message error
its logging the message content to the db, just not updating the ID
wait i may have fucked up brb
how do i use rewrite?
did you not just link some docs...?
ok
Any idea why this is saying 28 February 5285 17:28?
moment.unix(message.createdTimestamp).format("DD MMMM YYYY HH:mm")
if someone made a change, like add a channel, how would i undo that with discord.py?
events
time to scroll up
well no
add a channel as an example
hold on
that gave me an idea
when that event happens
it creates a new channel with the same name and properties of the channel
you mean the copy channel function?
@client.event
async def on_guild_channel_delete(before, after):
print("a channel has been deleted")
after.guild.create_text_channel(name = before.name)
await
let embed = new Discord.MessageEmbed()
.setTitel(`Bot Ban`)
TypeError: (intermediate value).setTitel is not a function
??? tf
Oh nvm
I made a typo
if(msg.member.bot) return
I have this on
client.on('message', msg => {
but i get an error saying
TypeError: Cannot read property 'bot' of null
I don't know why but it happens i guess
client.on('message', msg => {
if(msg.member.bot) return
if(msg.channel.type === 'dm') { if(msg.content.startsWith(prefix + " ")) { return msg.channel.send("I'm sorry but we don't support DM commands since they crash the bot client."); }}
is what i have
Was the message sent in a DM? You could use msg.author instead.
But it's still possible .author could be null.
ah
ok
if(msg.channel.type === 'dm') { if(msg.author.bot) { return } else { if(msg.content.startsWith("goose ")) { return msg.channel.send("I'm sorry but we don't support DM commands since they crash the bot client."); }}}
if(msg.member.bot) return
like that?
It's quite hard to read. Are you on mobile? You can just check it at the top of the function scope rather than just if it was only sent in a DM.
I'm sorry but we don't support DM commands since they crash the bot client.
why include this message? just don't respond at all
its more design choice but do as you wish
maybe some users would think that the bot isn't working or something, leaving a message behind lol
a lot of bots just dont respond to dms
yeah
a lot of tutorials use a similar fashion: if (message.channel.type === 'dm') return
how do i use the clone() function
In python?
oh
i did read the docs but it didnt help
"TypeError: Cannot read property 'bot' of null"
all i did was this
lol
if(msg.member.bot) return
client.on('message', msg => {
if(msg.channel.type === 'dm') return
if(msg.member.bot) return
some message types dont have a member property, such as system and welcome messages, webhooks, etc
also, bot is not a member property
its an author property
depends on what language and library.
on djs you can just make a collection, and store things with .set and get things with .get
can someone tell me how to use clone()? discord py
the docs probably tells you how
just do whatever the text channel is .clone()
so like this?
@client.event
async def on_guild_channel_delete(channel):
print("a channel has been deleted")
await channel.guild.clone(channel)
i have a problem with a bot
i would think it would be channel.clone()
okay
message.guild.id
TypeError: Cannot read property 'id' of null
thank you for the help
message.guild && message.guild.id
^
well no
messages dont always have guilds
i can't do that
you should return to dms
Since I'm using the id to get the settings of the guild
Oh
yeah
k
Thats why
ty
channel.type === "dm" right?
or type
Like I did?
or if(!message.guild) return
channel.type === "dm"?
k ty
¯\_(ツ)_/¯

how do i know who deleted the channel with the on_guild_channel_delete event? discord py
Pulling the info from audit logs
how do i do that
Docs
D O C S
D O G S
...
Docs are generally your main source on how to do things.
It helps to know how to read them and turn it into working code
How do i edit a message after sending it? I tried let sentMessage = await message.channel.send("hi"); but it gives an error. I use discord.js 11 because I'm lazy and won't edit the 100 embeds i use because RichEmbed is now MessageEmbed in version 12
audit_logs method of guild
guild.audit_logs(action = channel_delete)
If you use vsc, you can edit all instances of richembed quite quickly @earnest phoenix
hopefully its the right name of the action
What class has that property
If you use vsc, you can edit all instances of richembed quite quickly @earnest phoenix
@solemn latch what if you're lazy
Well, v11 won't work in a few months anyway
Longer you wait, longer it'll take you to fix
@slender thistle idk, i guessed the name tbh
Ctrl + F on the docs page
then?
can you take a look at my source and tell me everything i need to change? glitch.com/codecodiscordbot i don't have an exposed bot token don't worry
🤔
channel_delete
You need discord.AuditLogAction before the channel_delete in the channel
I'm not going to do all that work for ya.
Time is money 
it took me to event reference
You need discord.AuditLogAction before the channel_delete in the channel
code, not channel

🧃 💩
juice poop?
I'm drinking
Tankya
np
This is #development
does somebody use youtube-dl?
I'm trying to get for example the Video ID with youtube-dl
but I only get the error: cannot read property id of undefined
so uh
how the fuck do i overwrite channel perms in djs v 12? (per user)
(node:6664) UnhandledPromiseRejectionWarning: TypeError [INVALID_TYPE]: Supplied overwrites is not an Array or Collection of Permission Overwrites.
let overwritemedaddy = msg.mentions.members.first()
msg.channel.overwritePermissions(overwritemedaddy, [{
allow: ['VIEW_CHANNEL','SEND_MESSAGES',"READ_MESSAGE_HISTORY"]
}])
The first argument should be the overwrites (an array or collection, but an array is easier). Each element of the array should be an object with any of these properties: https://discord.js.org/#/docs/main/stable/typedef/OverwriteData
Look at the example
Yes, that's what you're doing.
It's like 5 per 5 seconds, but I wouldn't rely on it unless you have a reason to do it in bulk.
FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUCK
The one time I’m not paying attention
I don’t have it running
And it gets declined. Time to wait another month I guess
@sudden geyser nah nah just like I want know a sage value to add it between the thingy
like the time between the dms
Ah okay. Just remember that the library you're using also handles it for extra guarding
Does anyone know a script that sets the bots status??
Discordjs has a ratelimited event, seems kinda useful
ok
Does anyone know a script that sets the bots status??
@exotic cradle what library are you using.
how do i break discord ToS with discord py?
but why
i was joking
i use discord.js, node.js, and Visual Studio Code
What's the V12 version of isMentioned?
Men
like mentions.has()?
check message mentions
mentions.has() yes
Ok
50 percent of perfect a
Can anyone help me with my bot
please just ask
we can't help you if you don't tell us the problem
I don't know how to code tbh I didn't know this app requires coding
@client.event
async def on_guild_channel_delete(channel):
print("a channel has been deleted")
if channel.guild.audit_logs(action = "channel_delete", user = client):
await channel.clone()
else:
await channel.delete()
@client.event
async def on_guild_channel_create(channel):
print("a channel has been created")
if channel.guild.audit_logs(action = "channel_create", user = client):
await channel.delete()
else:
await channel.clone()
E
the code is supposed to clone the channel if it gets deleted
and if the channel gets deleted it gets cloned
and if a channel gets created it gets deleted
I also made it if the bot creates or deletes channels it wont delete/clone
which worked
Aww i have to pay for the bot maker on steam
I have one
h
Idk how to code tbh i thought I wouldn't have to
async context manager time
what
@haughty elbow if you came here to discuss bot makers you're in the wrong place, either learn to code or leave the channel
Debatable
okay
What is html
Does anyone know the check que position command?
There isn't one
Thanks!
And no you can't find out where your bot is in the queue
why do i need to read the audit_logs docs
because you're not using that method properly
Idk how to code tbh i thought I wouldn't have to
@haughty elbow tru tho
What is html
@honest perch hyper text markup language
try {
let invite = guild.channels.cache.filter(c => c.type === 'text').find(x => x.position == 0).createInvite(
{
maxAge: 10 * 60 * 1000,
maxUses: 1
}
)
console.log(invite)
} catch(err1) {
console.log("An error has occured while creating an invite.")
}
guild is set.
For some reason, I keep getting:
Promise { <pending> }
https://stackoverflow.com/questions/53350871/how-to-code-that-bot-will-make-a-temp-instant-invite
https://stackoverflow.com/questions/58358852/discord-js-how-to-get-first-channel-of-a-guild
I've been trying to play with both of these but like i messed up
I'm trying to make that my bot will create a temp instant invite for a guild that it's currently in. Is it possible? (This bot will be public, so it will be in a lot of guilds)
If so, I'm asking fo...
guild = discord.Guild
@shy turret one word: await
guild
SyntaxError: missing ) after argument list
i dont know why but ^ keeps happening when i put console.log(await invite)
i think i need to remove try {} catch(err) {}
await where you create invite
nope didnt work
not where you read invite
ok let me try .then
let invite = await guild.channels.cache.filter...
should also work where he reads it tho
i need to get a refresher on promises
await isnt working for some reason lol
I'd still await where the invite is being created though
@shy turret show code with await
how did it allow you to use await?
Lmao I always defined an async function in the dev console
:P
Didnt know it just worked
any tips to grow a bot
code it
i did
have features that make users want to use it
growing a bot involves many factors: quality features, ease of use, nice design, good presentation, some advertising or website and a bit of luck
^ all of those, give your users a reason to add your bot instead of another bot that may have similar features
and also bandwagoning trends lmao
planttrees
covidbot, pokemonbot
Converting APIs into bots are handy
converting converters into converting converts
What do people recommend to write bots in? I see loads of libraries in pretty much every language, are there languages I should avoid using? Does anyone have any experience writing bots at large scale? How do these bots scale (from a server point of view)? Obviously when no one is using the bot you would want to scale down and conserve compute power.
A lot of big bots either modify the libraries they use or make their own
discordjs is about the worst at anything scaled up pretty large.
however people do have bots with millions of users on it.
really, any offically library will work up to a pretty okay scale.
You can write a bot in any language. A language is simply a tool, and so is a library. Discord.js, for example, is popular as it's very easy with a lot of features and guides, but doesn't handle well when it comes to how much resources it uses. Eris, on the other hand, is another Discord library in JavaScript which is known to do better in the resources it uses.
Hmm okay, also has anyone split their bots out over different regions to reduce latency, or is this not something that needs to be worried about?
can anyone hel me with discord python
what's the issue you're having, please explain
i once heard there is only one text server location for all of discord
i actually never checked
How does the bot edit a message when a response is clicked
Not any particular issue, just thinking ahead, I work at a company where we split our infrastructure over several regions, America, Asia, Europe so we can deliver lower latencies to everyone
Just wondering if anyone has had to do this, or if it’s not something that I should even think about
One text server location makes coding a lot easier hahaha
only bots im aware of that has multiple locations are voice based bots.
ive seen bots with millions of users on basic VPS's costing $10 a month.
the only part of discord that is split in regions is their voice servers
so you should only worry about that you plan to make a music bot
the biggest problem with scaling a bot is caching
because most popular libraries offer very limited caching control
and just cache as much as they can to avoid hitting the api
hey guys, I'm about to implement sharding since my servers past 2k servers now. Currently I'm just using dbl.postStats(client.guilds.cache.size), what would be the best way to update this to ensure all servers get posted to stats when I've included sharding?
i think you can just pass it the client, like normal
Okay makes sense, I’ll keep this in mind, thank you for your time 🙂
if you pass your client to the dbl constructor, you dont need to use postStats
if you want to explicitly use postStats, you just need to add the shard id and total shards parameters
hey
i create cmd rob
i set if i want to rob i must have crowbar and gun
but that not work
someone can help me?
i use quick.db
What
That gives us zero context
No code or explanation of what you have done so far
if (db.has(message.author.id, ["gun", "crowbar"]) === true)
still the === true part is not needed
===?
what I'm trying to do is get the message content using message.content.startsWith to get the "Now Playing" Message to delete and display the next now playing message
anyways
@ebon kelp no need === true??
Is that even how you use the has method
how do i use icon_url_as?
An if statement needs a boolean value, if the responds is boolean you don't have to do equal to
if() {//does this if true}
if(!) {//does this if false}
This is what you did @marble geode
if (true/false === true) {
// code
}
how are you storing the user items?


if(true) { big brain code }
It will never be false

if(true) { big brain code } else { this will literally never be executed }
Pog
That’s some big brain stuff
if(true) {
//gets executed every time
} else {
//never gets executed
}```
Big Brain
how do i use icon_url_as
[1-10] has a range from 1-1, cuz 10 gets counted as 1
Thank you
To test your regex
I changed to 9
Why the |cancel?
why not just \d?
They probably want to match between 1 and 10
that's the same as \d, but I guess it excludes 0
You can use [0-9]
It can be 1 2 3 4 5 6 7 8 or 9
and they split cancel into individual letters
@torn ravine yup idk what you did there xd
fucking regexp
just play around with it
^(?:[1-9]|0[1-9]|10)$|cancel though matching cancel is kind of unneeded in my opinion
regexp looks encrypted at first, but try it out for a while and you'll know how it works easily
That also matches 000001, 00002 etc. by the way
You can remove the second alternation if you don't want that
@strange trout it is kinda uneccesary
because the bot times out automatically after 30 seconds
I just think it's redundant since you'll have to check if the content is equal to cancel after that anyway
This is kind of a weird question, but does anyone know of a site/app/whatever for designing/sketching a user interface?
(node:32613) UnhandledPromiseRejectionWarning: AkairoError [ALREADY_LOADED]: Command 'ping' is already loaded
is there a reason this is happening
how can a command already be loaded
your webbrowser
set your browser to refresh a local webpage every couple seconds and just edit away
🤔
or just edit directly
in the browser
can someone just tell me how to change the guilds icon with discord py my head hurts from searching and scrolling everywhere
youd likly need the image buffered in memory
in discord.py can one of my args be role : discord.Role or is discord.Role not a thing?
discord.Role exists yes
and i cant believe something so simple is just so hard for me to know
how do i change the guilds
nevermind
im not gonna ask the 50th time
im annoying sorry
how do i change the guilds
@elfin flower https://stackoverflow.com/a/52469796
I want to change server icon.
Trying this:
await bot.edit_server(ctx.message.server, icon_url="http://some.thing/image.png)
^^ try this
You read through all the comments
yes
Hmm
backdrop-filter is sexy
https://cdn.discordapp.com/attachments/664343828278542366/729534949228544050/unknown.png
python seems familiar, but also so foreign at the same time
does message.guild.icon.edit() exist?
hey @solemn latch can we talk in dms
no @elfin flower i don't think so but i maybe wro g
wrong*
im in a csgo game 🤔
if its something simple i can answer while im dead
i dont care
give me the answer
i will sacrifice my brain cells to change the guilds icon
oh
pgamer is a js dev
@solemn latch u know me rght?
i have been asking you silly questions since weeks
ye
im gonna dig around docs till i find something
i found three stuff related to guilds icon
guild.icon
guild.icon_url
and
guild.icon_url_as
and none of them is related to changing the guilds icon at all
changing guilds icon impossible confirmed?
anyone know why py async def reactrole(ctx, role, emoji): if isinstance(role, discord.Role): print("test") else: print("test2") does not print "test" when I mention a role as the arg?
@elfin flower chill
okay
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
send a manual curl or something request
if your lib doesnt do it, do it manually
¯_(ツ)_/¯
okay
if(command === "jail"){
client.on('guildMemberAdd', async member => {
const channel = member.guild.channels.cache.find(ch => ch.name === 'member-log');
if (!channel) return;
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'jpg' }));
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
const avatar = await Canvas.loadImage('./assets/jail.png');
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'jail.png');
channel.send(`Bruh you are in jail, ${member}!`, attachment);
});
}```
this is not working
@elfin flower does
await ctx.guild.edit(icon=somethinghere) not work?
and yes i haev defined canvas
@opal plank im using discord py
it's obvious so don't ask
@elfin flower thats the raw api, regardless of language you need to send a json request
can anyone
help
if(command === "jail"){
client.on('guildMemberAdd', async member => {
const channel = member.guild.channels.cache.find(ch => ch.name === 'member-log');
if (!channel) return;
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'jpg' }));
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
const avatar = await Canvas.loadImage('./assets/jail.png');
// Move the image downwards vertically and constrain its height to 200, so it's a square
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'jail.png');
channel.send(`Bruh you are in jail, ${member}!`, attachment);
});
}
this code is not working
it logs nothing
i have defined canvas
and i know avtar is jail imae
because i wanna lay over that
@zenith gazelle no it doesnt
it said
TypeError: startswith first arg must be str or a tuple of str, not bytes
so like
message.guild.edit("32323.jpg", blah blah, blah blah blah)?
help me
What is the easiest way to get a guild by id when sharding? (discord.js)
@delicate shore don't put events in commands
you'll add a new event every time you run it
at RequestHandler.execute (C:\Users\farah\Desktop\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
method: 'delete',
path: '/guilds/710369656262623253/members/404365332912930827',
code: 50013,
httpStatus: 403```
I keep gettting this error when trying to kick anyone from the server.
if (!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send('ERROR : Must have administrative rights to execute this command!')
const usere = message.mentions.users.first();
if (usere) {
const member = message.mentions.members.first();
if (member) {
member.kick('You were kicked from this server.').then(() => {
message.reply('Successfully kicked the user from this server.');
}).catch(err => {
message.reply('I was unable to kick the user.');
console.log(err);
});
} else {
message.reply("Please specify a user from this server.")
}
} else {
message.reply('Please specify a user from this server.')
}
break;```
here is the kick code
missing permissons lol
so what should I do den
give admin straight lol
ok
You should check if the target member is kickabale.
it is
Also why are you checking .users.first() and .members.first() when you only need the members one.
give ur bot higher role than ur user lol
You aren't. There's a property called .kickable on an instance of GuildMember for this
doing a kickable check will check for that
That does not mean it'll be able to kick the member.
that also doesnt mean it can kick a user
You could have administrator on a server yourself and you still wouldn't be able to kick the guild owner for example
Check if .kickable is true.
@delicate shore don't put events in commands
@sick cloud so i need to keep the member one event outside on top
?
discord perms also work off a tier system, the user is above the bot in that tier list, it wont kick, no matter the perms
@solemn latch what u use canvas for in your bot ??
yes
then that's the issue
they are the same role
@mild flower it won't work
hmm
like I said for the 3rd/4th time, check if .kickable on a guild member is true.
If it is, you can kick them.
try it and see
yes
@sick cloud ```js
client.on('guildMemberAdd', async member => {
if(command === "jail"){
try{const channel = member.guild.channels.cache.find(ch => ch.name === 'member-log');
if (!channel) return;
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'jpg' }));
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
const avatar = await Canvas.loadImage('./assets/jail.png');
// Move the image downwards vertically and constrain its height to 200, so it's a square
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'jail.png');
channel.send(`Bruh you are in jail, ${member}!`, attachment);
}catch(err){console.log(err)
msg.channel.send("This command is in")
}
console.log();
}
})
ye
try it and see
how are u using commands inside guildMember
I fixed it
u meenaee
u cannot use message property inside guildMemberAdd
What is the easiest (or best) way to get a guild by id in discord.js when sharding?
u cannot use message property inside guildMemberAdd
@restive pebble then how to use it
@solemn latch what u use canvas for ?
@restive pebble then how to use it
@delicate shore in a message event ie: Client.on(“message”
just directly use it
?
then it says member is not defined
directly execute
@delicate shore I do some stuff with gifs
how would i convert the time my server was created at to just the date?
My blaxkjack game uses canvas too
@errant perch https://discord.com/developers/docs/reference#snowflakes
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
chill dude
ok
@restive pebble ```
typeError: Cannot read property 'channels' of undefined
at Client.<anonymous> (/app/index.js:123:40)
at Client.emit (events.js:196:13)
at MessageCreateAction.handle (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/websocket/WebSocketShard.js:436:22)
at WebSocketShard.onMessage (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/node_modules/ws/lib/event-target.js:125:16)
at WebSocket.emit (events.js:196:13)
at Receiver.receiverOnMessage (/rbd/pnpm-volume/38b33121-f779-43cc-a95d-c99a7cf7a9d4/node_modules/discord.js/node_modules/ws/lib/websocket.js:800:20)
cannot read property channels?????????
send code lol
ok
if(command === "jail"){
let member = msg.author
try{const channel = member.guild.channels.cache.find(ch => ch.name === 'member-log');
if (!channel) return;
const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');
const background = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'jpg' }));
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.strokeStyle = '#74037b';
ctx.strokeRect(0, 0, canvas.width, canvas.height);
const avatar = await Canvas.loadImage('./assets/jail.png');
// Move the image downwards vertically and constrain its height to 200, so it's a square
ctx.drawImage(avatar, 25, 25, 200, 200);
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'jail.png');
channel.send(`Bruh you are in jail, ${member}!`, attachment);
}catch(err){console.log(err)
msg.channel.send("**This command is in development**")
}
console.log();
}
@restive pebble Here^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
what are u doing even
what are u doing even
jail command like dank memer
@restive pebble
hehe
like this ^^^^
^^^
@restive pebble
¯_(ツ)_/¯
(node:2133) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit
How do i fix this lmao
You set member to msg.author
Which is a User
User doesn't have .guild @delicate shore
https://discord.js.org/#/docs/main/stable/class/User
Do you use .on("message", (...) => {...}) explicitly 11 times.
Lmao yeh
If not, do you think you have the event listener nested in another listener or anything that's called more than once
ah well you don't need that
you only need one
Too much work
Lol

Its more work to do it your way
Its like 800+ lines of code lmao
what
Your way is likely going to take more space, along with additional resource use that can easily be chopped down.
You can also make it modular.
Is it within one single file?
uhhh, how would i go about choosing wether to use black or white when faced with a certain color
I guess i can cut them down smaller
Making a black and white filter?
I don't think you should do it yourself
You can use dank memer's api @delicate shore
But I don’t think they will allow it to be used by another bot
@regal raven how
ohhö

doesn't matter
(node:5238) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send messages to this user
I have my settings to allow anyone to dm me but it still sends this what does it mean?
@unborn steeple it's means the user has dm closed or blocked the bot :)
Or not allow direct message
hey
how to define channel
like i am sending s!command
here
and i wanna define this channel
so will it be msg.member.channel?
msg.channel
const { MessageEmbed } = require('discord.js')
const ms = require('parse-ms')
exports.run = async(client, message, args) => {
let user = message.author
if (db.has(`${user.id}`, ["gun", "crowbar"]) === true) {
let timeout = 3600000
let robed = db.fetch(`robed_${user.id}`)
if (robed != null && timeout - (Date.now() - robed) > 0) {
let time = ms(timeout - (Date.now() - robed));
message.channel.send(`You have already robbed a bank please come back in **${time.hours}h ${time.minutes}m ${time.seconds}s**`)
} else {
let earned = Math.floor(Math.random() * 1500) + 1
let jobs = ["Rexy Bank", "Discord Bank", "NYC Bank", "BCA Bank"]
let job = jobs[Math.floor(Math.random()* jobs.length)]
let embed = new MessageEmbed()
.setColor(0x7289DA)
.setAuthor(`${user.username}`, user.avatarURL())
.setDescription(`Robbed in: ${job}\nGet: ${earned}$`)
message.channel.send(embed)
db.add(`money_${user.id}`, earned)
db.set(`robed_${user.id}`, Date.now())
}
} else if (db.has(`${user.id}`, ["gun", "crowbar"]) === false) {
return message.channel.send("You need to buy a gun and crowbar first (hint: r!shop leads you to shop where you can buy stuff)")
}
}
exports.help = {
name: "rob",
description: "rob a bank and earn money",
usage: "r!rob",
example: "r!rob",
};
exports.conf = {
aliases: [""],
cooldown: 5
};
that my code
error lol?
i want someone want to rob must have gun and crowbar
but i test it
i no have gun and crowbar
and can do it
someone can help fix?
@restive pebble sir
sorry i cant help with quick.db
(!db.has(${user.id}, ["gun", "crowbar"]) maybe try like that
You could check the docs
Anyone can help help me how to fix is this problem 🤔🤔
Tall me how can do that
No bro
There's no point denying if you did
That's what it thinks happened
Yeah go to the Dev server :////
OK thanks @pure lion
Np
https://cdn.discordapp.com/attachments/343944376055103488/729579601726013440/unknown.png
how can i make this?
like it send all user in the role
and if from than 20 user then the bot make page
system
d.js?
get the list store it somewhere and edit the message
but how i do the pages thing?
idk then. on .js i chunk them down into a wanted amount and create a new page for each chunk
its an embed
edit the embed
you need to learn discord.py
like only 20 users on first page
yh
How do I add multiple prefixes in discord.py?
@potent holly you added your bot to 100 servers
You
@pure lion no, he added his bot here.
adding your bot to bot lists to get that initial leg up to 75 servers is considered "inorganic growth"
im pretty sure if u have like 5 test server or smth somewhere around there it is also inorganic
maybe, but theyve stated clearly that adding a bot here is called inorganic or advertised, and best thing you can do is reapply once you hit 250 servers and they tend to always accept that
its not like they can say no for no reason, just to cripple your bot, right? 😛
there are some issues with this, they made a Post on the d.js dev server about it and they want to fix some of the issues
Hmm would have been good to post that somewhere more generic,.not everyone uses djs
Can you copy and paste that please @lusty quest
Hey i recently installed a, tracker for like fortnite stats but how do i put a class into a command?
class TestRainbow6Siege(unittest.TestCase):
def test_get_player_info(self):
r6s = Rest('config.yaml', ignore_limiter=True).Rainbow6Siege
info = r6s.get_player_info('barzY-YT', 'uplay')
assert info['player']['username'] == 'barzY-YT'
def test_get_player_operators(self):
r6s = Rest('config.yaml', ignore_limiter=True).Rainbow6Siege
info = r6s.get_player_operators('barzY-YT', 'uplay')
assert len(info['operator_records']) > 0
def test_get_leaderboards(self):
r6s = Rest('config.yaml', ignore_limiter=True).Rainbow6Siege
leaders = r6s.get_leaderboards('pc', page=1)
assert len(leaders) == 100
def test_get_player_stats_seasonal(self):
r6s = Rest('config.yaml', ignore_limiter=True).Rainbow6Siege
player_stats = r6s.get_player_stats_seasonal('bedbbe83-015a-4e6f-babc-580c6e6ff9f3')
assert player_stats['username'] == 'SanalsBae'
def test_get_player_stats(self):
r6s = Rest('config.yaml', ignore_limiter=True).Rainbow6Siege
player_stats = r6s.get_player_stats('bedbbe83-015a-4e6f-babc-580c6e6ff9f3')
assert player_stats['username'] == 'SanalsBae'
def test_get_high_level_player_status(self):
r6s = Rest('config.yaml', ignore_limiter=True).Rainbow6Siege
player_stats = r6s.get_high_level_player_status('SanalsBae', 'pc')
assert player_stats[0]['ubisoft_id'] == 'bedbbe83-015a-4e6f-babc-580c6e6ff9f3'```
for examle that
@lusty quest dm me an invite please i'll take a look
if(command === "covidadv"){
api.all().then(console.log)
const data = await api.all()
const coronaadv = new Discord.MessageEmbed()
.setColor("RANDOM")
.setTitel("Advance Covid Stats")
.setDescription("No. of cases are not exact and may differ")
.addField("Global Cases" ,data.cases, true)
.addField("Global Deaths" ,data.deaths, true)
.addField("Global Recoveries" ,data.recovered, true)
.addField("Active cases" ,data.active, true)
.addField("Cases Today", data.todayCases, true)
.addField("Critical Cases", data.critical, true)
.setFooter("Stay Home, Stay safe | s!help")
}```
it says .setColor is not a function
like
wot
oh
have u tried colour?
@green kestrel found it was not the d.js server
oh lol
ah, ok
@lusty quest you know python right?
i forgot msg.channel.send
@delicate shore you also spelt title wrong let me just save you the problem in advance
@weary ridge not really
ah its ddev
oh
How to fix this?
tbh their suspicious growth thing is a bit silly
Agreed
agreed
they dont let you apply till you grow, and most grow by telling people about their bot, but thats inorganic
there are users that will get Friends together to create 100 Guilds just for getting the Badge
can anyone help with this? https://discordapp.com/channels/264445053596991498/272764566411149314/729591763618103396
my last bot i put on here, i went from 3 guilds to 75 in a day, then went over 250 over the next week
and then they woulda told you apply in 2 weeks
gg. i grow about 3 servers/week since i hit 100
my last bot i put on here, i went from 3 guilds to 75 in a day, then went over 250 over the next week
@green kestrel I don’t understand how they classify that as inorganic tbh Iike yeah I get it’s suspicious that it grew fast but it’s not like your sitting there saying “hey everyone check out my bot page”
my friend got to 160 in 2 days Lul
@delicate shore you also spelt title wrong let me just save you the problem in advance
@hoary elm oh thnx
lol\
and i think ik why
but thats a waste
and i pay for ads here too
lul
not at all, it gets me massive growth
hmm
but theyre saying then that this method of growth thats fine in any other industry isnt fine for a bot dev... why?
i dont want to compete with Mee6 and spend like 300$ on ads
Yeah that doesn’t make sense
hmm just curious is it possible to put ads in that html you allow us to add?
also im fine with the current grow. getting over night 1000 new Guilds would kill my Server
i could cope with that
100,000 and i'd be hoping at least a small percentage got premium lol
because then i'd need more physical servers
my Database is already ready for infinite scaling but the Server where the bot is running on not
TypeError: (intermediate value).setTitle(...).setcolor is not a function
at Client.<anonymous> (/app/index.js:822:6)
at processTicksAndRejections (internal/process/task_queues.js:88:5)
i am havin this error
also i need to find a way to get the shards on mutiple servers better managed. doing it manually is annoying
if(command === "covid"){
const countrycovid = args[1]
const countrydata = await api.countries({country : countrycovid})
try{
const countryembed = new Discord.MessageEmbed()
.setTitle(`${countrycovid}`)
.setcolor("RANDOM")
.setDescription("No. of cases are not exact and may differ")
.addField("Cases" ,countrydata.cases, true)
.addField("Deaths" ,countrydata.deaths, true)
.addField("Recoveries" ,countrydata.recovered, true)
.addField("Active Cases" ,countrydata.active, true)
.addField("Cases Today", countrydata.todayCases, true)
.addField("Critical Cases", countrydata.critical, true)
.setFooter("Stay Home, Stay safe | s!help")
msg.channel.send(countryembed)
} catch(err){
console.log(countrycovid)
console.log(err)
msg.reply("**This command is under construction**")
}
}
your code?
my code ^^
setColor
setColor
Capital C
fix the captial C and see if it works
^^
guys
ok
u use corona api
Use my api lol
check if the API return something usefull. if not change it to wahtevery you want
with postman ??
lol
It's webscrapped
first console log the respounce
So u can see
then u can see
npm I worldometer-coronavirus-info
@earnest phoenix nope0
So easy to use
look docs
Take a look at docs before trying anything lol
dide
It's a npm package
Hmmm






