#development
1 messages ยท Page 1322 of 1

deviating a bit from #development
Wasn't it Speedy who was asking about C# earlier?
probably
lol in general vc there's inly a person
only*
the issue is probably in the load commands file 
or idk
somewhere lol
Just make sure that you declare commands and that it's an array
No, can't change your mind
But for a beginner with a small bot it doesn't matter
and they have unique indexers
if we gonna throw coding practices out of the winodws just cuz the bot is small why not make every command under its own client.on('message') ? you can have up to 11 commands

๐ง
i dont see being a small bot excuse for using bad code
Hey Erwin
sup
But for a beginner with a small bot it doesn't matter
like me

i'm the beginner that you're searching for

๐
best command handler right here
no u
My eyes are burning
Don't tell me that's your bot 
thats my test branch for the clustering, yes
my focus is on the clustering and IPC bit, not on this rn
Panikk
@slender thistle i tried the module u recommended
it didnt work
import asyncio
import aioschedule as schedule
import time
async def job():
print('hello bob')
asyncio.sleep(1)
schedule.every().day.at("18:25").do(job)
loop = asyncio.get_event_loop()
while True:
loop.run_until_complete(schedule.run_pending())
time.sleep(0.1)
print('help')
it never prints help
nope
channel = discord.utils.get(payload.text_channels, name="starboard") how can i make channel be the channel called starboard when im only passing self and payload?
its for starboard command discordpy
Never heard of MariaDB
^
TypeError: Cannot read property 'filter' of undefined ```
@wind kayak it's MySQL v2
Uhhh... what??
I don't use d.js but I'm pretty sure it's members.cache
anyone here who knows a way to clear cache of discord / twitch. im trying to fetch some images with twitch api but image wont update when im refetching it?
there shouldn't be any cache behavior by default
but just append a cache buster to the url
google it if you don't know what it is
i added a unix timestamp on the url provided ...jpg?time=(unix timestamp)
that should work
but doesnt have any affect
i use nodejs with discord.js and twitch.tv-api which fetch data from streamer when its starts the stream. when its live it fetch stream data which includes api thumbnail.preview (small, medium, large), where i added the timestamp ?time=unixtimestamp
${data.stream.preview.medium}?time=${dateunix} something like this
@spare trench twitch doesnt have cache
@opal plank i figured out. its the cache of discord when i delete manual %appdata%\discord -> Cache folder and restart discord the images change to the new ones
what are you even doing that requires you to clear your own cache?
whenever you do a request it returns the url of the preview
thats about it, no caching involved
so idk what you even attempting to do, less so about adding timestamp on your url
yeah, i assumed that part, but what does the timestamp have to do with the returned preview?
i want to refresh the image. but because discord is creating a cache of it, because name of image provided by twitch api is always the same it wont change and it keeps example: GTA V image of yesterday but streamer is currently playing Mario Kart it wont change to the new image because of cache
ke will try
Is there anyway that i can make the text color in discord embed?
hi
Why is my bot not listed in top.gg
why why why why why why why why why why

@night rose dont think so, you could use image generation to bypass that though
@earnest phoenix cuz you either:
havent submitted your bot
it hasnt been approved yet
it has been declined
Ow yeah thnx
No, I was not rejected however
I have not been answered in the first place

what should I do
Why does webhook.send give "Cannot send an empty message"?
@earnest phoenix read #502193464054644737
you need to submit your bot first
@snow urchin cuz its empty
I sent it
@snow urchin cuz its empty
@opal plank How.. its sends an embed?
is the embed empty though?
How will I ask for a response without sending the bot ._.
i'd recommend logging the embbed object before sending it
Who here play rocket league Iโm doing a giveaway check it out My user name is Lawzdogplayz
@obtuse tiger bruh
add content, i think your embed is malformed @snow urchin
if it only sends the content that would mean the embed is malformed
It works when sending straight to a channel
@snow urchin embeds is part of the second argument (options): https://discord.js.org/#/docs/main/stable/class/Webhook?scrollTo=send
im fairly certain you can send the payload directly @sudden geyser
Yes, but you need to supply it as the second argument under embeds: [...]
so null, embed?
i dont think you even need that
didnt think so either
just like send() it can parse the payload directly
actually you don't even need to pass nvmembeds: [...]
try what i said, add content property on your object
outside of embed
{content: 'test', embeds: ...}
fetch("api stuff")
.then(res => res.json())
.then(json => {
return json;
});
Why does this return undefined? But console.log(json) gives me the JSON
i need hewp with making a snipe command pls dm me
so in theory im manually trying to launch 2 shards (for fun)
but it keeps restarting
without errors
ngl, watching paint dry is less infuriating than doing sharding
you starting to get a hold of what i was talking about in the previous msg
i mean, it worked with 2 so i dont see the problem with 20
i will simply repeat my message above
await request('api', function (error, response, body) {
if(error) throw error;
if(response.statusCode !== 200) return console.log(chalk.red("ERROR ") + 'Status code was ' + response.statusCode)
return body;
});
Returns Promise { <Pending> } even tho its an async function?

websocket connections and spawning childs with IPC pipes is one hell of a nightmare
discord made an official bot https://dis.gd/add-trickcordtreat lmao
nvm 2 is the most that will spawn
@honest perch wdym
i can only spawn 2 shards without it breaking
Any help?
is there a like limit per how many servers you have
yall legit hoping into a hornets nest, im not even kidding
possibly
websocket connections and spawning childs with IPC pipes is one hell of a nightmare
@opal plank websockets themself are a pain
sharding is:
hard
annoying to debug
advanced
and is a bitch with its mood swings
@opal plank well can you help me with a snipe command
there aint much in a snipe command
just map channel.id => message
its legit 3 lines
on messageDelete => map.set(channel.id, message)
on snipe command
message.channel.send(map.get(channel.id))
thats it
HeLlO? Am I being ignored?
thats it
@opal plank huh funny but that only works in index.js right what if i have a command handler
is that the most efficient way (as far as lag goes) to do it?
probably passing it as parameter
right
though depending on how your command handler is setup, it may not work very well
so its case-use
ive tried that
await request('api', function (error, response, body) { if(error) throw error; if(response.statusCode !== 200) return console.log(chalk.red("ERROR ") + 'Status code was ' + response.statusCode) return body; });Returns Promise { <Pending> } even tho its an async function?
@tulip ledge async function returns a promise
how do I depromisify?
^ that should work
Nope request.then is not a function
Tried it before
And node-fetch fetch('api').then(res => {return res.json()}) returns Promise { <Pending> } too
is 'api' even a valid url?
oh i see
you could try util on it
util usually works well with callbacks like that
to promisify it
ill try
fetch('api').then(res => res.json()).then(json => {
code here
})``` @tulip ledge
that would likely turn into a massive callback hell
specially if they do more stuff after that then() chain
try promisifying
Taf urs returns Promise { undefined }
require("util").promisify(fetch)(<whatever you want to do in the function>)```
callbackify ๐ง
Callback hell more like smol brain
@earnest phoenix urs returns pending too
idk how lol
.then(res => res.json())
```not works?
no

