#development
1 messages · Page 741 of 1
C# or C++
mostly C languages tbh
like godot, love2d, etc
triple A titles are mostly cpp
ye
like right now i'm working on a brick breaker like game on python with turtle
performance matters a lot in a game, that's kinda the main reason lol
yh
unity is good but it's still not quite there with c#
i mean in python i would use Pygame
it's not as performant as UE for example
UE is so many leagues better than unity it's kind of absurd
but for basic games it does fine
how do I make my own screenshot app, i saw my friend using one that puts the pic under his website
for what
like basically instantly
idkk
just use sharex
i mean you could do it in python
you make a screenshot app by google how do i make a screenshot app and get redirected to sharex
your friend is also probably using sharex with a custom uploader
Hello world.
hosit
console.log('hello back');
print(“Wassup?”)
this is epic
(node:185) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit
@sick cloud make it randomize number placement every click
@atomic quarry it's saying that you might get a memory leak
Is there a way to fix it?
Uuuhhh the last time I tried that I fcked up my code and had to cmd+z alot
you are using client.on 11 times?
oh! i guess you learned javascript and came back!
Welcome to why you don't copy and paste
@earnest phoenix wdym 
We told him to go away and learn js
lol
After his 'bot code'
but use a if statement
Was just copy and pasted that we found the original tutorial of
^
sugma

