#development
1 messages · Page 820 of 1
only the first-paged bot lists are good honestly
you put your bot on them and just leave it there
each one contributes backlinks
but the only one i ever get any traffic from is here
as in direct searches
i dont expect anyone to search for my bot on the other lists
It's because it gets on first google result
Other bot lists arent at the top like top.gg
they dont put the effort in to be at the top
they seem to put some botlist on glitch or heroku, and run it till they get fed up of the admin
and 6 months later its gone or merged
and what else gets my goat about them is the constant renaming! they use like .gl or .ml free domains etc and then every month or so the free hoster takes their domain away
so constant faffing with api endpoint names
there was an open source bot list a lot of people forked
that would explain it, i guess this is where those bugs come from
you know theres one list thats almost identical to your appearance?
its like they nicked your CSS
Wow i'd love to see how a bot list works behind the scenes lol
(badly... everything jumps about when hovered over)
yeah kinda weird
@earnest phoenix technically its simple enough, the hard part is running it
Yeah but like
dealing with queries, approving bots etc
like they be like dbl/topgg bad imma make my own
...and then proceeds to copy everything we do lmao
Since i'm learning in class on how to make websites and stuff
I'd love to just look at the code and see how it works
the only thing i'd do different if i made my own list is go for something completely democratised and community run, and not get my hands dirty with bot approvals
but i dont even have time to set that up
hmm
plus it has its own issues, when you think about it
like voting colleges would form, cliques, etc
"you want your bot listed? you need to be on these guys good books as they are the swing vote" etc etc
a bit like how steam greenlight used to be a bit of a shitshow
Well here's one
it's difficult to get a large community to do things right
and how about we dont link to them
oh ye
<a class="navtext" target="_blank" href="<%= response.invite ? response.invite : `https://discordapp.com/oauth2/authorize?client_id=${response.id}&scope=bot&permissions=0` %>">Invite</a>
theres part of the problem
it just plain ignores the url the user puts in
if people copied this source, it would explain the problem, but this ones far worse and strips permissions as well!
it uses the invite and if none is provided, generates one for you
dbl does the same
i cant actually find the broken code in there then
looks like that one works correctly
I want my d.js bot to respond when it's pinged, but i'm not sure how it works
if (msg.content == "@wet crater") {
msg.channel.send('test');
};
I made this but it doesnt really work and doesn't give an error
what error does it give?
none
oh wait there's a different error from a different part of the code
lol
gotta fix that first i guess
@earnest phoenix forgot a \
@unreal cape wait a sec
if (message.content.match(`^<@!?${client.user.id}>`))``` @unreal cape
Yes @earnest phoenix
ah okay thanks @tight plinth
I already solved my problem
Oh okay
but thanks
But discord.js has a .ismentioned so that's better
let me see actually
can't seem to find it
same, but i see people using it
Not sure if the regex is faster than checking message mentions, probably not even a noticeable difference so it doesn't really matter.
it does the same thing anyway, regex
guyz hey
im trying to rebuild npm
when i said i solved the exact errors, a new error came
ffmpeg-binaries
cant install
@unreal cape is it v11 or v12 the mention
?
My bot dies when I exit the command prompt. Is there a solution against this so the bot can run 24/7?
I am on an Ubuntu VPS
tmux/pm2
How?
For Pm2:
install pm2, google how to do it
pm2 start --name "NAME_HERE" "command_to_start_bot_here"
thx so much
if (message.author.id != message.guild.owner.id)
this command in dbl problem? -/
this true
i don't get
in bot rules this command in used ?
if (!value) throw new RangeError('EMBED_FIELD_VALUE');
^
RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty.```how to fix this?
one of ur embed field is empty show embed
@cunning glen wdym
wdm
?
@torn nebula thus error comes when i add
.addField("Game",message.author.presence.activities);```
when i that into the embed the error comes
Change activities to status
maybe author don't have any activities
so it will be null value
Whats the command
...
@earnest phoenix you can just do apt-get install screen
screen is good

what version?
For all those people who find it more convenient to bother you with their question rather than search it for themselves.
@earnest phoenix
But is that for v11 or v12? 
creating channel same in both ig
https://discord.js.org/#/docs/main/master/class/GuildChannelManager?scrollTo=create
its not the same
in v12 its guild.channels.create()
in v11 its guild.createChannel()
😐 in docs it showing
guild.channels.create() in both
i'm sure he knows how to change version in the docs
u try...
stable = 12.2
master = 12
How to check if a user is playing a game or not?
Is this for userinfo?
You can check the status of a user
check activity type == playing
member.user.presence.game
Is this for userinfo?
@zenith terrace yes
member.user.presence.game
@thorny meteor
that is in the v11
and thats not what i meant
i want to check are they playing or not?
My bot can create emoji in ANY server other then one
No error
full Slots Available
Admin permissions
d.js
11v
It Just doesnt create
Responds to eval by which i create
https://discord.js.org/#/docs/main/11.6.2/class/Presence?scrollTo=activities
check activity type == playing
which permission allows the bot to give roles to members? Manage roles?
Mhm
So i made a command called userinfo and the thing is that how do i make it show the game presence of a user (message.author or mentioned user's)
What's the code for it?
Google ?
read the docs, rtd
google
I did but it slightly didn't help...
presence.game
you do know that your answer will not be in plain sight in the docs, right?
@summer torrent that doesn't work at all
presence.game is Object
Hmm lemme check that doc again real quick
${message.author.presence.activities? ${message.author.presence.activities}: "No"}```
when the user is not playing the output is empty
what have i done wrong?
when the user is not playing the output is empty
make a null check
make a null check
@lyric mountain how?
if (message.author.presence == null) return;
@thorny meteor presence.activities is Array
yea
also ^
or if (message.author.presence.activities.length == 0) return;
if you want to send a custom message when there's no activity, just put it where return is located
lenght
@slender thistle you haven't seen anything
Hey, I have a quick question. Does slow mode (for text channels) affect your Discord bot?
It does
@nocturne grove depends
just like users
basically manage messages or channels
just as every user? If it has admin it doesn't affect the bot?
No
no
actually a bot IS an user with additional functions
Oh is manage msg or manage chan's enough for ignoring the slow mode?
if your bot has manage messages perm, no
manage msg
Its enough
@earnest phoenix did u get it fixed yet?
okay so not manage channels, only message messages (or admin)?
admin is the master perm, it overrides anything else
i guess manage messages will not allow your bot to bypass slow-mode
@zenith terrace still working on it wait...
oh, didn't knew it was written there
okay thank you!
^_^
My bot can create emoji in ANY server other then one
No error
full Slots Available
Admin permissions
d.js
11v
It Just doesnt create
Responds to eval by which i create
didn't know about that piece of text either
someone help me :/
@small prairie check its perms
this server i guess?
No
that's weird
Yea
check the serve lr database then
did u try kicking the bot and readding it
I wish I could help you 😦
like owo bot?
wat
what?
ur bot is stoling emotes from other servers
like
is that even legal