Nope
Weird
Have you tried
let response = await <node-fetch>("API").then(res => res.json());```
What would be the best way to show two command prefixes without it being confusing
my two prefixes are chai and ,, so something like chai, . ?
I feel that could get confusing tho
node-fetch uses two promises
you have to wait for the first promise, which returns a response object containing a data stream, then you have to wait for the second promise, which reads the stream and converts it into the appropriate data format you chose
so basically ```js
let response = await fetch("bla");
let data = await response.json();
// or
fetch("bla").then(response => response.json()).then(data => console.log(data))
@wraith haven you can just put like , or chai
Or wrap both prefixes between one line code blocks
#credit
, and chai
Anyone know how I can test an error event? D.js
I've tried client.ws.emit("error", "bar") and got nothing
client.emit()
without ws
is there any token system bot
similar to licensy
that isnt donatebot.io also
license system bot
I am looking to develop a bot.
is there any bots or source code for custom bots that can take payments through dms
so i dm the bot and it goes through a payment process
idk if there is anything like that, but you can look into the paypal and stripe apis
message = await self.client.get_channel(payload.channel_id).fetch_message(payload.message_) how would i get the message?
like payload.message_content?
content doesnt work
@blissful coral What's type at that point
If you log results[0].channeltype do you get '1'
python
@earnest phoenix Was a stupid error I fixed it
I have this inside a function inside a class, inside another function for the same class I log this.attachments, why does it return undefined?
You were supposed to pass a function, but you passed nothing/something that evaluated to undefined instead.
See the stacktrace for help
Notice the ) after "collect"
The second argument is supposed to be the function.
You instead closed it.
message.guilds.members.cache.get(args[0]) DOes this check if a user is in any server that the bot is in?
or is it not valid syntax
@snow urchin could you share your code on a site like hastebin.com as it's hard to visualize.
big brain
alright get ready for a big block of hastebin code ๐
?
is client.guilds.members.cache.get(args[0]) valid syntax?
@sudden geyser Actually I do not understand. Can you explain in more detail?
No, it's not valid syntax. Check the docs for info as members is not a member of the .guilds cache manager.
k
errrrrr one sec
๐
@sudden geyser Actually I do not understand. Can you explain in more detail?
And with the updates I am doing:
https://github.com/callumokane/Discord-Bot/tree/main/src/modules/support
@quartz kindle
Let me just push current
It's not working because you only passed one argument to it. You closed it via ) after "collect". This comes down to syntax.
reaction.on("collect", async (reaction, user) => {
// function code
})
Tim, that repo should be updated now, so you can have a look
@snow urchin in the attach command, for example
you use new Ticket, then ticket.fetch, then ticket.attach
ticket.attach uses this.attachments
Og thx
but this.attachments is only created by ticket.create
so it can only be used in ticket.create?
your current code only creates this.attachments if you run ticket.create somewhere before using ticket.attach
yes, I do
Oh wait
I see now ๐
Since I push the attachments to the database, I guess my solution would be to set this.attachments in ticket.fetch
Thanks ๐
So I started from scratch again for Discord.NET. I think I'm utilizing the lib a bit better than my own project if anyone wants to check it out
https://github.com/Code2Gether-Discord/Code2Gether-Discord-Bot
@umbral zephyr you dont make a database in discord js
you make a database, then use the language(js) or a library(also js) to connect and exchange data from/into it
ok
you need to do research about which database you need to use first
ik that
Mongo, Maria, Cassandra, postgres, or the likes
it varies on preference and usage
its the right tool for the right job tbh
the only realistic thing you should worry about is ACID compliance and Relational Database
the rest shouldnt matter too much, unless dealing with specifics
Why are there like 5-9 ways to represent a multi-line string in YAML
because fuck youโข๏ธ
i hate working with yaml
it's so... inconsistent despite being a format
I like some things of it, like creating a multi-line string isn't as painful as it is in JSON, but I have to agree that it's too inconsistent.
does anyone know how to make a collector within a collector? this is the code I have so far: https://paste.mod.gg/ugojeyezeg.js
If I am using a forEach and its going to run twice for 2 found then how do I make it wait 1 second before running the next foreach?
You should convert it to a for of and use something that could block/pause the execution.
An example would be making a sleep function defined as so: js const sleep = (ms) => new Promise((res) => setTimeout(res, ms))
function sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
///then here you want it to sleep just add where you want it to sleep
sleep(1000);
@blissful coral
Then in your forEach, , you call sleep(...).
Creepa I don't recommend that method.
That loop will constantly keep running until it's over.
That could be millions of iterations.
Wait so where would I put sleep then @sudden geyser
Just put sleep after the code
where you want it to sleep at
You put it where you want to block/pause the execution in the loop.
Okay
so like where you want it to wait at in the code
You also need to await it.
const sleep = (ms) => new Promise((res) => setTimeout(res, ms))
so I just change ms to the time
Ok
no no
No, you call the function with the duration in milliseconds.
ah
leave that the same. but then where you want it to sleep do ```js
sleep(1000) //this sleeps it for one second which is 1000 milliseconds
.query(...) is executed later as it's a callback. There's no guarantee found will be true on time.
Is there a work around?
Yes, handle it in the callback instead.
The only gain from that is readability/syntax though. And they would still need to make the forEach function argument async, and since promises are also called "later", there wouldn't be any benefit.
The only gain from that is readability/syntax though. And they would still need to make the
forEachfunction argument async, and since promises are also called "later", there wouldn't be any benefit.
yeah it would just be cleaner imo
query isn't async by default
i thin, but I'm not sure, never used it
This worked for checking forEach with IDs on a different bot I had
Don't know why it isn't working here
Hello
import asyncio
import aioschedule as schedule
import time
async def job():
print('hello bob')
asyncio.sleep(1)
schedule.every().day.at("18:25").do(job)
loop = asyncio.get_event_loop()
while True:
loop.run_until_complete(schedule.run_pending())
time.sleep(0.1)
print('help')
this never prints help
i used module aioschedule
Shouldn't this work better?
The loop isn't running
hmm
I see it don't answer
LMFAO
const channels = message.mentions.channels.filter(c => c.type === 'text')
console.log(channels[i].id)
``` Tells me channels[i] is undefined
i is 0
When I do
const channelarray = channels.array()
console.log(channnelarray[0].id)
I get a error that id is not defined aka channelarray 0 is not defined
Anyone know why?
Does anyone have any idea on how to draw text using canvas?
spooky maybe your channels is just getting the id and not object? nah that wouldn't make sense never mind
Btw, guys, arch I've seen in my bot guilds logs, that my bot has leaved this server or other servers (pseudo-leave, I mean - bot receives leave event, but isn't actually leaving) . And I know that discord is doing this
. But is there some way to know about this "weird" events?
*know/detect
O.o too many questions
a GUILD_DELETE event is emitted by discord when guilds become unavailable
you can check if the event contains unavailable:true
Isnt channels a collection not an array @blissful coral
@vernal rivet yeah but you can do .array() according to the docs
What are you trying to do?
So I provide multiple channels
Then it will search the db for each channel
I am using a for loop to search by each one
But I can't do channel[number] because it isn't a array
There should be a .forEach method
when I search through my db it doesn't come back in time and I can't use await because it won't wait for it in a forEach
How long does the db call take?
I mean it looks like you're doing remote db correct?
Oh your dealing with callbacks
Try wrapping it in a promise
Either that or inside a function and have a function call into a variable
can someone explain the basics of clustering in the context of a discord bot? I think I have a slight understanding, but any explanation would help a lot :)
Does anyone have any idea on how to draw text using canvas?
thx
ctx.font = '30px "bhb"';
ctx.fillText(textMessage, 0, imgHeight/2);
I was doing that but it wasn't working for some reason
@jovial void clustering doesnt actually mean anything in itself, its just a popularly used word to define multiple processes running multiple shards each
so I can have two processes running like 30 shards each, with the first process running shards 0 - 29 and second running 30 - 59 and nothing conflicts with each other
yes you can
do you have any insights on how one would go about implementing such a system?
thank you for your help thus far btw :)
depends on the library you use
I am on python, but basic principles might apply across all languages, idk
never done something like this before, thats why I'm finding it a bit confusing sorry
so technically you would need to supply a total shard count, ie 60, and a list of shard ids, ie [0,2,3,4,...30] to the client
but from looking at the dpy docs, it seems discord.py doesnt support internal sharding
their shard_id option only accepts an integer, and not an array
oh wait i forgot about autosharded client
let me check
ah yes here it is
client = discord.AutoShardedClient(shard_count=10, shard_ids=(1, 2, 5, 6))
so you would launch one process with ids 0 through 29, and another with ids 30 through 59, both with a total count of 60
ohhhhhhh
I see
so suppose I've calculated the required amount of shards, I could then launch processes accordingly with the appropriate shard_count and shard_ids for each process
yup
coming together
yeah ig I just thought it was more complicated than it sounds
thanks a lot!
really appreciate it
np :3
Tim filltext does work but it won't wrap the text on image
I am not sure how to do that, do you have any idea?
there is no text wrapping on canvas
fillText does have a 4th parameter where you can specify the text's max width in pixels, and if reached, it will automatically resize the font to make it fit
but there is no autowrap feature
you need to wrap the text yourself
you can use the measureText functions to get the text width in pixels, and if bigger than the width you're working with, split the text into two lines
to make it go into a second line, you need to use fillText again but with a different Y value
you need to define the line height yourself
how do I throw a DM if missing permissions on sending messages?
Doesnโt sending message return a value assuming to be the message id if successful?
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
Create a new DM channel with a user. Returns a DM channel object.
how do i convert a pdf to some other filetype?
Guessing it will return null or false if not successful meaning permissions are missing or recipient doesnโt allow DM. @carmine summit
I can't seem to make it work by try{}catch{}
try{
message.channel.send('Test')
}
catch (e) {
message.author.send(`Error: ${e.message}\n\nKindy join our support server and report it there.`)
}
try catch doesn't work and gives an error in the console
Canvas is an un found module yet if I run npm install canvas it installs then displays tons of errors then donโt work.
Canvas has requirements
Wdym
Check out their github page
Idk where to find their page at.
Canโt copy your message nicely on mobile but try to catch the return value by let result = message...send();
See what result will be.
If successful it should be an object if not false or null I assume. @carmine summit
uh
there is a lot of coding to do
if i did that
there are like a thousand of message.channel.send() in my codes
ah wait
client.member.hasPermission()
YES
nono I'm ust gon use .hasPermission()
that could work too
alright
hmm
channel overrides could be a pain
Idk where to find their page at. @solemn latch
Good luck gonna sleep now
@earnest phoenix https://lmgtfy.app/?q=Canvas+node
Did they rework lmgtfy, it sucks now :(
So .hasPermission() returns true/false depending on the roles and completely ignores channel overwrites.
What I wanted to do, is to check if the channel has permission overwrites
@zenith knoll json.includes(search)
no?
{
'2': {'s': '3', 'r': '7'}
}
and i did search for a 7
would it get to the 'r': '7'
so you want to search the values
yea
no
im just checking IF its true
like
im checking if 7 is in the 'r' key of anything in the first key layer
its hard to explain
here
is an json example ion it
{
372856234756: {"chanid": 102348796, "firstmsg": "hi"},
23423424: {"chanid": 3242342, "firstmsg": "ji"},
987789789: {"chanid": 10232342448796, "firstmsg": "by"}
}```
@carmine summit
Should this data be in a database?
Yeah, but why?
I feel like this data looks like something that should be in a database
Databases fit millions and millions of row
Rows
And are designed to be plug and play
And do this perfectly
Loop over the entire json
In what language?
js
Use object keys
o
im so dumb
thank you
so i get the array of obj keys
and do a foreach
and check if the id is alr used
kk
Internal you can save some ram and put more shards in a single thread iirc
So internal is better?
Internal can be better. Can be worse
So .hasPermission() returns true/false depending on the roles and completely ignores channel overwrites.
What I wanted to do, is to check if the channel has permission overwrites.
So: Role permissions: false, Channel overwrites: true //returns true
If your bot uses 100% of a thread at 2000 guilds, and you use internal sharding making it so you have 4000 guilds per thread you'll have some lag issues
You can combine them iirc
Huge bots typically do afaik
Huge bots have such of different things lmao
One last question, const client = new Discord.client({ shardCount: 'auto' });
this is for normal d.js
If i use commando
Um what would it be then?
same thing, though .client should be capitalized
Thanks
https://discord.js.org/#/docs/commando/master/typedef/CommandoClientOptions
https://discord.js.org/#/docs/main/master/typedef/ClientOptions
Seems like it
sad
auto doesnt work
you set shards to 'auto', not shardCount
Oh
Welp
My bad
Is there any client.shards number which tells how many shards are their or something?
got it nvm
client.shard.count
@quartz kindle round two, this time with just one question lol. That got me thinking about how I'd sync all the instances up with one another (say for a restart) and how I'd actually obtain the recommended number of shards in the first place. Would this call for some fancy docker stuff or am I overcomplicating things? (please ping if you respond, thank you!)
i can't connect to pm2
package.json
{
"name": "Bot",
"version": "1.0.0",
"description": "",
"main": "bot.js",
"scripts": {
"prod:start": "pm2-runtime bot.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.2",
"discord.js": "^12.3.1",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"moment": "^2.27.0",
"ms": "^2.1.2",
"node-fetch": "^2.6.0",
"pm2": "^4.5.0",
"quick.db": "^7.1.1"
}
}
.env
PM2_PUBLIC_KEY=nothingtoseehere
PM2_SECRET_KEY=nothingtoseehere
bot.js
const pm2 = require('pm2')
connect to pm2? do you mean the web dashboard thingy
connect to pm2? do you mean the web dashboard thingy
@small prairie yes
pm2 link
???
Thats what it says on the help thingy
Isnt pm2 a terminal app?
idk
Yeah
ok i removed it
package.json
{
"name": "Bot",
"version": "1.0.0",
"description": "",
"main": "bot.js",
"scripts": {
"prod:start": "pm2-runtime bot.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.2",
"discord.js": "^12.3.1",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"moment": "^2.27.0",
"ms": "^2.1.2",
"node-fetch": "^2.6.0",
"quick.db": "^7.1.1"
}
}
.env
PM2_PUBLIC_KEY=nothingtoseehere
PM2_SECRET_KEY=nothingtoseehere
Whenever i think i cant be surprised
New devs at DBL Do it
Dbl new devs never cease to amaze me
hmm
it says that ita a dependency
so i added back "pm2": "^4.5.0", in package.json
its still dosn't connect
Uh what do you think PM2 is?
Monitoring for?
npm i discordjs
?
how do I install discord.js though
^
Do you known what NPM is?
no
Do you know what nodejs is?
no
do you know how to make js code?
Do you know javascript?
Welp this isnt the right place to start then
but how do i install discord,js though
learn javascript first
^
@small prairie I need help conencting to pm2 please
im just want to know how to install that
Install discordjs is not like installing "An app" or a game
You need to use terminal in the most cases
...
And you need basic JS knowledge if you are starting with d.js
you won't understand what you will be doing if you don't understand javascript
Or there are always people who will mock you like crazy
;-;
That has happened to me, The developer world is not all friendly
Well, not in communities like this one
Who knows lmao
A good guy might be having a bad day and comes here to vent
But yea, This server is a good place
its pretty much easy
you tell a variable what he is, then call it, then he will say what he is
Thats confusing but surprisingly correct
var str = "Hello world!";
console.log(str);
//returns Hello world!
0.0
Id take a look at the djs guide
https://discordjs.guide/
thanks
Yea
I dont understand what you are trying to do so i cant help
Afaik pm2 isnt even a in file module
Pm2 is just a process manager.
Not sure what you'd want a module for it?
Id take a look at the djs guide
https://discordjs.guide/
@solemn latch im even more confused than before
Its the basics of the basics
...
Its best to understand a bit about the language first really.
which link do i choose first
There is only 1 link ._.
Javascript.info is a good one
ok nvm
the link in the site
Most here hate it, but codecademy i like for the very very basics. Anything past like the second section kinda sucks
i typed pm2 in console, gave me pm2 is not defined
do npm i pm2 -g
ok then???
then retype pm2 in your console
Codecademy sucked for me with HTML and CSS ngl
I barely learned anything, it was mostly an equivalent of copy-pasting with all the "enter the small snippet of CSS here"
then retype pm2 in your console
@small prairie gave me an object that has spaggethi code
Hf
thats really not the thing to have fun about but Thanks!
What happens when you do pm2 monit
@slender thistle codecademy has sucked at a lot of stuff tbh
every task you finish it suggests pro mode
lol
or that one time where in their C++ tutorial were talking about inlines and shoved a bunch of code I never saw and basically said "yeah test it and see if it makes your code faster"
I miss the days when it didn't have pro mode
Would have 4 pages of text per example
๐คทโโ๏ธ
I'm sorry hwat
oh and there's one more thing. When the number of users for a course isn't that high they'll usually just put the number of users they have across the entire site (join 45m+ "learners") which looks silly
Help
add .size at the last part maybe
Thought I would share a poker game I wrote in C# (itโs commented out because there are bugs i.e. 2 games canโt run at once etc.) The poker game does work on its own tho: https://github.com/stageosu/Kaguya/blob/master/KaguyaProjectV2/KaguyaBot/Core/Commands/Currency/Poker/PokerGame.cs
add
.sizeat the last part maybe
@carmine summit and if i want it to say how many text channels, then that?
message.guild.TextChannels.cache.size
const Discord = require("discord.js");
const client = new Discord.Client();
const fs = require('fs');
const prefix = 'bow ';
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync(`./Commands/`)
for(const file of commandFiles){
const command = require(`./Commands/${file}`);
const name = file.split('.')[0];
client.commands.set(name, command);
}
const cooldowns = new Discord.Collection();
client.on("ready", () => {
console.log("bow bot is online!!");
client.user.setActivity(`${client.users.cache.size} people!`, { type: 'WATCHING' });
});
client.on("message", (message) => {
if (message.channel.type === "DM") return;
if (!message.content.toLowerCase().startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if (!cooldowns.has(command.name)) {
cooldowns.set(command.name, new Discord.Collection());
}
if(client.commands.has(command)) {
client.commands.get(command).execute(message)
}
}
)
client.login('NzI1NjMwMjkwNTg3ODExOT5.Xw8ltQ.aNqF_ii6thN-J9hhTWOdLXOsQEI')
// fake token dw
okay so even if i do this thing where it checks if the channel type is dm, it still responds to dm commands how do i fix it
read the comment
if (message.channel.type === 'dm') return
@hazy sparrow
if (message.channel.type === 'dm') return
dm is lowercase ^
yo cwickks
add
.sizeat the last part maybe
and if i want it to say how many text channels, then that?
message.guild.TextChannels.cache.size
you need to loop through message.guild.channels.cache and manually count the text channels
BRUH
............
-nodot
or filter the cache to include only text channels and count the size of the filtered collection
message.guild.channels.cache.filter((channel) => channel.type === 'text')
message.guild.channels.cache.filter((c) => c.type !== "category").size;
then?
there you go
you have a collection of only text channels, and you can find the size of it easily with .size
ive got message.channel.send(attachment); and it takes some time to upload, so how do i make it send a message and delete the message after it has sent?
what do you mean?
put dot size
where?
ive got
message.channel.send(attachment);and it takes some time to upload, so how do i make it send a message and delete the message after it has sent?
@silver lintel
message.channel.send(attachment).then (message.delete({timeout: time in milliseconds }));
no
put dot size
@carmine summit where? i tried and its giving me errors
no
oh yeah
ahhh
right
message.channel.send(attachment).then(m => m.delete({timeout: 5000 }));
every second is 1k
its called miliseconds
@carmine summit where do i put the .size
lol
await is asynchronous right?
message.guild.owner
AT THE END
OF THE
THING
message.guild.channels.cache.filter(m => m.type != "category").size
spoonfeed?
why, guild owner might not be cached use this instead: js guildOwner ? guildOwner#tag : guildMembers#fetch(ownerId).tag
ffs
case 'meme':
fetch( 'https://meme-api.herokuapp.com/gimme' )
.then( async response => {
const meme = await response.json();
const embed = new MessageEmbed()
.setColor( '#EFFF00' )
.setTitle( meme.title )
.setURL( meme.url )
.setImage( meme.url );
message.channel.send( embed );
} );
break;
case 'meme':
fetch( 'https://meme-api.herokuapp.com/gimme' )
.then( async response => {
const meme = await response.json();
const embed = new Discord.MessageEmbed()
.setColor( '#EFFF00' )
.setTitle( meme.title )
.setURL( meme.url )
.setImage( meme.url );
message.channel.send( embed );
} );
break;
@tardy hornet
not working
please someone
Rpg h
how do i see the servers that added my bot?
i want to make a command that will send me the servers that added him
i need help, i dont want to get in the eval stuff
Uh
client.guilds.cache.size
tat will get your bot instanly denied
because of
privacy
thingy
but if you do want? client.guilds.cache.forEach(g => console.log(g.name))
just add a filter that only you can see it
if (message.author.id != 'ur id here') return
oof im stupid
How can I know the reason if someone banned/kicked my bot?
feedback101
Can I change the logo here?
@merry thunder Are you talking your botโs logo?
yeah
Change the profile picture in the application page
How can I know the reason if someone banned/kicked my bot?
@carmine summit You will receive the GUILD_DELETED event through the gateway if so.
Returning the guild id.
Change the profile picture in the application page
@hasty mulch Have another opitons?
And afaik the reason if the user has used one.
@hasty mulch Have another opitons?
@merry thunder Uhhhhhh, @modern sable ?????
Not that i'm aware of
And afaik the reason if the user has used one.
@boreal iron how
wow
I've learned so much

Let us all appreciate the effort that was made.
Huh whatโs your issue with it?
It will return the client object and optionally the reason as string of given by the client.
huh damn I canโt copy on mobile
Gimme a second
To move to the PC
Let god thanks for Windows updates...
Oh I see... that just fetches a ban reason, not a kick reason
hmm
That's because kick's dont come with a Reason by standard.. If you want to save the reason you've gotta use a Database or a JSON file.. but its easier to use a Database
@carmine summit Should be https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=fetchBan
You can use the user ID or object etc.
To fetch the ban.
and it will return the object banInfo https://discord.js.org/#/docs/main/stable/typedef/BanInfo
{
user: <object>,
reason: <string>
}```
The reason is optional, which means you need to check if baninfo.reason is undefined and if so there's no reason.
guild.fetchBan(user).then(baninfo => console.log(baninfo.reason));
@carmine summit
But I'm not sure if "fetchBan" will be transmitted through the gateway before the BOT is banned.
Could probably be possible the BOT will receive the GUILD_DELETED event only.
Not tested this out yet.
its too confusing for me
lemme test it real quick...
Not received any ban event through the gateway, oof.
oh hold on for a second... may I'm missing the right intents
need to check this real quick
oof
ohh meeennnnn
Thought if your BOT is used in less than 100 server priviledged intents are allowed, shouldn't they?
You need to enable them
oh nvm, forgot to enable them
aye, thanks for the hint
idk, no reason given on GUILD_MEMBER_UPDATE event
for kicks even if I enter one
You need to fetch that from audits iirc
oh
yeah got that, GUILD_MEMBER_... events don't contain the reason
You need to fetch that from audits iirc
It would be needed to fetch the latest audit log if anyGUILD_MEMBER_REMOVEevent is been sent through the gateway, aye
its too confusing for me
@carmine summitguild.fetchBan(user).then(baninfo => console.log(baninfo.reason));
How so?
Working on Luibot Premium Roblox features.
https://gyazo.com/7018ccd357b3dec67b767970c40d3898
Users will be able to see live stats about their game etc,

.
Wrong channel for dotposts
lol
Just for the deleted message about Math.random issue:
(quoting the JS docs)
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
And your_array.length will return the array size, to use it as max value to return the keys, you need to do: let max = (your_array.length - 1);
Because array keys will start at 0, not 1
hi, i have an embed with a thumbnail and a main image. i want to know if i can attach a link to the images? the code is simply embeded.set_image(url=img) but i want to be able to click on the image and send the person to another url. is this possible?
no you can't
But you can set an URL for the embed itself, which will turn the title into a link.
ok thanks
What is the new message.mentions.channels.first()
@jovial void discord has an endpoint which gives you the recommended number of shards, so you can get them from there, then arrange them among your processes
This can be done either from a script that launches/controls the processes like a sharding manager, or it can be done from the processes themselves as long as they have a way to identify themselves
For example if process 2 knows that it is number 2, then it can fetch the total and assign itself the latter half
if(args[0] === prefixMention) return message.channel.send('please use the `!` prefix in this command, ty')```
its still sending the command.
when i use the mention
someone
args is usually AFTER your prefix
if you followed the guide, at least
@tardy hornet
without more code we cant tell much
the command is the you kill the user.mention.first()
but if someone use my @mention perfix it will kill the bot
not the user
!command bla bleh
prefix is !
command is command
bla is args[0]
bleh is args[1]
by logic using args[0], it surely wouldnt do anything regarding to prefix cuz its under args
if you are looking for a way to have it respond on a mention this helps https://stackoverflow.com/questions/57115994/how-can-i-get-a-bot-to-respond-to-a-channel-mention
no im not
i want it to kill the user not the bot
oh
i still dont see what you are trying to do
for that i had a video
it gives a role, but it has the code to dtect a mention.
its for discord.js
the snippet your provided doesnt give any info whatsoever
if you want a mention, message comes shipped with a mentions porperty in it which you can use to get the person, so i have no idea what your prefixMention is and how its related to what you want to accomplish
like i said, i need more context
i have a command that for example:
!kill @mention
and when i use the mention prefix, its killing the bot, not the user, because its killing the message.mentions.users.first()
yes cuz thats the first one
ik
if you want to mention the player in discord.js do "<@" + message.author.id + ">"
if message.mentions.first() === me => get second mention
first() returns first mention
if i do @opal plank kill @tardy hornet , the first mention is me, which is returned in first()
instead of using that, get the second mention instead
so just check if the prefix is your mention, if so, grab second mention
if the prefix is the normal prefix, get the first mention
should be as simple as doing that
thats what im trying to do
if i do @opal plank kill @tardy hornet , the first mention is me, which is returned in first()
iirc correctly they are ordered by ID not by mention order
if(client.mentions.users.first().id === client.user.id) => get second mention
else { //use first mention}
im not too sure tbh about the order they come shipped in, so you might be right
what i sent should also work
TLDR
You might expect it to ban @Offender, because that is who you mentioned first. However, the Discord API does not send the mentions in the order they appear; They are sorted by their ID instead.
what do i put in the get second mention part
regexing is rally bad
@opal plank ?
interate in the map and get the second index value
what do i put in the
get second mentionpart
@opal plank







