#development
1 messages ยท Page 1126 of 1
Anyone familiar with Roslyn's CSharpScript? Trying to pass in a global variable but I can't seem to reference it
it doesnt seem to be working
For example, I am passing in a SocketCommandContext as context in the optional [globals: param]
(ERROR) (1,1): error CS0103: The name 'context' does not exist in the current context
it doesnt seem to be working
@mild flower you have to put your math code INSIDE thetry {/*/stuff/*/}
evaluate(qtrim)
} catch (err){
message.channel.send('Please enter a valid math problem.')
};```
but its not workin
does your bot turn off upon the error?
yes
"evaluate"
but its not workin
show an image
what is evaluate
"evaluate"
i told himhow to use mathjs
of code or error?
both
and what it does when you run the command
^
Error: Undefined symbol lmao```
bruh
that's because you used smth else
it is a problem with your own code
you can literally just freaking do:
case "math":
if (!args[1]) {
message.reply("bruh enter smth");
} else {
evaluate(message.content.substring(`${prefix}math `.length));
}
@mild flower allow me to explain
message.content returns the stuff that the user types
undefined symbol lmao
dude what the fuck is this
smth from mathjs library
LmAo
now shut up
what's evaluate
IT'S A FUNCTION
mathjs?
IN THE LIBRARY
it's big
substring works too
bruh
Example:
User: <prefix>math potato
message.content will give <prefix>math potato
and the substring just cuts out <prefix>math
and then you run evaluate() on what it returns
where did you define evaluate?
args.slice(1).join(' ')
where did you define evaluate?
@pale vessel
bro
no it does matter
import {evaluate} = require("mathjs");
thank you
it automatically throws when i insert algebra
bruh
...
Lmao
remove qmultiply and the other q<smth>
Dice the pro
it is just unnecessary stuff
tim 2.0
You should substring the prefix out in args tho
code913 gay 10000000.0 brain 1.5
it is substringed
Where from?
You should substring the prefix out in args tho
he already did
1.5 brains sounds amazing
O
and used switches
I just have the 1
Oh snap
I am Tim MK2
the two o in your name are two biggo brains just zoomed out
When he gets sick of us I'll be the replacement jajajajajajaja
Let's be real, no one can replace tim
ohw ait
np
Yeah tru
google intensifies
it doesnt recognize the math problem now
bruh
oh
What's the error tho
i literallly explained you
bruh
Omg
can only me explain him cuz your solution just caused another error tbh
forgot to remove that
x)
you only need to substring the prefix and the math word out from the whole message
by this:
cus im grabbing from arg[1]
var substringed = message.content.substring(`${prefix}math `);
message.reply(evaluate(substringed));
This is a sentence
args[1] = "is"
Lmao
oof
bruh
period
mine didn't work?
dude substring and slice only accepts numbers
can you temporarily add me to your glitch project
not on glitch
dude substring and slice only accepts numbers
oh yeah
add .length after `
forgot that you need to put .length after the string
bruh
nice meme
-development
hah imagine
Period
@mild flower maybe try figure smth out on your own
because
thats all i want to know
:l
show the code then
and three people explained you one guy even spoonfeeded you but you still have errors :/
code, chill
evaluate(variable)
} catch (err){
message.channel.send('Please enter a valid math problem.')
};```
and what's variable?
i wanted that if someone uses a !warn cmd in any server it should show in my server channel client.on('-warn', async (guild) => { const channel = client.channels.cache.find( ); channel.send(`cmd got used in **${guild.name}** This server is epic!`); });
can u help
What is -warn
try/catch will still throw errors. just they are handled
yep
-warn is a cmd
Did you make a -warn event?
client.ws.emit('-warn')
galaxy brain for making a new event for every command
Jajajajajaja
I'm sure people have done it
@surreal notch just do bot.channels.cache.get(text channel id).send(stuff)
@mild flower
Try catch will only catch whats in try {}
So if the code in your catch {} block errors it will still be thrown
yep
try doing this
try {
// code
} catch (e) {
console.log(e)
}
e
try {
throw new Error()
} catch (e) {
console.log(e)
}
throw new Error()
is good idea use discord.js-commando? ill use it and idk if is a good idea
Its just a command handler
if you find it easier to use than making your own
then use it
^
if you find it easier to use than making your own
@dire obsidian if you follow the above and use the package then you are a verified non-dev
command handlers are the easiest thing in the world
sigh
that's not entirely true
using command handlers through packages is terrible
no.
Thats a big statement
*using a command-handler package is terrible
@earnest phoenix Thats the most condescending asshole statement ever
tututu, well some of the things is allready configred in commando
ok purge my messages
@dire obsidian Use whatever you're comfortable with
@earnest phoenix Thats the most condescending ***hole statement ever
@delicate zephyr please stop swearing it makes me uncomfortable
Well telling someone that not doing something themselves makes then a non-dev is wrong and entirely objective. Learn to think before you speak :)
ugh
anyway
when a person use a particular cmd how to get server invite of that serveer
then why are you using a library then? JUST make your own
Doesn't djs kinda support commando anyway?
you can use fetchInvites()
Yes
I'm sure there's some rather high profile bots using commando ๐คทโโ๏ธ
like xiao
discordjs-command was made entirely for discord.js
well only is discord.js with some others things extra
when a person use a particular cmd how to get server invite of that serveer
@surreal notch you create an invite bro
the bot might not have the permission to
@.Ultron if you dont wanna create an invite then read audit logs and grab one
@surreal notch You can either fetch existing invites or create a new one
can someone give me an example of a bulk delete event?
yep
frik
in what? dsp?
too late me
@delicate zephyr How to make new one
@surreal notch should be msg.guild.createInvite()
Not the command itself. What would cause the event to triggered (by someone else)?
@delicate zephyr
message.channel.createinvite({
maxAge : 0,
maxUses: 10000000000000000
}).then(invite =>{
//do stuff to the invite by referencing the variable invite
})
oops
accidental shift enter
can't only bots trigger that event?
@faint prism only bots can trigger that event
and the ban bulk delete doesnt trigger it either
well looks the default things you canget of commando
Interesting. So it would mean another bot is bulk deleting msgs if I get that event?
Yes
Gotcha, ty!
@surreal notch
message.channel.createinvite({
maxAge : 0,
maxUses: 10000000000000000
}).then(invite =>{
//do stuff to the invite by referencing the variable invite
})
if maxAge is zero then the invite will never expire
@earnest phoenix dont spoonfeed
if maxUses is zero then there is no max limit
oh
smh
@earnest phoenix dont spoonfeed
@delicate zephyr i only showed him the function
smh
*method
no
idk me not THAT good at JS
You fed him the exact code