printf requires a format string @white cobalt i believe
Hey, i have small problem with my discord bot (.js) im running on Linux
I have command what plays music and it worked before, but now but just ignores that he should play music and then about 1 minute later leave server
No errors btw does anyone know?
what
@earnest phoenix it's a school thing smh
How to properly ask technical questions, and demonstrate that you've done your research and are willing to learn on your own.
@sick cloud is it electron?
o
Yo on d.js, is there any way to get a regular status and not the custom status? I'm trying to see the user's activity.type, but it's undefined as it gets the custom status on d.js master
this custom status thing is breaking almost all libs since statuses are now supposed to be interpreted as lists/arrays lol
lol
But I can make a request myself and get the data myself then still right?
I'll look into it but thanks
// User's message will be deleted after 1500ms
handler.onCommand("?t").deleteInvocation(1500).then((message) => {
message.channel.send(@everyone [T] Training! Come to the Training Center for a chane at a Promotion!! https://www.roblox.com/games/4368863292/Mano-County-Training-Center);
});
would that work?
Wow
@amber fractal its seems to be a websocket event so I think you might need to modify the library
yeah I suppose
there's been an issue open on discord api docs for ages to make the api return the presence in rest requests
but discord devs are discord devs
so fuck the community we need money
@zealous veldt
-m @little totem Spamming emoji in #development | 12 hours
🤐 Muted uchiha_Itamar#9302 (@little totem)
how do i send friend request as the bot in discord.js
you don't
you can't
okay. so no way to friend my own bot?
not anymore
oof
@earnest phoenix thats a very high effort meme
Question: in discord.js, i am using fs.readdir to run files in my designated "./commands" folder. I have tried using fs.writefile within these commands, but it never seems to write to that file, whereas it does within my main 'index.js' file.
is there a way i can run fs.writefile within my command files? I can provide my code if needed
i guess i will provide code, sorry for the lengthy explanation
This is in my index.js file, which reads my directory ('./commands'), and allows the commands (and aliases) to be used later
fs.readdir(`./commands/`, (err, files) => {
if(err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js");
if(jsfile.length <= 0) {
console.log(`\x1b[31m`,"[LOGS] Couldn't find Commands!");
}
jsfile.forEach((f, i) => {
let pull = require(`./commands/${f}`);
bot.commands.set(pull.config.name, pull);
pull.config.aliases.forEach(alias => {
bot.aliases.set(alias, pull.config.name);
});
});
});
Further in my code, it runs this command in the bot.on(message) event. (bot = client)
if(!message.content.startsWith(prefix)) return;
let commandfile = bot.commands.get(command.slice(prefix.length)) || bot.commands.get(bot.aliases.get(command.slice(prefix.length)));
if(commandfile) commandfile.run(bot, message, arguments);
This method allows me to run commands in a seperate folder for orginization, and is less messy.
Now, when the command runs, for some reason, using fs.writefile() to save data to a json file doesnt work
write file method, which works in my main file, but not in the command files:
fs.writeFile("../quotes.json", JSON.stringify(quotes), (err) => {
if (err) console.log(err);
});
apologies for the lengthy code and explanation, i try to be thorough, but let me know if you have a question
${message.author.avatarURL} what am i doing wrong here
not even the author username works
async?
and yea how shall i get the files from stuffs like kick.js ban.js etc
http://prntscr.com/q7g24z must be in #starboard
2 min??????
ofc
if (command === "eval") {
if(message.author.id !== botConfigs.ownerID) return;
let args = message.content.split(' ').splice(1).join(' ');
let codemsg = args;
args;
console.log('executed: ', codemsg);
message.reply("**You've executed the following code -->** ```" + codemsg + "```");
};``` i got this but it does not execute `args`
args is an array
how to fix
maybe split it by ' ' using Array#join
where?
oh wait
?
let codemsg = args;
args; // remove this```
if (command === "eval") {
if(message.author.id !== botConfigs.ownerID) return;
let args = message.content.split(' ').splice(1).join(' ');
let codemsg = args;
console.log('executed: ', codemsg);
message.reply("**You've executed the following code -->** ```" + codemsg + "```");
};```
also what does the console say when you executed the command
come to #commands
Do i have to change anything
ye ofc
but where and how and what
so i have to do args()
eval(args)?
yes

gonna do ok
preference if you wanna add semicolons
no problem 
and im gonna do the eval later on the executed thing
Now it works!
yay?
is there a way to view the last message in the console
wdym "last message"
like you saw youve executed blahblahblah, i want there the log of the command
so i did console.log(test)
ik ''
then it will show up the output in the message
in the `````````
maybe it store it in a variable before your command code and fetch it from there?
message.channel.send(fetch.console) this or something?
wuw
nvm
Move to #memes-and-media @surreal sage
hmmm
How what
did not work
copy and paste
like this? if (command === "eval") { if(message.author.id !== botConfigs.ownerID) return; let args = message.content.split(' ').splice(1).join(' '); let codemsg = args; console.log('executed: ', codemsg); message.reply("**You've executed the following code -->**"); message.channel.send('```js' + codemsg + '```'); eval(args); };
Add a linebreak after ```js
gonna tr
shows error
/home/container/bot.js:576 message.channel.send('```js\' + ^^^^^^^^^^^ SyntaxError: Invalid or unexpected token at Module._compile (internal/modules/cjs/loader.js:721:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules
@sudden geyser
You're escaping the end of a string
How do I add a letter (k) to a number?
So 6 will be 6k
But a linebreak has a n after the backslash
Just do num + "k"
but you should know it's in that range
message.channel.send('```js\n' + codemsg + '```');``` this?
message.channel.send('js\n' + codemsg + '');
ops
try it out and see
anyone knows how to get the code out of a txt file on the web? some http request
message.mentions.users.first().username stopped working for some reason
It was working before
did you mention anyone
then what's specifically not working? are you getting an error?
it's hard to help when having no context. Maybe it's something bigger than just that (e.g. problems with another file). Source code?
It happens to all the commands that has this
let user = message.mentions.users.first() || message.author;
And when i try to input user.username it doesn’t return anything
then it may be something like your listener file. If you console.log(user) do you get a user instance?
Yes i do
source code?
anyone knows how to delete the source message of a command?
User:
!test
Bot: *removes "!test"* You just said test!```
message.delete()
function
it works...
so ()
but not in this server
(node:11) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
thats the problem here
no prob in other server.
jsut fixed
Yes
just*
Maybe your bot is missing permissions in this server
it does
so it can't delete
(node:11) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions

i just said it before you said maybe missing perms
what will happen if i do proccess.exit() on a vps
the process wil exit..
and does not kill everything?
it kills the process
im gonna try..
if you dont have a process manager or something to restart it, it wont restart it
lol try catch
does anyone actually use that
yeah nothing special
executed: process.exit()
[Pterodactyl Daemon] Server marked as OFF
[Pterodactyl Daemon] ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon] Exit Code: 0
[Pterodactyl Daemon] Out of Memory: false
[Pterodactyl Daemon] Error Response:
[Pterodactyl Daemon] Server process detected as entering a crashed state; rebooting.
[Pterodactyl Daemon] Server marked as STARTING
[Pterodactyl Daemon] Checking size of server data directory...
[Pterodactyl Daemon] Disk Usage: 21M / 1000M
[Pterodactyl Daemon] Ensuring file permissions.
[Pterodactyl Daemon] Running server preflight.
[Pterodactyl Daemon] Starting server container.
:/home/container$ node bot
[Pterodactyl Daemon] Server marked as ON
who wouldve thought
just restarts with my vps
just restarts my vps*
anyone knows how to refresh the status like: 1 min servers 1 min votes and repeat
client.on("ready", async function() {
if (botConfigs.statusType === "PLAYING" || botConfigs.statusType === "WATCHING" || botConfigs.statusType === "LISTENING") {
client.user.setActivity(botConfigs.gameStatus, { type: botConfigs.statusType });
} else {
client.user.setActivity(botConfigs.gameStatus, { type: "PLAYING" });
}
});``` this is my code for it rn
read up on setInterval
@sudden geyser there are multiple commands that has the problem
I tried it myself (on master) and it worked as expected. If you're getting a user instance, it's doing what's expected.
i have made an bot but how to give commands
@compact raft uh
u listen for a message
Filter the message if it starts with something
Then execute a certain action
That’s how
Also which oak
lan
that one in discord application so
Just made nothing advance
only bot who just look a bot do nothing
right
anyone has a guide or video to do a bugreport command/script?
and learn a programming lang
@surreal sage you could get a args then send an args in another channel
@surreal sage Make it yourself lol
simple one
ok sigh okookokokoko
Copy Pasta
@surreal sage just grab a say command and tweak it
y ik
ok
well i thought about webhooks
I don't get it
let UserIDrp = Object.keys(db.server.configs.rolePers[User.id]);
db.server.configs.rolePers[User.id] = UserIDrp.splice(i,1);
"rolePers": {
"266162824529707008": [
"0"
]
}
That 0 was a role id before it got spliced
I know that splice modifies it, and I want to remove it.
I don’t get it isn’t a question
What’s dB
which
¯_(ツ)_/¯
mm ok
Either way, my question is, why does that splice just change it to 0, I want the object gone.
And yes, db = database
I don’t understand your code either
^
avoid using json files as a database
json works for me
my bot id ```javascript
647689857166213134
} else if (addRemove.toLowerCase() === 'remove') {
if (!db.server.configs.rolePers) {
db.server.configs.rolePers = {};
}
if (!db.server.configs.rolePers[User.id]) {
db.server.configs.rolePers[User.id] = [];
}
if (db.server.configs.rolePers[User.id]) {
for (i = 0; i < Object.keys(db.server.configs.rolePers[User.id]).length; i++) {
if (db.server.configs.rolePers[User.id][i] === role.id) {
let UserIDrp = Object.keys(db.server.configs.rolePers[User.id]);
db.server.configs.rolePers[User.id] = UserIDrp.splice(i,1);
//delete db.server.configs.rolePers[User.id][i];
fse.writeFile(`./databases/${message.guild.id}.json`, JSON.stringify(db, null, 2))
return message.reply(`Successfully removed ${role.name} as a permanent role from ${User.tag}`);
}
}
}
Perhaps that will help understanding my code?
json files, or files in general, aren't meant to be used as a database
Json has data corruption, slowness as its getting bigger and so many problems
what is the best method to do a music bot in js
Well, it works for me.
It wont in some point xd
@earnest phoenix lavalink?
Use sqlite
And besides, I do have backups in both the code and locally, in case anything corrupts.
ok
ytdlcore?
or you can do the standard but buggy ffmpeg and opus
There tutorials on yt I think
lavalink is probably best
Either way, my question isn't about the database, it's why splicing the last object just changes it to 0.
The original array is blank until a role persist is added using a command.
im on phone so i can't be bothered to rewrite this, see https://discordapp.com/channels/264445053596991498/272764566411149314/579050783601852436
So let's say, role ids
gonna check lavalink
@summer acorn yeah learn some JS tbh
I've aleready do one witth ytdl-core but it sucks
what are you trying to do ? @summer acorn
I am literally using JS, and I checked that, but nothing on there said anything about the last object
I am trying to completely empty the array
learn it
can you read @summer acorn
db.server.configs.rolePers[User.id] = UserIDrp.splice(i,1);
the array has 1 element, which then gets removed, the array will be []
What are you even trying to do
An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned.
So
An array containing the deleted elements.
what are you trying to do
^^^^^^^^
db.server.configs.rolePers[User.id] = An array containing the deleted elements.
I want to remove the objects from the array
fp
I don't want the deleted elements
yeah
then dont add that equal
simple right?
its simple as this: UserIDrp.splice(i,1);
Oh wait, I think I see...
Well, I've not really used arrays to modify stuff, all the much. I mainly use objects like
"userid": {
"item1": {
"itemthing1": "data",
"itemthing2": "data"
},
"item2": {
"itemthing1": "data",
"itemthing2": "data"
}
}
So yeah, I am used to using delete to delete stuff
ok?
And I am pretty slow in my head, plus partly blind sometimes. So sorry if I caused any frustration.
Thanks for the help though.
no problem
how to disable a error log by a certain cmd
Glitch eww
@earnest phoenix do you have a lavalink server running
good idea
lavalink client is not a lavalink server
no i dont have
so i need one
well you need to
yes
how to disable a error log by a certain cmd
hi
though a lavalink server plus a discord bot is probably too heavy for glitch
lavalink alone depends on JRE and hits 600mb+ ram usage
you're annoying
for a certain*
stop repeating your question
stop skipping me
i want to know about this bot owner / developer
bitch u aint in a queue lol
so i go to the classic but buggy ffmpeg opus
i think
We skip you because you're a fucking copy pasta kid who wants everything spoonfed
Stop asking
CDeveloper stepped in queue.
Lavalink is the best option, in my opinion
if you can try to find native audio manipulation libs
but I don't have money for a vps
so...
I'm forced to use glitch
(I can't self host)
i avoid lavalink cause it's really badly optimized and slow as hell
is there a way to disable error logs or move them into a file?
but its rather stable imo
so
ytdl-core?
even if it sucks
and i avoid using ffmpeg because every time you need to run a new instance of the same base code
@surreal sage be more specific, what kind of error and why does those errors appear
ytdl core is just a package to get info on a youtube video
Well there is no error, If there comes a error i dont want it to show up or move the error into a file
you still need something to process the data from ytdl core
@surreal sage give ur bot admin in ur server
no not that
ok
if there comes a error, i dont want it to show up
@surreal sage try to look for where the error is happening, and wrap the code involved in a try...catch
discord.js-lavalink gut
don't avoid errors and don't try catch them
instead do your best to prevent them
you could intercept all using process.on unhandledRejection method @surreal sage
hence why i said to check if you can do x before doing x
and do it yourself
try {
code
}
catch(e) {
console.log(e)
}
possibly happens when you try to DM someone without DMs on
or when you try to modify server/channel settings without enough perms
h
you're costing your memory because you're lazy instead of fixing the error
npm install discord.js ffmpeg-binaries opusscript ytdl-core --save
found this on a tutorial
try catch clauses put a lot more load than an if check
well, I'm gonna do that
Cant you do anything?
k newproblem
the bot assume that themusic is finished but it never started
joining-disconnecting the voice channel
fuck
either use markdown or html, i'm guessing the parser has a stroke and filters out some stuff @surreal sage
I gave up
ytdl-core still broken?
but still in github repo
but there tons of broken stuff
How to ban players from your bot.
Step 1. Create a json (any name)
Step 2. Go to your main bot file (javascript only)
Step 3. Addconst banlist = require("./(name).json")
Step 4. Add these things to your command:
if (message.author.id !== banlist[users]) then {
return;
} else {
<code>
}
};```
Step 5. Add your banned user ids in to the json with a title of "users"
Step 6. See if this is almost the same:
```js
const Discord = require('discord.js');
const client = new Discord.Client();
const banlist = require("./banlist.json");
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {
if (msg.content === 'ping') {
if (message.author.id !== banlist[users]) then {
return
} else {
msg.reply('Pong!');
}
};
});
client.login('token');``` *Not sure if works*
i typed that all on my own god damnit
yeah ik
optimizitation
yes if you make banlist.json like this
{
"users": [
]
}```
users: ["id1, "id2"]
}```
or like mine
and make banlist.users into banlist[users]
changed it
oh my the syntax errors
probably do this banlist[users].forEach(u => { if (u === message.author.id) return })
there's no way to break a foreach loop (except erroring)
im gonna make a test cmd for this
probably do this ```
blacklisted = false;
banlist[users].forEach(u => {
if (u === message.author.id) blaclisted = true
})
if (blacklisted === true) return
fixed code
1-2 weeks
~1 week
Ooh
superhero or just,
- Make a banlist file with a users prop listing all users
- Use a some loop in your if condition
what
i have some nice features i think, well eval is a big one
@restive furnace could just do banlist.users.includes(id)
which returns a bool
no need to do a for each
also not to mention that code is flawed anyways
A
Can anyone help me in making vote info webhook
ask your question
https://oliy.is-just-a.dev/rk443m_2262.png this is very inefficient.
you'll be looping over unnecessary stuff if it's found
I'm not spoonfeeding, I'm saying this is not the way you want to do that
Imma be real with you I've never done [][] and have no idea what [][] does
2d array
ooooh
I dont think you can do it like that in js
I know that's how you do it in java
Well .includes would probably be the best
help if(client.user.guildCreate) then { SyntaxError: Unexpected token { at Module._compile (internal/modules/cjs/loader.js:721:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:829:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) < Error
Script: js if(client.user.guildCreate) then { role.setColor('#FF1493') };
do you do js
bruh
because it isnt lua.
what
oh
You wrote 99% of it in js and 1% of it in lua
If only
that whole snippet is just a bunch of bad practices
yeah im a roblox dev too
idk
creates a guild
Is enmap good for server config?
It doesnt do anything.
Per*
That's not how you listen for events
its client.guildCreate
https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics I suggest this
That's not even a thing
That's not how events work
you're confusing guildCreate and createGuild

oh lol
createGuild is a method used for creating guilds
@amber fractal please use <>
Guild Create
guildCreate is an event for when a guild is sent through the ws but it's not completed
I like the embed tho
Lots of space on mobile
It works, it wont do anything.
bots can create guilds if their guild count is under 10
would disabling the messagereactionadd event affect reaction collectors?
that may also be helpful
well it doesnt change the role color of the bot
You should probably learn js syntax first
cough
would disabling the messagereactionadd event affect reaction collectors?
i assume not
as collectors have their own oncollect event
but just in cade
nvm
Im getting this error JSONObject["track"] not a string. code: https://pastebin.com/FQtNJt3Y, and the getSongs: https://pastebin.com/sSaccGpJ , client.manager2 : https://pastebin.com/ch23ywY7 (running on latest lavalink)
is there a way if your bot joins a server his role color automaticlys change?
Listen to the guild create event
@surreal sage @topaz fjord no they cannot
rip
you can create a role on the guild the bot was added to and change that color
but
yeah...
you cant change the bots colour
yeah rip
because its its highest role
but whats this then? http://prntscr.com/q7kc8p
to change the color of a role
but the bot cannot change its own role, as its its highest role
and noone can edit their highest role
or if their top role is colorless
what would be the classes or id?
make them yourself or find them yourself
lol
I don't think so
cuz mine does not load fully
what are shards???
something that you don't really need until your bot has 2.5k servers
what does it do?
well basically its something to help both discord and your bot deal with larger amounts of messages/commands etc
ok
it's to reduce load one connected client gets
instead you get to split the client into shards
each shard is on a specific guild and that guild is distinctive to one shard only
+help
is it possible to retrieve the console and put it in a embed?
k sorry
Im not sure, but many of guys did it.
i found this: ```js
(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4)
}
var blob = new Blob([data], {type: 'text/json'}),
e = document.createEvent('MouseEvents'),
a = document.createElement('a')
a.download = filename
a.href = window.URL.createObjectURL(blob)
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':')
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)
a.dispatchEvent(e)
}
})(console)```
can this work?
nope
It is possible if u use shell plugin, or save logs into a file.
Yeah, but not the way hes trying
@surreal sage youre trying to approach this the wrong way
You want to send the eval result to the message, right?
You dont console.log it and then somehow get it from the logs... You simply log it AND send it as a message
nvm
.addField("Propriétaire du serveur", message.guild.fetchMember(message.guild.owner.user).then(owner => {owner.tag})) is this line correct for caching the owner and putting his tag in the embed ??
please mention me if you have a solution
ps : it's a bot made with discord.js
most people will only see the actual mention if they share a server with them
your answer is for whom because if it's for me I don't understand
if you mention someone who doesnt share a server with the user who called the command, it will apear like @frosty sinew instead of the actual tag e.g @cobalt mesa
most of the time ^^
But he's not even doing that
He wants to display the tag as username#discriminator
Anyway
I don't think that's right
What was my past convo
Not sure what exactly you get when checking the owner if uncached in discord.js
But it'll probably just be undefined
Which means that you can't use it to fetch the owner either
guilds have an ownerID property
Which will always be there
You can use that to fetch the owner
i got an error when i execute my command and the owner is uncached
^ You can fetch the user object with the ID, which then won't be undefined
and I was told that with fetchMember I could get the owner
Checking the docs, you could apperently even use the guild itself aswell
as discord.js userResolvable thing will change it to the owner of the guild
sorry i'm french i don't understand
You can use <Guild>.ownerID to get the guild's owner ID
Which you can use to fetch the User object so you have access to all info
but with the id I can't get the tag? Nope ?
When you fetched the member, you have access to all info including the tag
ah ok
and suddenly it would be necessary that I put what in the field of the embed ??
to fetch the user outside the embed how do i do please
what version of djs are you using
11.5.1
fetching is different in versions
how to store a value into a variable
Ok, quick, newbie question, whenever I try to get the presence.status
The idle shows as idle
The dnd shows as dnd
The online shows as idle, why?
(discord.js)
Because it doesn't
For some reason on my bot it does
is anyone else having issues re-connecting their bot?
Can you show us the code you are using for that?
You could have disabled certain events that would prevent those from updating
Other than that, who knows what happens if Discord is being poopy and they timeout
Discord isn't entirely stable atm so that could be a reason
I mean, I separated each file, this one shouldn’t have anything that could prevent it from updating
to fetch the user outside the embed how do i do please
😅 just a variable ??
It was doing that even before the downtime
Disabling ws events is done in client options
But if you're not familiar with any of those it probably means you didn't do that
Yep, it’s the first time I’m using the “presence”
He's talking about modifying client options
I mean you can test again
Oh, then no
Does it work now
can i add a presence to a bot from a game?
Let me test it one se
@surreal sage no
rip
If it works fine now, there's a very good chance that the presence update just timed out and caused it not to be updated before
But that's breaking ToS
yeah...
nope
ik
oof
Doubt that will work
I made a log showing that they give a role how I do it writes the role he received.
#readthedocs
I don't see the room.
@earnest phoenix #memes-and-media
ok ;v
Creative thinking I see
there are no errors if there are no lines of code
heyo
there are no errors if there are no lines of code
This could potentially be someone’s motto
how would I add a opt in opt out command of a map
opt = db.fetch(`opt_${person.id}`)
while (opt === 0) {
person = XD[Math.floor(Math.random() * XD.length)];
console.log(person.id)
if (opt === null || opt === 1) {
break;
}
}```
im trying to add a command that rerolls if opt === 0
for refrense 0 === opt out
1 === opt in
There is no need to
wdym
But it has a chance
Of pinging someone opted
ping me a response I feel like crap so I’m going to sleep
message.mentions.users.first().<property> doesn't return anything
Is there any better way of capitalizing the first character of a string in js?
I would of used String#slice over String#substr
@valid frigate I don't think there is a problem
I think he wants suggestions to make it better
oh well
https://joshtronic.com/2016/02/14/how-to-capitalize-the-first-letter-in-a-string-in-javascript/
const upper = lower.replace(/^\w/, c => c.toUpperCase());
google moment
google moment
peace
@vital lark i defined it as
let user = message.mentions.users.first() || message.author
hmm
Using regex sounds redundant/slower
The way it was done already gets the job done well (unless you want to make a function out of it)
same website
const lower = 'this is an entirely lowercase string';
const upper = lower.charAt(0).toUpperCase() + lower.substring(1);
efficient, simple, no regex
oh shit i forgot no spoonfeeding
lol
nah it'll probably be fine (except those mod eyes
)
they probably dont care because i gave advice and thats the end of it
can you do nested mongo db queries
wym
Wait, you werent doing it programmatically before? 
somehow I can check if the bot is running or not? because i would get such a small status.bot web where you can see it running or not and pinging etc just the question is that it can be requested somehow
discord js
when i type node bot.js
the terminal say's
internal/modules/cjs/loader.js:964
throw err;
^
Error: Cannot find module 'winston'
Require stack:
- H:\DISCORD BOT\GULAM-BOT\bot.js
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:961:17)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:854:27)[39m
[90m at Module.require (internal/modules/cjs/loader.js:1023:19)[39m
[90m at require (internal/modules/cjs/helpers.js:72:18)[39m
at Object.<anonymous> (H:\DISCORD BOT\GULAM-BOT\bot.js:2:14)
[90m at Module._compile (internal/modules/cjs/loader.js:1128:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:983:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:891:14)[39m
[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: [ [3
well what's winston?
Winston
var Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
can i remove that's
it doesn't know what winston is
ohh
after removed
internal/modules/cjs/loader.js:1184
throw err;
^
SyntaxError: H:\DISCORD BOT\GULAM-BOT\auth.json: Unexpected token � in JSON at position 3
at parse (<anonymous>)
[90m at Object.Module._extensions..json (internal/modules/cjs/loader.js:1181:22)[39m
[90m at Module.load (internal/modules/cjs/loader.js:983:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:891:14)[39m
[90m at Module.require (internal/modules/cjs/loader.js:1023:19)[39m
[90m at require (internal/modules/cjs/helpers.js:72:18)[39m
at Object.<anonymous> (H:\DISCORD BOT\GULAM-BOT\bot.js:3:12)
[90m at Module._compile (internal/modules/cjs/loader.js:1128:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:983:32)[39m
but token is Correct
Is this discord.js?
yeah
How can I make a webhook to know who voted my bot
Give us the json
Without the token
I mean, replace it with BOT_TOKEN or something like this
@compact raft show me how you did it
@compact raft give the ss of ur json
@opal halo it's a problem in auth.json
package.json
{
"name": "GULAM-BOT",
"version": "1.0.0",
"description": "This is My First Bot",
"main": "bot.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "AKRAM DESHWALI",
"license": "ISC",
"dependencies": {
"discord.io": "https://github.com/woor/discord.io/tarball/gateway_v6",
"discord.js": "^11.5.1"
}
}
I said auth.json
@compact raft auth.json
Not package.json
Lol
{
“token”: "NjQ3Njg5ODU3MTY2MjEzMTM0.XeupPw.hZ8S4Lhfjp0r95j-xxxxxxxxxx"
}
no I meant like const Bot =
The commas are wrong
no
@compact raft yes use "
you have to specify the bot
@opal halo don't get involved in this if you don't know what to do
i do
@wheat jolt🤣
The error doesn't say anything about the bot
@opal halou don't
It's an unexpected token in auth.js
The commas were wrong
The only accepted commas in .json s are these: " "
Yup
@compact raft
after use this @earnest phoenix
logger.remove(logger.transports.Console);
^
ReferenceError: logger is not defined
This is an error from your .js
Hm
@wheat jolt lol full code 🤣
somehow I can check if the bot is running or not? because i would get such a small status.bot web where you can see it running or not and pinging etc just the question is that it can be requested somehow
discord.js
you removed the logger part with winston thing remember?
@earnest phoenix
var Discord = require('discord.io');
//var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
token: auth.token,
autorun: true
});
bot.on('ready', function (evt) {
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
// Our bot needs to know if it will execute a command
// It will listen for messages that will start with `!`
if (message.substring(0, 1) == '!') {
var args = message.substring(1).split(' ');
var cmd = args[0];
args = args.splice(1);
switch(cmd) {
// !ping
case 'hi':
bot.sendMessage({
to: channelID,
message: 'Hello!'
});
break;
// Just add any case commands if you want to..
}
}
});
if copy pasting then u get those errors
it should be discord.js lmao
discord.io is a thing
O
LOL
anyone can provide full code
@restive furnace oh
shouldn't be different than d.js?
@compact raft -_-
i want to make my bot to send dm to who i said
well what is winston supposed to be?
@compact raftu copy pasted the code?
lol
oh
@earnest phoenix YEah
he said this was discord.js
🥴
not .io
var Discord = require('discord.io');
var logger = require('winston');
var auth = require('./auth.json');
// Configure logger settings
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console, {
colorize: true
});
logger.level = 'debug';
// Initialize Discord Bot
var bot = new Discord.Client({
token: auth.token,
autorun: true
});
bot.on('ready', function (evt) {
logger.info('Connected');
logger.info('Logged in as: ');
logger.info(bot.username + ' - (' + bot.id + ')');
});
bot.on('message', function (user, userID, channelID, message, evt) {
// Our bot needs to know if it will execute a command
// It will listen for messages that will start with `!`
if (message.substring(0, 1) == '!') {
var args = message.substring(1).split(' ');
var cmd = args[0];
args = args.splice(1);
switch(cmd) {
// !ping
case 'hi':
bot.sendMessage({
to: channelID,
message: 'Hello!'
});
break;
// Just add any case commands if you want to..
}
}
});
🙏
Try @compact raft
@opal halo then he didn't knew what he was saying
@wheat jolt which line u fixed?
uncomment the line where he defined logger
I realize that
Oh
@wheat jolt
using this
getting this error
internal/modules/cjs/loader.js:964
throw err;
^
Error: Cannot find module 'winston'
Require stack:
- H:\DISCORD BOT\GULAM-BOT\bot.js
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:961:17)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:854:27)[39m
[90m at Module.require (internal/modules/cjs/loader.js:1023:19)[39m
[90m at require (internal/modules/cjs/helpers.js:72:18)[39m
at Object.<anonymous> (H:\DISCORD BOT\GULAM-BOT\bot.js:2:14)
[90m at Module._compile (internal/modules/cjs/loader.js:1128:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:983:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:891:14)[39m
[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: [ [32m'H:\\DISCORD BOT\\GULAM-BOT\\bot.js'[39m ]
}
before: js //var logger = require('winston');
after: js var logger = require('winston');
Do
@wheat jolt installing
@earnest phoenix which lang
@restive furnace js
if js i couldnt get it working
node.js*
@restive furnace why?
idk

@wheat jolt
{"message":"Connected","level":"info"}
{"message":"Logged in as: ","level":"info"}
{"message":"Gulam - (647689857166213134)","level":"info"}
know what
Bot cannot be made on js w/out node.js so here js means node.js
your bot works
Yeas Bot is now Online
@restive furnace help me in webhook
But when i say hi the bot didn't respond
@wheat jolt yes online but that command is not worked
let me given permission
not here
what do you mean
OFFLINE AGAIN
you don't need to use caps
it can be fixed
did it threw an error?
@earnest phoenix about your status page, you should use statuspage.io or make yourself a status page system where you can change the bot's status, add incidents or whatever you want
@wheat jolt you can make a code for it too
as I said, he can make himself a statuspage system
or
also, @earnest phoenix you have Client.status
which will give you the status of your Discord bot
@earnest phoenix thans my bot is now Online in my server and respond as coading
k
Now can that bot Online Everytime?
vps <