Uh
oh
i have been given the task to copy that to other server
and i dont wanna do it manually
i'm lazy AF
I can only think of corrupted db rn
db?
database
u can make a bot to do that
;-;
map from bot ofc
why would i be in this server
i mean asking for help in dev section
it did the first time i ran it
url is valid?
check by logging them
can u add console logs
What does it mean when console.log gives an error called RangeError?
full error...
Hmm... It's the RangeError from the message embed value....
full error
maybe empty fields
No empty fields included
rangeerror can be for more than 1 errors I think

djs v12, I'm trying to add @mention as a prefix foy my bot, but it doesnt work. Why? (https://prnt.sc/rfxexe)
field values can be null
i wouldnt use regex for that
Why does NO ONE use this
wut
@tight plinth try only <@..>
k
Is that if code(useri.presence.activities) correct?(i never used that code before so it might be invalid)
try it and see
(useri is = message.author || message.mentions.users.first()) btw
Lol nano is more comfortable for me
@tight plinth did it work?
message.mentions should be first, else it will never be used, because message.author always exists
with <@${client.user.id> np
(useri is = message.author || message.mentions.users.first())
seems wrong
message.mentions should be first, else it will never be used, because message.author always exists
Ah yeah
Hmm
as for activities i think it returns an object, i dont remember
console.log it or check the docs, and you'll see
K lemme check
@tight plinth if(message.content.startsWith("<@!YOURID>") || message.content.startsWith("<@YOURID>"))
forgot the ! thing
Btw, for V12. Is it better to rewrite the whole coding again
wait
depends on your code, but possibly yes
@quartz kindle and btw wdym by message.mentions to be the first? I got a little confused
oof
something || somethingElse means literally something OR something else
if the first something exists, it will be used
the second something will never be used if the first one exists
message.author always exists
"<@ID>" always exists (its a literal string)
I didn't show the part above but ???
message.guild.emojis.map(e=>{
client.guilds.get("ID").createEmoji(e.url,e.name)
})
this is in d.js v11
Dont tell me if its illegal or anything
I'm using it on a server i'm staff in
Is this right?
basically mapping all emojis of a server to another
@quartz kindle the message.mentions is the first
Hmm
it won't work
ah i know why
Uh?
you cant use .map with async code
because .map will resolve the entire loop instantly and not wait for any promise
same thing with foreach
works
Then what can i use?
they will both fire 50 requests at the same time, making you get rate limited
@quartz kindle so as you were saying the message.mentions to be the first... It's literally the first...
if you have 50 emojis
you have to use a regular for loop, so you can await each request
@earnest phoenix yes and its correct, i said it because you said this before
is there a collection.next thingy?
Or an index
@small prairie js for(let i = 0; i < message.guild.emojis.size; i++) { await client.guilds.get(ID).createEmoji() }
@earnest phoenix field values may not be empty
let some = message.guild.emojis.map(e => e.id === "id").url
<guild>.createEmoji(some)
Anyone know how to change a bot tag?
one of your .addField()s has an empty value for some reason, you have to find out which one
@earnest phoenix There isnt a way
Scroll up @quartz kindle
try console.logging the embed before sending
thats very wrong Sai lol
lol
@quartz kindle after i added that if case (useri.presence.activites) it showed me that error
I dont see any errors
if you remove it then it works?
can i convert it into an array and use array functions?
Yup
then console.log useri.presence.activities
How was that done i forgot?
No no no
See in a collection
there is no way to get from index right?
But i can use index from for loop in array
so can i convert it to array and use?
Does the fields(url,name) remain the same?
@earnest phoenix console.log(useri.presence.activities) before the line where you use them
Oh ok lemme check
@small prairie yes you can
Alright Trying it
you can also try using a for in
i dont know if it works with collections
for(let emoji in message.guild.emojis) {
await something
}```
Erm
SyntaxError: await is only valid in async function
do i need to convert the eval function in code to async? @quartz kindle
create an async function
yes
Oh, Okay
or create an async function inside it
Erm?
@quartz kindle oh and i didn't see... Sorry for asking but wdym "before the line where you use them"
Oh in there?
Ok lemme check
@quartz kindle i did it and it shows nothing besides the same error as before...
async function some(message){
var em=message.guild.emojis.array()
for(let i = 0; i < message.guild.emojis.size; i++) {
await client.guilds.get("ID").createEmoji(em[i].url,em[i].name)
}
}
some(message)
is this correct?
.array()?
i really dont want this video again
@quartz kindle you there?
whats your current code?
You want to see it you mean?
yes
Is that it?
the error is the same as before, and nothing else showed up? it only happens with the userinfo command?
Yes
code doesnt work
no error
async function some(message){
var em=message.guild.emojis.array()
for(let i = 0; i < message.guild.emojis.size; i++) {
await client.guilds.get("468823185882742794").createEmoji(em[i].url,em[i].name)
}
}
some(message)```
@quartz kindle What if i use map but add a timeout?
1s before each request
are you having problem with the bot info command or the emoji list thing? different people
emoji list
try console log the emojis first
@quartz kindle found any solution yet?
Yes
Tim
Reply to me?
var add=0
message.guild.emojis.map(e=>{
add = add + 1000;
const cunter = setTimeout(() => {
client.guilds.get("468823185882742794").createEmoji(e.url,e.name)
},add)
})
something like this
to check if an empty array contains values or not, you do if(array.length)
so your if has to be useri.presence.activities.length
@small prairie that will not work
Length set to nothing?
async function some(message){
var em=message.guild.emojis.array()
for(let i = 0; i < message.guild.emojis.size; i++) {
await client.guilds.get("468823185882742794").createEmoji(em[i].url,em[i].name)
}
}
some(message)```
ternary operator makes it easier
why isnt this working?
what's wrong?
@quartz kindle so like the code needs to be like this?:
+ If (useri.presence.activities.length){
userembed.addField("**Currently playing:**", useri.presence.activities, true)
}```
?
use ternary operator
that will fix the error yes, but you will need to change the actual value of the field
Value to the what?
because that will likely show up as [Object object]
Hmm so the value code needs to be changed to what tho? @quartz kindle
check the docs
Hmm ok
F
async function some(message){
var em=message.guild.emojis.array()
for(let i = 0; i < message.guild.emojis.size; i++) {
await client.guilds.get("468823185882742794").createEmoji(em[i].url,em[i].name)
}
}
some(message)```
@small prairie add console.logs to it or something to see which parts work
Anyone know how to setup two prefix on discord.js?I tried var prefixes = ["prefix1", "prefix2"] but I didn’t work
@earnest phoenix You need to run the prefixes in message.content.start too
both of them
how do you remove the prefix from the command? slice?
@quartz kindle
The code didnt seem to go after await
Its stopped
try await some(message)
SyntaxError: await is only valid in async function
put it inside a code and try it
why are you using eval to code anyway
you can try then btw
@quartz kindle so i changed the if statement's end method to length and it fixed it without changing the value of the Field... Thx for the help at the very least...
its a temp one time command
Why should i edit the code for it
!eval async function some(message){
console.log("2")
var em=message.guild.emojis.array()
for(let i = 0; i < message.guild.emojis.size; i++) {
console.log("y")
await client.guilds.get("468823185882742794").createEmoji(em[i].url,em[i].name) //Stops Here
console.log("h")
}
}
console.log("h")
that last h isnt logged
and the y only logged once
@small prairie which discord bot wrapper are you using?
d.js?
djs
Hmm
v11
use .then dude
Seems suspicious of that code
console.log("2")
var em=message.guild.emojis.array()
for(let i = 0; i < message.guild.emojis.size; i++) {
console.log("y")
await client.guilds.get("468823185882742794").createEmoji(em[i].url,em[i].name).then(()=>{
console.log("Success")
})
console.log("h")
}
}
console.log("h")
some(message)
This?
no
.then where?
client.guilds.get(id).then(guild => { guild.createEmoji(stuff); });
lmao it seemes to be doing that now
i used the command 2 mins ago
and its creating the emojis now
ah rip
stopped after a few
TypeError: client.guilds.get(...).then is not a function
@pale vessel
hey i had this problem a long time ago but how do i make my warn command multi server?
(so the warns are different and not the same on every server)
i didnt use it
i dont know how
i dont?
so nothing
i'm gonna go sleep
@small prairie gn
good day or whatever to you
thats the thing i wanna write it myself i deleted the old one
you need some sort of database to store info
i dont know how to store for different servers
i found the old command
ok listen
i have a warnings.json file
where the warnings are saved
i dont know how to make it for each server
I have a question...
In my userinfo command i want it to show a message.author's and a mentioned user's date of them that they joined the server...
How is it possible?
Is that correct?
@earnest phoenix use SQL db, or some other database
json is easy but not sage
safe*
can you teach me how?
start with sqlite, it's kinda easy to get used to it
js?
yes
you might want a db management tool -> https://sqlitestudio.pl/
@lyric mountain do you have any idea about my problem up there?
i just wanna use the normal json file i have no idea how to use that
i just dont know how to make it so the warn numbers will be different for each server
i just wanna use the normal json file i have no idea how to use that
@earnest phoenix json is not safe nor lightweight, better to use a DB for storing guild configs
but i need some help with it
I think you should watch some tutorial somewhere...
@lyric mountain do you have any idea about my problem up there?
@earnest phoenix the user object has a "joined at" attribute and a getAsMention function
you gotta check the docs for them tho
idk how they are called in js
Hmm lemme check then
but i need some help with it
@earnest phoenix read the first link I sent you
it'll guide you through setting up and using sqlite
@earnest phoenix note that mentions don't work within embeds (they actually show up, but doesn't ping the user)
what should i choose
@earnest phoenix all of them
they are sequential tutorials
Ik... I don't even want them to ping the users lol
That would be annoying if it did ping them
@earnest phoenix
@earnest phoenix just browse the docs for the things you need, d.js is quite well explained in its wiki
I'm doing it right now... I hope i be able to find it in low time...
don't rush, the best bots takes months to be done
been refactoring mine for 4 months and its still not ready lul
astrobot @quartz kindle?
ye
it's one of the most complex looking botbi have ever seen tbh
it pretty much is lol
I hope I can understand atleast 1 word
how to edit a role in v11
knowing astrology would make it easier to understand (as thats the main purpose of the bot)
@torn nebula thx
@quartz kindle you there?
no im not here
Lol
I want my bot check when a mentioned user was joined to the server at...
What do i need to change the code to? @quartz kindle
does anyone know how to solve this error, and any possible causes
at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19)```
show code?
@earnest phoenix message.mentions.members.first()
Oh hmm... Let's check that
hmmm
@quartz kindle thx it worked...
how do you remove permissions from a role? (<role> .edit)
I used that code before but i don't know why it didn't work before...
yes @quartz kindle
it looks like just internet
might not happen on my host
did you whitelist your ip address in atlas?
or are you connecting from a different ip?
How do I get the default role of a guild? Was that removed?
why is v11 so outdated
i feel like im using v12 but im not
my bot is a mess currently
dont think there really is such thing as a default role
It used to bemessage.guild.defaultRolebut that doesn't work anymore. Tim (answer quoted below) is correct.
guild.roles.everyone
Thank you! That's it!
let role = message.guild.roles.get('688090958507933755')
message.channel.overwritePermissions(role, { CONNECT: false })
.then(updated => console.log(`Edited role`))
.catch(console.error);``` there is no error but it does not work
you want to edit the role permissions or the channel permissions?
role"
role.edit(data,reason)
ok but from there, how do you remove permission from a role?
its explained in that link
role.edit({
pemissions: ["SEND_MESSAGES","ATTACH_FILES"]
},reason)
Ya'll Discord.js users are lucky
Ya'll don't have to fight with Reactive programming, while I do
its these add permissions not remove?
its to set them
it doesnt add or remove them, it sets them to exactly that
to add or remove you have to get the current ones, and change them then put them there as a list like that
I really don't understand, then with this discord.js documentation I really have a hard time excuse me (I'm French, it doesn't help either)
you can also use this
message.guild.channels.forEach(async (channel, id))```possible that the text or voice channels in the "for each"
@slate oyster what's a reactive programming?
So in my bot... The command userinfo works but i want it to show the user info as well when you mention someone by thier ID's... What's the code for that?
let User = message.mentions.users.first() || message.guild.members.get(args[0])```
Oh hmm... Lemme try that real quick...
@wicked pivot get method needs to be set to args[0] or user.id?
like this the syntax will be,<prefix>userinfo [@user || id]
Hmm... I did your code... Lemme check if it works...
@wicked pivot it says message.guild.members.get is not a function... I think the get method has been removed or renamed...
Oh wait ik what's it renamed to... Brb
which version are you in?
You mean what is the version of discord.js I'm using?
yes
yes"
It's 12.0.2
i can't help you sorry i'm using v11
Oh anyways... Thx for the help at least...
in v12 its members.cache.get()
I'm tryna use discord.js-commando and I don't know how
have you rtd?
?
have you read the docs?
Ys
So
I have tons of commands not in the commando format
and I dunno how to convert all my args and prefixes and stuff
Have you checked their docs?
iirc with setting up commando you should start in the Registry area of the Docs. But it's been a while since I've used them
instead of thinking about how to "convert" your command to commando, try rewriting it in commando
^^
aka, create it again from scratch, using commando functions and methods
that will help you understand how commando works
Re-write it and follow the docs and you should be good
hi how can i check if a server contains a text channel named "TEST"
at least they're trying to learn
This is true
@royal ravine
maybe check for it?
like you can filter them by name
hmm
what doesn't work
can you maybe send a link >?
1 sec
message.guild.channels.find(c => c.name === '') ??
cannot read property channels of undefined
why
why did u fucking tell 'em
we're not supposed to spoon feed
.... I would like to point out that depending on what exactly he's trying to do that is some what of an answer
But there are things that he could be attempting to do which would make it incomplete
🤷🏻♂️
it's still spoon feeding
K
var channelNAME = message.channel.name
message.channel.send(channelNAME)
Chan[ServerName] = channelNAME;
fs.writeFileSync("./C.json", JSON.stringify(Chan));
if () //i wanna check if there is a channel named Chan[ServerName] and send a message there
message.channel.send("The theme of today is " + "`"+Themes[theme]+"`")
that was not spoonfeeding
i am writing the channelname where the command was send to a json file
var channelNAME = message.channel.name
message.channel.send(channelNAME)
Chan[ServerName] = channelNAME;
fs.writeFileSync("./C.json", JSON.stringify(Chan));
if () //i wanna check if there is a channel named Chan[ServerName] and send a message there
message.channel.send("The theme of today is " + ""+Themes[theme]+"")```
and i wanna checn every intervall if the name in the json exist in tje server
and then send a message in that channel
so you would be creating a setInterval
how can i use the if function to check
that is already in a interval
thats the content
@royal ravine are you on v11 or v12?
12 i think
check the package.json if you need
yeh 12
i have this in my json
{"Bot Test Server":"tes1"}
and i wanna check if that "tes1" is in the server
tes1 is a text channel
to find a channel in v12 its <guild>.channels.cache.find(channel => channel.name === NAME)
are you searching for a specific channel per guild or just a specific channel?
ok got it
every intervall i wanna check if that text channel still exists
and when it does i wanna send a messgae
why would you do that?
its better to save the channel ID not the name
when it doesn't its just gonna console.log
because the channel name can change
hmm
yeah
okay willchange that
are you making it to a message will be sent on an inverval?
or when a command is used?
ok
so now it saves the channel id in the json
{"Bot Test Server":"688123488524683288"}
like that
okay
ok, do you plan to do this for every guild or just the test server?
i get guild is not defined
Message and interval should never be said in the same sentence unless you're explaining why it's bad
send your code
if (message.content.startsWith(prefix + "START"))
{
var interval = setInterval (function () {
var theme = Math.floor(Math.random() * Themes.length);
var ServerName = message.guild.id
var channelID = message.channel.id
Chan[ServerName] = channelID;
fs.writeFileSync("./C.json", JSON.stringify(Chan));
if (guild.channels.cache.find(channel => channel.name === Chan[ServerName])){
message.channel.send("The theme of today is " + "`"+Themes[theme]+"`")
}
//write to .json
ServerConfig[ServerName] = Themes[theme];
fs.writeFileSync("./S.json", JSON.stringify(ServerConfig));
//write to .json
//}
}, 1 * 1000); //1000 = 1 sec
}
if (message.content.startsWith(prefix + "START"))
{
var interval = setInterval (function () {
var theme = Math.floor(Math.random() * Themes.length);
var ServerName = message.guild.id
var channelID = message.channel.id
Chan[ServerName] = channelID;
fs.writeFileSync("./C.json", JSON.stringify(Chan));
if (guild.channels.cache.find(channel => channel.name === Chan[ServerName])){
message.channel.send("The theme of today is " + ""+Themes[theme]+"")
}
//write to .json
ServerConfig[ServerName] = Themes[theme];
fs.writeFileSync("./S.json", JSON.stringify(ServerConfig));
//write to .json
//}
}, 1 * 1000); //1000 = 1 sec
}```
I gotchu
oh yeh i see
first, work on a command to set the data
uum
then in the main file, you can work on a function to keep updating it
first, work on a command to set the data
@crimson vapor like if it is enabled ?
okay
so the command will only set the data for the json, instead of making an interval which will reset when the bot goes offline
you can do that in a different file
jup
adn then check if that command is enabled in a server ?
and then ceck the channel id if it stil exists ?
one sec, im editing your code so I can better explain what you would be doing
ah thanks
Hi, i have a problem, i use shortand if for do a variable that save a value or other value
let roleOwner = membersWithRoleOwner == [] ? "Vacio" : membersWithRoleOwner.join('\n');
membersWithRoleOwner is a array that should have all the users with that role
but one role dont have any member so i do that condition
but the console returns nothing
any solution?
if the array is empty or no
membersWithRoleOwner.length
alright
I cannot help with the function on the index.js but the command would be just defining the data
@quartz kindle so umm... Remember the help i asked?
How can i set my userinfo command to show info of the user that's mentioned by their ID's...?
should i save everything in one json file ?
up to you
so the serverid channel id and if the function is enabled ?
first, define theme, then define serverID and channelID, and set Chan[serverID] = channelID, then write to the json. then you can do the message.channel.send @royal ravine
@earnest phoenix how do you get the user now?
yeh
when you are done, please show your code
and how to check if the channel exists ?
@quartz kindle wdym?
You mean like message.author and message.mentions.users.first()?
here is fine I think
okay
@earnest phoenix yes, so basically you have to add another option in that line
And that option is what I'm asking for...
What's the code for it?
@lyric mountain https://developers.redhat.com/blog/2017/06/30/5-things-to-know-about-reactive-programming/
Sorry to take so long on reply
do you parse message arguments in any way?
ie: args = message.content.split() or something
Yea?
then you use args[0] to first check if it exists, then check if its a number, then check if the number is a user id
And then how's the code done for that?
whats your discord.js version again?
12.0.2
@crimson vapor if (message.content.startsWith(prefix + "START"))
{
var interval = setInterval (function () {
var theme = Math.floor(Math.random() * Themes.length);
var serverID = message.guild.id
var channelID = message.channel.id
Chan[serverID] = channelID;
fs.writeFileSync("./C.json", JSON.stringify(Chan));
if (message.guild.channels.cache.find(channel => channel.id === Chan[serverID])){
message.channel.send("The theme of today is " + "`"+Themes[theme]+"`")
}
else
{
console.log("Channel not found!")
}
}, 1 * 1000); //1000 = 1 sec
}
thats what i have now
just what you said that when the bot goes offline it doesnt work anymroe
yeah so I made something different
am I allowed to show or would it be spoonfeeding?
let user;
if(message.mentions.users.size) {
user = message.mentions.users.first()
} else if(args[0] && !isNaN(args[0])) {
user = client.users.cache.get(args[0])
// or if the user is not cached, you have to do this instead
user = client.users.fetch(args[0]).catch(e => null)
} else {
user = message.author
}```
if (message.content.startsWith(prefix + "START")) {
var theme = Math.floor(Math.random() * Themes.length);
var sID = message.guild.id
var cID = message.channel.id
Chan[sID] = cID;
fs.writeFileSync("./C.json", JSON.stringify(Chan));
message.channel.send("The theme of today is " + "" + Themes[theme] + "")
}``` this is what I made
hmm
so you define the themem serverid channelid
then save it to json with ServerID:ChannelID
yes
and then message
@quartz kindle hmm imma try that...
hmm yeh i have kinda the same now i think
you need a function on a different file that sends the theme
everything works fine now but i just have to fix that when to bot goes offline it will just work again
so like a loop where it checks
yeah kinda
hmm okay i wil try that
@royal ravine accept friend
@quartz kindle tysm for the help... It worked...
Hello. For my bot I'm trying to show a cpu usage, however when I run the command, it says NaN bytes.
Let me show you.
https://prnt.sc/rg126r
.addField(CPU usage:, ${process.cpuUsage().heapUsed / 1024 / 1024} bytes., true)
Is this in js or c#?
js.
Cpu usage is not in bytes though that is ram 
Ah.
So how would I fix it so that one, it shows the usage, and two change bytes to something else?
That would be process.memoryUsage()
yes but cpu usage isn't measured in bytes
and what's it measured in?
have a guess
the cpu usage is measured in clock ticks or seconds, => a percentage
ahh
i think you cant
Filter client.guilds.cache for if the guild has that user
Hello. I am new to discord bot developing and have some quistions. I am trying to get my bot online but keep hitting the same error. Could anyone explain what I am doing wrong?
if it isnt too hard could you please @ me when you repsond because I have this server muted
am I just really dumb?
yes
I figured
what was the problem
error at the bottom.
new discord.client --> new Discord.client
trying to get it online
@dapper hill capital D in Discord.client
U forgot the caps
yes
im really dumb
also you'll wanna change bot.on stuff to client.on
Yea u defined it as client so it has to be changed from bot to client
Same error?
yes
Did you install the discord.js package?
Oof
One question.. did you save after changing it
no IU did not save
one moment
ya still doesnt work after save let me install discord.js
Ok
you didn't even install d.js
So i made a command called ping for to say:
Latency is {latency}ms
API Latency is {API latency}ms```
All works but it shows `NaNms` in front of the `API Latency is`... What's wrong here?
think about it for a moment
Hmm
@earnest phoenix what app name in mobile?
@radiant parcel Termux
Thank you 🥳🙂
Np
So... Solution anybody?
the result of your math floor returns NaN
Yup
Which NaN is aka not a number... But what's wrong there tho?
why do you need to floor in the first place
Umm... Just to get the result of how much of latency there is... Is there another solution to that?
do you even know what flooring a number means
Bruh moment
@earnest phoenix
(`Pong! (took: ${msg.createdTimestamp - message.createdTimestamp}ms)`)
This is what I have
exactly that
but don't spoonfeed code
let them figure it out themselves
Hmm... Lemme try that real quick
does guild.create run when somebody dm's my bot?
It only fires when it joins a guild I think
Okay
DM's trigger the message event
oh damn
@zenith terrace oh wait a minute... The one with the first code of my ping command is fine but what about the API Latency one?
The issue is the second code... After that first one...
Hmm... Imma check that real quick...
stop doing operations without knowing what they actually do
you saw it somewhere and now you're copypasting it
Hmmmm, message.guild in a dm return null, but discord api docs say guild create runs on a dm too https://discordapp.com/developers/docs/topics/gateway#guild-create
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
there's no need to floor or round since it's a time measurement for latency, milliseconds, it won't have a decimal
where tf does it say that @vestal star
I misinterpreted it ¯_(ツ)_/¯
Guild create only works when the bot joins a server
ok
Yeah that's what I thought as well
any dpy people?
@tasks.loop(seconds=1)
async def check_stream_change(self):
g: discord.Guild
r: discord.Role
m: discord.Member
c: discord.TextChannel
async for g in self.bot.fetch_guilds():
await g.fetch_roles()
if self.cfg.data[g.id]["streamer-channel"] == 0 or \
self.cfg.data[g.id]["streamer-role"] == 0:
continue
c = g.get_channel(self.cfg.data[g.id]["streamer-channel"])
print(self.cfg.data[g.id]["streamer-role"])
r = g.get_role(self.cfg.data[g.id]["streamer-role"])
for m in r.members:
tw = self.db.lookup_gaming_record(m.id)[4]
if tw is None: continue
msg: str = self.cfg.data[g.id]["streamer-message"]
u: twitch.helix.User = self.helix.user(tw)
if m.id not in self.online.keys():
self.online[m.id] = u.is_live
else:
print(u.is_live)
print(u.display_name)
print(m.display_name)
print("---")
if u.is_live and not self.online[m.id]:
await c.send(msg)
self.online[m.id] = u.is_live
ERROR:discord.ext.tasks:Internal background task failed.
Traceback (most recent call last):
File "D:\repos\AnsuraBot\venv\lib\site-packages\discord\ext\tasks\__init__.py", line 73, in _loop
await self.coro(*args, **kwargs)
File "D:\repos\AnsuraBot\cogs\streamer.py", line 43, in check_stream_change
for m in r.members:
AttributeError: 'NoneType' object has no attribute 'members'
but the role has me as a member
so i am much confused
r is null
but why?
i had it print the role id
and the role id matches
r = g.get_role(self.cfg.data[g.id]["streamer-role"])
im assuming its this line?
Idk py
self.cfg.data[g.id]["streamer-role"] returns an integer id
Because it seems to not be finding the role?
but thats what im asking tho
its a valid role
i can ping it by id
i had it print self.cfg.data[g.id]["streamer-role"] before it tried to grab the role
Is the guild object the same guild object as it should be
ye. the config file is a yaml hold on
604823602973376522:
streamer-channel: 0
streamer-message: '%user% is streaming'
streamer-role: 0
643870039660953612:
streamer-channel: 643870039660953615
streamer-message: '%user% is streaming'
streamer-role: 682056617269002321
it skips the first guild
cuz nothing is set
I ment are you getting passed the guild object you expect
wym?
it fetches the id from the config
that it gets from bot.fetch_guilds
similar code to my (working) config initialization code
You are overriding g several times
Also I don't advise doing lots of ws requests in a for loop