aa!eval msg
even with that .then lmao
^
maybe i m not gonna use that
good choice
I had no idea C# has a scripting eval(string) via the Roslyn api ๐
and be a good boi
that's bold coming from you
Now my C# bot can have an eval like everyone else lol
I had no idea C# has a scripting eval(string) via the Roslyn api ๐
no doubt you didn't know about an API
@surreal notch You can read more here:
https://discord.js.org/#/docs/main/stable/class/GuildChannel?scrollTo=createInvite
i sometimes hate APIs
ok
also
CSharpScript.EvaluateAsync<string>(inputString).Result; = eval(inputString) in JS
The adverts
i almost always redirect users to my source

Sharing repos isn't adverting
if they beg for spoonfeeding
i didnt
He didnt
beg
but you're a good boi Ultron
You just spoonfed him answers for no reason


Oof ok my bad leave it
damn that x didn't work
Also, you seem to be picking fights with people. Really no point
You should try and teach them
i do
i'm just going to lurk honestly
yea
tests in prod
does anyone have stats api
Also, google that exact question
define "stats"
Like bot stats?
"statistics"

Doesn't dbl have a stats api somewhere?
they meant command usage thingies probably
server stats, displays how many people are in the server, how many are online etc.
what kind of stats is what i meant
Parsing json parses it into an object readable in JS,
for example:
{
"message": "hello"
}
turns into
{
message: "hello"
}
But the latter is an object ^ in a running JS process, rather than the first. Which is a string.
you don't need an API for that?
@pale vessel i wanna do that
Parsing json parses it into an object readable in JS,
for example:{ "message": "hello" }turns into
{ message: "hello" }
so it just removes the " around message??? js is weird
guys u need uptime?
no
kk
a better example would be ```js
obj = {
a:10,
b:20
}
JSON.stringify(obj) = '{"a":10,"b":20}'
JSON.parse('{"a":10,"b":20}') = { a:10, b:20 }
@earnest phoenix br mano
But the latter is an object ^ in a running JS process, rather than the first. Which is a string.
so JSON can be used for storing and sending objects in a human-readable format and parsing converts it into normal JS objects which the language can read and use?
yeah. Pretty much
cool
๐
just learnt smth
also wtf is your pfp Auger
someone help me to leave my bot on
json is the portable version of an object, because an object cannot be sent across the network nor shared with other processes
use a vps @earnest phoenix
but you can convert it into a string, and sent the string
@earnest phoenix don't turn it off
ok now i get it Timmmmmmmmmmmmm
i've told you that about 3 times
and use a process manager
@earnest phoenix
Imagine playing a game and clicking "Save". That's essentially serializing objects to a file (abet not in JSON). And Parsing when you reload
ok
Ok guys I tried hard, but I can't create a changing status someone pls help me i readed whole doc didn;t helped
@misty sigil like
JSON can be used for saving and sending around objects in a file and parsing converts it into normal objects that can be used in JS
like?
Ok guys I tried hard, but I can't create a changing status someone pls help me i readed whole doc didn;t helped
you freaking update it every <smth> seconds
use a vps @earnest phoenix
@misty sigil how do I do that
just look up vps hosting for bot or something lmfao
Ok guys I tried hard, but I can't create a changing status someone pls help me i readed whole doc didn;t helped
Djs?
me can
setinterval
don't send your shitty source again please
Oof
ow i feel like i've lost all my braincells
so stop
after a set amount of time run the second function which changes the status then again then at the last roll back to the start function
@pale vessel wait did he send it again
Changing status, so i need easy tutorial
i hope not
or help
yes
use setInterval
and how do i set multiple status
ok
and iterate through them
like this:
function first() {
//set the status
//then use setINterval to goto the second
}
function second() {
//set the different status
//then use setInterval to goto the first
}
eh, I'd use a for loop
you should call first() after your bot is ready
const status = ["status1", "status2"]
setInterval(function(){
client.user.setStatus(status[randomNumber])
},60000)
Ok
basically that
huh still same thing happening
its more psuedocode than actual code you still need to make the statuses and the numbers
Ok Ima try
just have a counter and reset it when it hits the limit
--- Truncated to last 15 messages, set outputCapture to 'all' to see more ---
(
use Math.random() for random
Does anyone know a bot that in a channel it would delete messages if it didnโt start with a certain word?
and multiple it by the array list's count and then floor it
That seems too specific for there to be a bot for it
now it haves no status
just make your own lmao
really weird
you need to set it first
const status = ["Hello", "Test"]
It won't have a status the first minute with that code
setInterval(function(){
client.user.setStatus(status[randomNumber])
},60000)
Which really isn't a problem, or you can set it once outside the interval if you want
F
ReferenceError: randomNumber is not defined
and theres definiently a stackoverflow question about that btw
Lol
lmaoo
god every single fucking day i get closer to leaving
use it
ReferenceError: putYourVariableHereDontJustCopyAndPaste is not defined
Y no wrk?
its online
Hello, I need help because if I use this string I have an error:
return console.log("Credenziali non valide!".red);
} ```
Error: 'return' outside the function
But why?
there is nothing to return
ok
Do you have a language in mind @cunning ocean ?
no
return 10 // error
function bla() {
return 10 // ok
}
Thanks
I have this coding that I want to use
if(!msg.content.startsWith("word") && msg.channel.id === "channel id")return message.delete()
and https://discord.js.org for documentation
I know
look, how about, uh, i make the bot
Can you?
you need to fill in some things
why ppl wont understand that, pseudo code
I made it
Iโm very new to coding but I know I need to fill it
return 10 // error
function bla() {
return 10 // ok
}
@quartz kindle ok, but not work, the error not change
Iโm very new to coding but I know I need to fill it
Learn a coding language BEFORE making an discord bot
the error explains what the issue is @worn zephyr
you can't use return outside of a function
How to code a bot with repl.it
you just dump your stuff on there DONE they are literally just giving you a computer read https://discordjs.guide to learn how to make a bot
^ and DONT start with making a bot
Ok
you can but you need some braincells
@misty sigil I couldn't find free vps hosting for bot. could you give me a link in my private
Vps hosting isn't free
@earnest phoenix there isn't free hosting.
I tried to find free tyres for my bike, couldn't find any
Vps hosting isn't free
repl.it kinda allows but they are like the BEST CHEAPEST AWESOMEST BEST FREE TRIAL service
sigh
if you want long term hosting then its going to cost money
me gonna use the donations for my bot to buy a better host on repl.it
@misty sigil I have no money to host. but I have the bot ready
then host on repl
because
not long term no
they're dumb enough to allow ping services
why would you make a bot if you didn't do research about keeping it online
repl.it is a good temp host
who wants to live with 512 mb of storage anyways i'll switch to self-hosting soon
doesn't make u dumb tho
soon
@earnest phoenix and it'll get big like glitch did eventually and they're start banning them
Bandwidth and server space isnt free...
who wants to live with 512 mb of storage anyways i'll switch to self-hosting soon
they said they're not going to ban them but who knows
so I think my bot will never go online
i mean unless they're making enough money from their premium then idk
Honestly, glitch probably makes a buttload of money due to how they did it
you need to ping it
let a lot of users use the platform, then tell them to pay
:(
ping services are free
what is "ping" for?
to keep it alive
Hey, I've recently updated my Schema for mongoose.
How can I update all existing files in the database.
an example of a free ping site?@misty sigil ๐ ๐
Wouldn't you just .find() and then edit each one?
I just removed and added a few things.
uptime robot
Woo, will all the current data stay though?
@pine aspen you'd have to use: ```js
mongoose.updateMany({ thing: { $set: { foo: "bar" } } })
for adding
and removing you should just do
const documents = await mongoose.find({})
documents.forEach(async doc => {
delete doc.foo
await doc.save()
})
ok
Ay I was half right.
wait what does the foo stand for?
@pine aspen what do you wanna set autorole to
its just variable placeholders
its not functional code
Oh. so it doesn't matter?
Does mongodb have migrations?
``Guilds.updateMany({ autoRole: { $set: { : [] } } })`
So if I do something like this it does work?
Guilds.updateMany({}, { autoRole: { $set: [] } })
Yeah that's fine.
// Because we're looking for {} it will return every document in the collection
const documents = await mongoose.find({})
// Iterate through the documents
documents.forEach(async doc => {
// Set autorole to array
doc.autorole = []
// Delete foo from doc (EG { foo: "bar" } ==> {}
delete doc.foo
// Save document
await doc.save()
})
ive added commenting
No problem!
Thanks a bunch!
Guys u are legends
u helped me a lot
Luke u helped me a lot
Woo Helped me a lot

it dont' detect when i am mentions users
if (!message.mentions.users.first()){
}else{
}
I mean such as if i type !!ma -> reply Hello
but if !!ma @earnest phoenixz -> reply Hi
Luke for a boolean it's just true/false right?
Wait
it is true n false in most of languages, and some languages print them as 0 n 1
I think my schema might be outdated on my server.
@pine aspen yea, true and false
๐
Eval works: 
+eval "\x40\x4D\x61\x67\x6E\x65\x73\x23\x38\x35\x38\x33 \x69\x73 \x67\x61\x79\njk lel"
o-one file b-bot?
user files
he meant lines
user files?
oh
um so like how do i even start
What?
Developing.
I recommend watching handy youtube videos.
That's how I learnt.
oh okay ty dad
dad pog
Make sure to use a coding keyboard 
?
tf is a coding keyboard
I know bot developers
thats the stack overflow one.
programmer socks too
Hello
whelp, im not a programmer
I know bot devs
i dont have coding soks
awh man feels bad
Programmer socks v5
Look up SOCKS5 
probably why you dont have developer role
u mean documents, syn?
<Collection>.find().limit(1000);
holy crap, this is stuff people actually google
also, how do people reccomend keyboards without a numpad as the best programming keyboard
number row is closer to fingers??
i dont use the numpad cuz idk how to make it actually work
like
one time it works, the other time it doesn't
arrow keys
yeah, still dont work lmao
Numpad are redundant bulk|| (that I can't stop using)|| prove me wrong
numpad is faster if you need to type more than 3 or 4 numbers
My desktop keyboard doesn't have a numpad either
numpad is faster if you need to type more than 3 or 4 numbers
@solemn latch Citation needed
true
If i just use find({ blacklist: null })
if im typing 100 i use standard number keys
if im typing 1027 ill use numpad.
it really depends on the numbers.
actually i write like 8 numbers easily withlut numpad
i also use a my desktop calculator a lot
so i guess its just normal for me to switch
spreadsheets numpads amazing too
๐คทโโ๏ธ
LETS GOOOOOOOO!!!!
What
well, ill be back when thats gone
@solemn latch it's gone
ty
what
have you destroyed the control/command key on your keyboard yet
NO BUT MY CAPS IS BROKEN
A guy had been fucking asking me one singlr command code I gave him
But I use command handler he doesn't
He just copy pasted that in index.js and said code is not working
And then I tell him he has to change code how he uses command and he had been spamming my DMS saying how how how and his code is
if(msg.content === "ping") {msg.channel.send('pong')}
He uses this and says his bot is super cool
first time?
I mean
Hi
Sounds like you need to tell him to "Read the docs, kthx bye"
mute
whoever id DMing you
I blocked him XD
if its someone from this server, probably should inform a mod
if its someone from this server, probably should inform a mod
@solemn latch
No he isn't
its not really relevant to this channel den
So i've got this message collector for my music command, the thing is that, the sPass and timerP variables are saved in the collect event but they're converted back to what they were before the collect event, this happens in the end event
https://hastebin.com/ipadigucey.js
my postgres running on docker suddenly changed password?
not changed
rather its giving me password authentication failed for user
it was running
I blocked him XD
@delicate shore why block
I need teh code still give me it my first time nabs
@digital ibex he is here @solemn latch
?
U need to tell your porblem
just report him or something
We can't Spoonfeed
teh thing sis
which thing?
what library u using?
What dictionary u using?
how to see that how much server in it that my bot
discord.js
how to see my bot states I mean
I told him guys
what
what do u mean "states"
I mean pl do this !states and bto states come @digital ibex
youd have to make that yourself
i've never heard of it
That's a command. Implemented by the developer
So i've got this message collector for my music command, the thing is that, the
sPassandtimerPvariables are saved in the collect event but they're converted back to what they were before the collect event, this happens in theendevent
https://hastebin.com/ipadigucey.js
Any ideas?
.-.
It allows you to interface with the API
No I copy and past
What i want
oof
we dont provide copy paste code
pgamer, you're really not helping ๐ฉ
What i want
@haughty igloo Import discord.js properly
what command hadler I never heard it?
Bruh
you've not installed it
bruh wtf
Well it can't find it. Check your directories and file paths
you guys wree going this site and I go this the otehr site
npm I discord.js --save
why do people still use the --save
npm I discord.js --save
@delicate shore
glitch is shit
@delicate shore Where to write
I usa npm install py.js
I have premium membership
?!
why is glitch shit?
glitch is overpriced and blocks additional ports
what is glitch
Yes
It costs to host now and everyone is angry ||ive never used glitch||
you use glitch as a host gamer, ofc you'd find it shit
I use glitch
its not a host
But I'm shifting to a VPS
waht
PLEASE HELP
still shit
i need because bot offlined
Wym
glitch is maybe fine for hosting a Website but there it ends
aaaaaaaaa @delicate shore said this is command if(command === "servers") {
msg.channel.send(${client.guilds.cache.size})} but no work
@haughty igloo use glitch if u want, its not bad. everyone here is just saying stuff without any context
Bruhhh
Officially it depends on the use case really.
i need help
You haven't defined
Pls help
@sudden geyser
Yes this is Lite
wot
ups wrong ping
well i mean, in madara's case, it seems the best fit
@haughty igloo what kind of help?
Glitch is meant for small websites, but can also run Node apps. If you're just running a small bot, it'll probably be fine (I did it myself too), but still not the right tool for the job.
open the console and write npm i discord,js
@lusty lintel send your ping command code here
@dire obsidian
No
@dire obsidian where is console?
tools/console
i have discord.js module
error says you dont
have you ran npm install discord.js ?
then open console
can you show your package json
have you ran
npm install discord.js?
^
it'd be pnpm* on glitch
ahh this broooo
what
no
tools
Where is it?
you run it in the terminal/console
push the button called tools
show us your package.json file pls
and pres console
oh god
have discord.js
THIS BROOO, LOGS SAY NO
And then some lol
so many libs
So i've got this message collector for my music command, the thing is that, the sPass and timerP variables are saved in the collect event but they're converted back to what they were before the collect event, this happens in the end event
https://hastebin.com/ipadigucey.js
<Help lol>
did you just download everything
maybe need help on dm
Madara try setting the name field of the package json to something like osmanli-bot
rather than Osmanli Bot, I've had issues with that in the past
Bro bot name Osmanlฤฑ
still not how it should look
you guys need to chill man, i feel like most people here when starting out was just retarded
no, im that
like retarded, and ur wayyy up
well dm me, maybe i can explain you, i used glitch on my first bots
alright now try opening your console and typing refresh
ah yes
where is console?
lol
config.json that is that
1 min
I've no idea from that screenshot, I don't code on mobile. Another option would be to click on your watch.json file and typing something to "refresh" it sort of
@dire obsidian config.json where is it?
you make a bot and submit it on dbl
I need help still @digital ibex
look at #502193464054644737 for info
Ty
try typing one character then deleting it so it's still valid json. I'm not sure if it'll force a refresh but you can try it
pls help
what do command guild with zipd o
Lets thx @sudden geyser
what
well no
I added my bot to top.gg i still have to wait
@earnest phoenix it takes 3-4 weeks at the moment
Is this kinda good? Im new to bot developing
ah yes
what
i love the pornhub-logo command man
@sudden geyser working thx bro
Oops
Alr removed
How gay am I
make an embed
-3%
i love the pornhub-logo command man
@digital ibex
Porhub comment is better XD
The help manual is okay but I think having the command (!command name here) on the left is easier to read
LMAO
99%
Add an eval command 
compiled languages 
Is this better
pornhub comment is just stupid imo

compiled languages :PepeHands:
@sudden geyser I have an eval in my C# bot
pornhub comment is just stupid imo
@digital ibex
Me: Broken inside as I worked hard on it
youre using dbd?
isn't C# interpreted or run in a VM
Discord bot developer
isn't C# interpreted or run in a VM
@sudden geyser
well its just my opinion
C# is a compiled language. It uses JIT though.
They added a C# scripting api with Roslyn
Is this better
@earnest phoenix better
Ok????
compiled = languages like C, Java, Rust, etc.
interpreted = languages like python, javascript, etc.
I see interpreted to bytecode and run in a VM
Il try using embed
const embed = new Discord.MessageEmbed()
now can kill me
It compiles to an intermediary language that the JIT further compiles on targeted arch and platform
@sudden geyser
Ah so it's similar to Java
Better now?
Maybe, JVM != JIT iirc
It outperforms Java
they both have similar principles imo. I know JVM is not the same as JIT
need me

How do you guys recommend "scheduling" timed mutes
so that they unmute on time
I want it to work even if my bot restarts, so a setTimeout may not work
(JavaScript btw)
Integrate your service with Discord โ whether it's a bot or a game or whatever your wildest imagination can come up with.
Pass in an embed object
use a database
How would my bot process know when to unmute tho
will it query the database on an interval or smth?
store the time when the mute should end
when the bot restarts, calculate the ms left to the end and set a new timer with that length
there probably is
thats how every bot does it
there isn't
there is no way, none that i know of anyways
i've looked quite a bit into this too
someone else with Discord API issues?
nope
(900ms ping)
Yes earlier today
I'm at 48ms
I had that issue recently though.
It was sitting at 500ms for some reason
@digital ibex fukcing fixed
?
teh thing
const LoginFind = Login.findOne({
credenziali: loginanswer
})
if(!LoginFind) {
return;
}```
If the credentials isn't in the database not stop the action, but continue... Pls help me


