#development
1 messages · Page 744 of 1
@modest maple to add to what you said earlier, ive once used a combination of json and mysql together. mysql 5.7+ and mariadb 10 support it. basically, you have standard mysql tables and you can put user defined data into a json data type in a column, it natively supports searching json with a search path
i used that in a commercial program to allow for the subscriber to add their own table 'columns', as far as they were concerned they were adding custom tables to the db, but obviously we didnt actually let them add tables or columns. if done right, you can even add indexes on json subparts
its basically a more correct and scalable way to do the antipattern of "entity-attribute-value"
@green kestrel Huh, can i help you with that project you have for today?
I suppose you're going to write it in C or C++?
already writing it in C++, yes
i have a whole raft of existing module loader code im going to reuse
Oh, awesome, can i join?
got some suggestions?
hmm, perhaps at a later date. once i have a module loading facility, it may be nice to bring on other team members
right now, the only place to put code is in the core, and thats icky
after xmas would be a good time 🙂
I know C and Assembly + some knowledge of ELF and PE
So, it's up to you to decide if i can join
do you know what my bot does?
No
But i just love low-level stuff way too much
im currently modularising the javascript interpreter and the infobot routines
it integrates duktape so that it can be extended by channel owners
You're getting me to orgasm with these words, Duktape is my fav JS engine
i think i just found a dev friend 😄 😄
i'd definitely welcome the help, but i do need to get the code in a nicer state first
you can see how it is atm on github
Oh, okay
wont be long, i code fast 😄
Thanks, i'll be waiting
sent you an invite to my server, and a friend request
ok np
how to do custom prefix with a sql db
channel.getGuild().ban(mentioned.get(0).getUser(), Integer.parseInt(""), "").queue();```
This should work?
Try it and find out
Bonjour/bonsoir,
j'aurai besoin de vous pour une erreur que je ne comprends pas.
J'ai restart mon vps (mon bot était déjà dessus) et depuis cela, j'ai cette erreur:
Si vous avez une solution, je suis preneur.
in english, but "no such file or directory" means "il n'y a pas de tel fichier", tu essaies de chercher un fichier qui n'existe pas
J'avais bien compris
Mais pourtant, juste avant le restart du vps, tout fonctionnais
hm
English:
Hello,
I will need you for an error that I do not understand.
I restarted my vps (my bot was already on it) and since that, I have this error:
https://cdn.discordapp.com/attachments/272764566411149314/654271559355072512/unknown.png
If you have a solution, I'm interested.
Tout est good pourtant 😦
what u trying to do?
you dont apear to be giving it the right file path
for it to look for
i believe there is a command similar to python like os.listdir which returns a list of directories within the file path specifier
specified*
that might help if someone can tell them what the Js version of the command is
fs is like os.dirthings
Ok
So, what should I put? Because before the restart of the vps, everything worked very well ...
how to get your bot a certified bot?
how can i make the login button turn in to the users discord avatar or username
like after the auth
i receive the access_token
what @fallen arch
also @surreal sage you have to send a physical letter with the requirments
To what?
how can i turn this into the users avatar or username
what are you trying todo with it is what im asking xD
im making a dashboard
The ideal applicant
Here are some things we're looking for in bots that want to apply. Following this one or more things on this list gives you the best shot at being accepted in to the program.
Bots that have a primary function which is executed and performs well
Beautiful clear documentation for users of your bot
Useful and fun bots
Unique and Original Ideas
Clear aspects of your bot that seperate it from the crowd
Developers who can read all of this and understand the requirements for applying don't guarantee entry to the program
@surreal sage
ok
Certain bots just aren't fit for our certification program and small edits/additions likely won't change this. Below is a list of things we're not looking for in our certification program at the moment
Multipurpose Bots
We prefer bots that are built for one or two features that are well made instead of hundred of useless/poorly designed features.
8ball / coinflip / RNG based commands
If one of your bots main/only commands is magic 8ball/coinflip or some other random number generated command don't bother applying
Non-English Speaking Bots
Your bot must support the English language. British English for extra points ;)
🤔
what @surreal sage ?
whats the type of a documents site (wiki, etc..)
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
everything about discord's aoth system is in there @fallen arch
you know site types right?
okay
like webshop etc
i want to know: whats the type of site for docs for a "bot"
wiki?
or something?
i have no idea what youre going on about
nvm
do you mean like .readthedocs?
YES
.readthedocs.io thats basically the first go to for any sort of documentation
thx
if (command === "setavatar") {
if(message.author.id !== botConfigs.ownerID) return;
const args = message.content.split(' ').splice(1).join(' ');
if(args === null) {
const e = new Discord.RichEmbed()
.setTitle(`:x:`)
.setDescription('Oops! You', `'ve not entered a image url!`)
.setColor('#ff0000')
message.channel.send(e)
}
} else {
if(args.startsWith('https://')) {
client.user.setAvatar(args)
const e = new Discord.RichEmbed()
.setTitle(`You've set my new Avatar`)
.setImage(args)
.setColor('#ff1493')
message.channel.send(e)
}
} else if(args.startsWith('http://')) {
client.user.setAvatar(args)
const e = new Discord.RichEmbed()
.setTitle(`You've set my new Avatar`)
.setImage(args)
.setColor('#ff1493')
message.channel.send(e)
}
}
}
}``` Theres a error and idk how to fix http://prntscr.com/q9a7u7 i know its something with: `)` `}` `;`
read the error
i do
X number 2 tells u what it wants
Yeah it uses the same backend.
.setDescription('Oops! You', 've not entered a image url!)
i thought lol
wtf is up with that command
im not saying thats the error or not
but it just doesnt look right
i fixed it
if (command === "setavatar") {
if(message.author.id !== botConfigs.ownerID) return;
const args = message.content.split(' ').splice(1).join(' ');
if(args === null) {
const e = new Discord.RichEmbed()
.setTitle(`:x:`)
.setDescription(`Oops! You've not entered a image url!`)
.setColor('#ff0000')
message.channel.send(e)
}
} else {
if(args.startsWith('https://')) {
client.user.setAvatar(args)
const e = new Discord.RichEmbed()
.setTitle(`You've set my new Avatar`)
.setImage(args)
.setColor('#ff1493')
message.channel.send(e)
} else {
if(args.startsWith('http://')) {
client.user.setAvatar(args)
const e = new Discord.RichEmbed()
.setTitle(`You've set my new Avatar`)
.setImage(args)
.setColor('#ff1493')
message.channel.send(e)
}
}
}
}``` fixed
it whas the else thing cuz it did not end properly
I don't think that'll work, but okay
Is there someome here who create a bot with python?
ive made serveral bots with python yus
.setTitle(hexes. + args)``` hexes a is a const of a json file, args are supposed to be: (example: red)
it says i got a error
Identifier expected.
usual needs somthing like name=
http://prntscr.com/q9b68e this is my json rn
wait
i can do const colorarg = hexes + .args right?
@modest maple
const colorarg = hexes + . + args;```
yeah dots are annoying
no erros but hope it works
gonna try
startup ☑️
@modest maple
oof
make that a string?
the "hexes"
think so
http://prntscr.com/q9bb3z hmmmmmm
no string there lol
gonna try the dot without string
are you trying to change the colour of the embed or send the colour name>?
yeah..
well the value of the color in the json is the hex
so it works
prob
does not start cuz of the dot
oof
dream
u know how to let the dot work but not make it a string
?
i dont exactly get why you are adding + . + args
when normally embeds just take the hex code direct?
like: axhex <color>
like blue
it gets "blue" out of the json and the value of it is the hex of the color
but args is the same as name
the problem is
the dot
else it wont get it
i tried dot and hexes in strings but it showed: hexes.<colorname>
should i add a: js const hexes = require("./json/color-hexes.json")?
extra?
dream?
u know how to fix this?
@sullen yacht
help
what
idk i dont do js
rip
both of us are Python xD
rip
what
how fix this dot? http://prntscr.com/q9bo1t
What are you trying to do
oh
if (command === "hex" || command === "color") {
const args = message.content.split(' ').splice(1).join(' ');
if(args === null) {
message.reply(`Oops! You've did not specify a color name.`)
} else {
const colorarg = hexes + . + args;
const e = new Discord.RichEmbed()
.setTitle(colorarg)
.setColor(colorarg)
message.channel.send(e)
}
}```
yes
that happens if the dot is a string
let something = {
test: true
}
console.log(something["test"]) // logs "true"```
i know
but in order to get that color hex from the json it requires: hexes
thats a const of my json
That's what you need, no?
Switch something with hexes in my example
how to fix
what is the error?
... thats not what i mean
Yes, you want colorarg to be one of the hex values
nonono
?
thats not what mean
From what I'm getting, you want it to be a color that the user chooses
As in the user will enter the color in regular text format
http://prntscr.com/q9b68e if the args is one of these names it gets their value
Yes
but in order to make the script short i use this http://prntscr.com/q9bvym
Yes
and hexes is a const of the json
You want to use hexes.whateverTheUserEntered
CD, search up bracket notation
yes
but that doesn't work
So instead
use hexes[whateverTheUserEntered]
Which will work
Be aware that it'll be undefined if they enter something that's not in there
client.commands.find(cmd => cmd.help.aliases) returns
The regular cmd instance
@modest maple can you teach me how to make a command code? Since i give up making it never worked
Btw sorry pinging you
dw
and you basically just check if a message has the prefix and command or atleast what i do
in the on_message() function
should help u 
Okay thanks
ofc
what
does anyone know why this happens. it's only when im put onto a smaller screen, gaps just come out of nowhere between the icons.
page;
<div class="box">
<% guilds.forEach(x=> {%>
<div class="guild" value="<%=x.i%>">
<div class="tooltip circleDiv" href="<%= base %>/<%=x.i%>">
<% if(x.a) { %>
<img class="guildPicture" src="https://cdn.discordapp.com/icons/<%= x.i%>/<%= x.a %>" alt="<%=x.n%>">
<% } else { %>
<p class="guildText"><%= x.n.match(/\b(\w)/g).join("").toUpperCase() %></p>
<% } %>
<span class="tooltiptext"><%= x.n %></span>
</div>
</div>
<% }) %>
</div>```
(relevant) css
```css
.guild {
float: left;
background-color: #23272A;
border-radius: 50%;
width: 100px;
cursor: pointer;
text-align: center;
margin-right: 10px;
}
.box {
padding: 0px 15% 5% 15%;
}
Desktop screens are completely normal
i dont know man but that .box css rule seems to be the problem
do you have any mobile specific css rules
absolutely none
ok then i'd probably guess that it's your .box css rule
on desktop it would look fine since it's a larger screen
padding just does this
do you not want the gaps there?
without it looks like this
im talking about this
thats probably because you're using float
honestly dont quote me these are just guesses
based on my own experience with something similar
without float does this

hold on
https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox might wanna consider this its pretty cool
el flexbox
i use grid rn on the other pages
you should use the same concept on ur server list then
but this seems like something that is completely unnecessary to use a tool like this
no i know but my point is i shouldnt need to use something like flex or grid for a simple side to side thing
hi, quick question (discord.js)
if i want to delete the author's message every time a command gets used, how would i do it?
i tried using message.author.delete() but it doesn't work
message.delete()
Author doesn't have the delete function
message.delete() doesn't delete the cmd's message
if you try it here it does not have the perms
what is your code
execute(message, args) {
messageid = message.author.id;
message.channel.send(messageid)
message.delete()
var server = message.guild;
const debugEmbed = new Discord.RichEmbed()
.setThumbnail("https://i.imgur.com/t1P6d5P.gif")
.setColor("0xfeb637")
.setTitle("Invite Party to your server!")
.addField("You can invite me here:" , "[link here]")
.setFooter("Party!", "https://i.imgur.com/B6QKBgC.png")
.setTimestamp();
message.author.send(debugEmbed);```
can i find out what my hosting systems are with a thing?
where is the if msg content lol
a thing?
like it replys with like platform (win10)
wait nvm i'm just stupid
process.os
thx
really
?
bruh ive been mislead like 60 million times
and im sad
wait
nvm lol
i accidentally deleted the channel a few minutes ago and the permissions got synchronized with the category
@surreal sage nvm
ok
wrong channel
lol
lol haha xd 😂
+emojiler
does this work? ${message.client.user.username}
if client is a property of message, yes
but i assume you didnt set message.client to client
so no
also https://tryitands.ee
try it and SEEE
all that's missing is bill wurtz's voice :c
How I can add a second reaction to this?
event.getChannel().sendMessage(embed.build()).queue(message -> message.addReaction(args[3]).queue()); (JDA)
save the message in a variable
@earnest phoenix don't know how? Can you show me?
i don't know how JDA names entities
but that's java basics
saving a value into a variable
Yeah I know but in what kind of variable
nevermind you don't even have to do that
just do it in the queue callback
just expand your lambda expression to multiline
Have I but I wan't to add a second but this dosen't work
event.getChannel().sendMessage(embed.build()).queue(message -> message.addReaction(args[3]).queue());
just expand your lambda expression to multiline
Now I've got this:
event.getChannel().sendMessage(embed.build()).queue(message -> message.addReaction(args[5]).queue((Consumer<? super Void>) message.addReaction(args[3])));
And this:
ERROR RestAction - Encountered error while processing success consumer java.lang.ClassCastException: net.dv8tion.jda.internal.requests.RestActionImpl cannot be cast to java.util.function.Consumer
And I don't know how to fix. Can anybody help me?
@earnest phoenix Oh now I have it Thank's!
Hi, I have a problem.
When I do a web request to a API JSON, and when I log that JSON in the console it looks like this but when I log json.reason it logs an empty message. How I can solve it?
(JavaScript)
That isnt json
It needs to be json[0].reason?
It throw me this error:
(node:10894) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'reason' of undefined
(node:10894) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 19)
OH 🤦
Tnx xd
try catching everything is not the solution
it's a lazy hack
you don't fix it you choose to ignore it
guys there is a problem in this syntax please help if you can
const server = msg.guild;
const type = 'category';
//########################################################
for(let i = 0; i < Categories.length; i++){
server.createChannel(Categories[i][0], {type,
permissionOverwrites: [{
id: server.id,
deny: Categories[i][2],
allow: Categories[i][1]
}]
}
)
}
return new Promise(resolve => setTimeout(resolve, timeOutCat));
}```
node.js/discord.js
what is categories (or at least what you pass for permissions)
You should take a look at the available permission flags: https://discord.js.org/#/docs/main/stable/class/Permissions?scrollTo=s-FLAGS
Not all of those are valid, like MANAGE_CHANNEL is actually MANAGE_CHANNELS (the S).
okay iwill try it thanks
the main problem is in this part and i really cant fix it please help if u can
server.manage_channels(Categories[i][0], {type,
permissionOverwrites: [{
id: server.id,
deny: Categories[i][2],
allow: Categories[i][1]
}]
}
)
}
return new Promise(resolve => setTimeout(resolve, timeOutCat));
}```
You can fix it by passing valid permissions in the JSON tree you showed in the screenshot.
Still not
the tutorial used vultr, but i figured it would be essentially identical to digital ocean
server.dispatcher = connection.playStream(ytdl(server.q[song], {filter: 'audio', highWaterMark: 1*1000*10000 /* 10MB */, begin: begin}), {highWaterMark: 1, bitrate: 64000})```
I use the above to stream a song over a connection using the ytdl library. I used to have for my pause command `server.dispatcher.end()` where it would save the playing song and the playlist. For the resume command I was basically unloading the paused queue and played the song using the above. However, I decided to use `server.dispatcher.pause()` and `.resume()` respectively. I understand that these are meant to pause/resume dispatchers and their streams, however it seems like it is only being paused and not resumed. Can anyone provide some insight on this? (Node v12.10.0, DJS 11.5.1)
And, yes, it is still connected and recognized by discord. Its just not resuming as can be seen here
And when I log server.dispatcher.paused it comes back with true
wait
I may be stupid
@dense patio I'm concerned that tutorial doesn't mention backups anywhere
i don't need to worry about those anyway
Famous last words
true
😁
if i need to enable them, there appears to be a simple setting in DO
The only other thing id change is, maybe Debian instead of Ubuntu, it's more lightweight, and also whatever SSH program they talked about, never heard of it, just use PuTTY
did discord.py get updated recently?
Ok
I just got a really weird error though
Send it, I might be able to help, though I don't know
It's working now but it said type TextChannel doesn't have the name attribute
or someth like that
odd
the error was for
if message.channel.name == '💡suggestions': #I made this for a specific server
AttributeError: 'DMChannel' object has no attribute 'name'
Sooo someone ran the command in DM's then probably
@zealous veldt http://youtube.com/watch?v=7lvDCMkjcsM
Song information 不可思議のカルテ Fukashigi no Carte アニメ「青春ブタ野郎はバニーガール先輩の夢を見ない」ED "Seishun Buta Yarou wa Bunny Girl Senpai no Yume wo Minai" ED Singer :Mai Sakurajim...
@earnest phoenix yes but wrong channel
@fathom pewter dont expect to be spoonfed code
we can help you write the code for bot presence
but we will not just send you ready code for it
Hi, is it just me who is experiencing MongoDB issues which it will sometimes deletes the command executer’s data from the database?
It only happens sometimes so I don’t think its a problem in my code.
Never had any issues with it
check the code where you are deleting data if you are not then check if you are actually adding it
Oh.. Okay then
Btw what happen with discord nowadays since the invite link embed seem broken lmao
Links in embeds work perfectly
I mean like the member count
What member count
@tidal parrot can u help me set up the dyno and mee6 bot pls
whats so hard about it?
(edit : I found)

One message removed from a suspended account.
helo guys I need a quick help
I am developing further with my discord bot, sooo, I need a function (or general help) to retrieve if and how my bot is into the ratelimit
Oh
Because it will error out if you are limited
I mean I should make a web request probably
nahh i want to make large style commands for big servers that don't violate the rate limit
yea???
yeah
why do you need that
rate limit is there to stop you
automatically
and you just dont do anything
you cant control users
duh tell me how webrequests work and where I should make them to retrieve the JSON
Check the headers of the request to see info about the ratelimit
duh ok figure it out yourself copy pasta
not lesson me on how my bot should be semi legal
you can get all of discord's endpoints from their developer documentation
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
have fun
You probably want the ones for resources
https://media.discordapp.net/attachments/483201827320496139/654679067085373440/unknown.png could someone explain this in a less complicated English
int input = 1;
int[] numbers = new int[]{ 1, 2, 3, 4, 5 };
for (int number : numbers) {
int sum = number + input;
System.out.println("The sum of " + number + " and " + input + " is " + sum);
}
I did something like that based on the question
but I'm not sure if that actually the right understanding on that problem
One message removed from a suspended account.
One message removed from a suspended account.
I know I need to use a for statement in java on that
the problem Im facing is the numbers I need to add
One message removed from a suspended account.
it says 5 values, I assumed the predefined values are 5 or something idk
One message removed from a suspended account.
I cant actually understand what do the questionaire even want me to sum one per line
One message removed from a suspended account.
One message removed from a suspended account.
first integer = the numbers of values remaining to be entered
One message removed from a suspended account.
One message removed from a suspended account.
I know java but its useless if I cant comprehend the way of english on the problem 
One message removed from a suspended account.
yayy all ready to go live
somewhere theres a error of args but idk ```js
if (command === "courses") {
const e = new Discord.RichEmbed()
.setTitle('Courses')
.setAuthor('Axyx', boticon)
.setColor('#ff1493')
//fields
.addField(course1.title + 'By: ' + course1.author + '', 'To view this course \nUse axcourse c1')
//send
message.channel.send(e)
}
//course 1
if (command === "course") {
if(!args) return;
message.reply('Please specify the course.')
const args = message.content.split(' ').slice(1).join(' ')
} else {
if(args === "c1") {
const e = new Discord.RichEmbed()
.setTitle(course1.title)
.setAuthor(course1.author, course1.authori)
.setDescription(course1.desc)
.addField(course1.pages + ' Pages', 'Switch from pages: \naxcourse c1 <page>')
message.channel.send(e)
}
}
//pages
if (command === "course") {
const args = message.content.split(' ').slice(1).join(' ')
return;
} else {
if(args === "c1") {
if(args === "c1 1") {
const a = new Discord.RichEmbed()
.setAuthor('1/2')
.setImage(course1.page1i)
.setColor('#1e90ff')
message.channel.send(a)
} else {
if(args === "c1 2") {
const a = new Discord.RichEmbed()
.setAuthor('2/2')
.setImage(course1.page2i)
.setColor('#1e90ff')
message.channel.send(a)
}
}
}
}
then how could we find it out?
shouldn't you find it yourself, as you understand it
as idk what your code does
One message removed from a suspended account.
gonna retry rn
are there any errors?
how do i do it?
The error message tells you what you did wrong
how do you do what
Well how to solve the problem that I also tried .setDescription
You need to make sure the table you make is not over the limit (either by capping or slicing anything past it)
Well, those do ..., I ask
hey
My bot has a command folder which contains all commands of my bot. I want to make folders into this command folder for organization. Here is the script (https://prnt.sc/q9xscj) who checks all the js files in my bot. How to edit it? (ex : I want him to check commands/fun/filename.js, commands/mod/filename.js...
2nd part of the script https://prnt.sc/q9xunv
read directories recursively
<Guild>.members.filter(x => x.user.bot).size
that's what happens when you copy paste things
https://discord.js.org/#/docs/main/master/class/Guild?scrollTo=memberCount @earnest phoenix if you are using discord.js
he's asking for bots
@earnest phoenix, they mean to read the directory for each category, or do it recursively (if you plan on having more folders inside folders in the future). For example,
let commandCategories = fs.readdirSync("./commands/");
for (const category of commandCategories) {
let commandFiles = fs.readdirSync(...); // Use logic here to get categories, like how you do it for commands
}```
like ```js
let commandFiles = fs.readdirSync("./commands/fun" || "./commands/mod")
no
🤦
what your trying to do in that line of code is
oh
you just need to loop over each category the same way you loop over the command directory to load each command
like ./commands/${category}/${stuff}
oh
Or you can just use https://www.npmjs.com/package/glob
ew
ew
no
glob good
its very light (56kb) and useful, idk why yall instantly say ew
but yeah its pretty unnecessary for this purpose
for what
code **Users** ${message.guild.members.filter((m) => m.user.bot = false).size} error (node:1810) UnhandledPromiseRejectionWarning: DiscordAPIError: 401: Unauthorized at item.request.gen.end (/rbd/pnpm-volume/b99409d4-7b2f-4afb-9263-e5e20c3823a2/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15) at then (/rbd/pnpm-volume/b99409d4-7b2f-4afb-9263-e5e20c3823a2/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21) at process._tickCallback (internal/process/next_tick.js:68:7) (node:1810) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:1810) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
cant you already do that with tsc
want to count users
why need to use a dependency that is so easy to do natively
I use it for registering commands
lmao why are you getting 401 on that
dont know
thats weird
mfw
they're getting a 401 at logging in but don't know how to debug properly
that stuff is websocket
also that's not how filtering works
i want to count only users
ur doing Boolean checks wrong
of the server
it's usually
!aaaa = false
aaaa = true
@earnest phoenix Is he the new CDeveloper copy pasta dev?
if doing if statements or predications (filter, map, etc)
i guess lol
there are a lot of people here who only know how to press ctrl, c, v
yep
its literally the only keys on their keyboards
it showing me a is not define
lmaooooo
replace aaaa with what ur doing
🤦♂️
What if we took V for paste, and changed it to P to make it harder

(https://canary.discordapp.com/channels/264445053596991498/272764566411149314/654727440308109314) to be honest, a friend write me the code for the commands folder, so i only understand 50% of the code
why you should always write the code yourself
how to do likee: if args include "a" make a -> b
so a becomes b and b becomes c
etc
like mors code
thats not morse code at all tf are you on
lol what
lmao
example
look up ascii code
caesar cipher with a shift of +1
where?
the fuck do you mean where
lmao
where you want it to shift
funnily enough I did that in C earlier
do some research
"look up ascii" code
oh boi
the first 2 steps is what most people in this channel do
copy pasting is fine as long as you understand what it does and how it works
otherwise its pointless
stackoverflow
a coder cant know everything
but you need to still make it yourself
find some snippets and understand your code
what are the things i should know if i want to do a thing where you can add multiple channels and itll make a webhook for each of them. and then everyday it loops through them and sends something?
like is ratelimiting a thing in that cuz they'd all be different webhooks
all endpoints have ratelimits
all ratelimits are per token
https://prnt.sc/q9z1g0 why it wont work
The bot can have a nickname (<@!)

thx
I want to check if a string starts with the current server prefix. But I get this error:
ReferenceError: prfx is not defined
var str = '.hello'
const prfx = `${server.tag}
`
if (str.startsWith(`${prfx}`)) {
msg.channel.send("Yes")
} else {
msg.channel.send("No") }```
Why do you do it like that???
var str = '.hello'
const prfx = server.tag
if (str.startsWith(prfx)) {
msg.channel.send("Yes")
} else {
msg.channel.send("No") }
str.startsWith(server.tag)
should be, lemme check
Are you sure the error's from that snippet of code (or edited)
d.py robo keeps randomly disconnecting from VC. no errors or anything - this is what the debug logs say in relation to it https://pastebin.com/3Fk9X1Gn
4014 Disconnected Either the channel was deleted or you were kicked. Should not reconnect.
it is a private server - the channel definitely was not deleted nor was anyone kicked
welp, thats what your logs say
either you got the wrong log, or ask in the d.py server
neither do i
well maybe it just means someone kicked it out of vc
or another bot did it though chances are unlikely
i believe the 4th line might actually be from Lavalink and not the bot itself. regardless, it wasnt kicked from VC
i see. any idea why they would do that? it isnt spamming voice or anything weird like that
and it is seemingly random. could happen after 5 minutes, could be 5 hours
the bot got remotely disconnected, apparently from discord's websocket
what version of D.py r u on?
1.2.5
the 4th line is seemingly from lavalink and not the bot itself - it will dispatch that event when it detects it has been disconnected from voice
only thing it might be is a shard switch over?
and from that it does seem like voice ws
if the server voice its on and the bot randomly gets disconnected and reconnected
like if you have high ping on a VC normally
it sometimes disconnects you
yeh thats possible
but in bot's cases the API doesnt auto reconnect
or it was a user action
they did state on the docs that 4014 shouldnt reconnect
which means likely shouldnt be random

actually thinking about it now, recently alot of VC have been breaking and failing to be deleted / changed and discord's been going through alot and resetting them
one thing that should be noted. i changed my websocket to use websockets rather than aiohttp since aiohttp would randomly dc from the lavalink server. with that said, the stuff involving connecting to a voice channel hasnt changed at all
Arab chat?
err no.
https://some-random-api.ml/meme how to get that image url out of there?
const url = https://some-random-api.ml/meme
url.image```?
i know theres something with the link
w-what
make it a string?
what
hes using an api
just send a url request
get json object
treat as dictionary
get image url
uhhhh
problem solved
no
That's how you treat that.
client.on('message', async (message) => {
if (message.content.startsWith(`dtest`)) {
if(message.author.id != config.owner)return;
let entry = await message.guild.fetchAuditLogs({type: 'BOT_ADD'}).then(audit => audit.entries.first())
let userr = []
userr = entry.executor.id
let acct = []
acct = entry.action
message.channel.send("<@"+userr+">\n\n"+acct)
}});
Why acct = undefined?
Resolved
@surreal sage i use this
const fetch = require('node-fetch');
const response = await fetch('https://some-random-api.ml/animu/hug').then(response => response.json());
[...]
please don't spoonfeed 👀
perhaps i put too much code
that wasnt too much code that was a full course meal
filled with pudding and starters
yeah, well, i'm too lazy to pick stuff
i dont need it any more :P
oh ok
Being too lazy to pick stuff hurts others.
Is it possible to restore a corrupt sequelise sqlite3 database?
Only some actions return that the database is malformed, not all
same
If i use this: if (!bot.member.hasPermission("SEND_MESSAGES")) return; bot.member will not be the bot in that guild right?
Client#member isn't a thing, if your client is the discord client
docs are helpful
and Guild#me is your bot in that guild as a member object
@earnest phoenix u know ur converting an array to a string right
yes
K thanks
Yes but thank you
i didn't read the Resolved part. my bad 
So ive got if (!message.guild.me.hasPermission("SEND_MESSAGES")) return message.author.send("I cannot send messages in " + message.guild.name); in my message event before i run anything. But when i test it my bot just errors out and doesnt dm me
Any reason this is?
you didn't send any error so
i started my bot using pm2 on digital ocean but it still isn't online, in the command line it says that index.js was started but the bot is offline
@green kestrel got anything?
@earnest phoenix what do you mean?
Nope, try running it without pm2 and see what error appears
or check pm2 logs
wait
it says "cannot find module discord.js"
There's your answer :)
install discord.js
did you required the module in your script?
i assumed it would've been downloaded since it was in the package.json i moved in
no
@pseudo whale what's the error you get.
https://youtu.be/hljkZxgogcY you have your answer I suggest you act on it
ing, I think you should do the comparison twice
@sudden geyser Discord API Error: Missing Permissions
@earnest phoenix that doesnt work cuz its invalid
the error is self explanatory
like if (event.d.message_id === 'ID' || event.d.message_id === "2ndID")
you either blocked your bot, or you disabled your dms
you have to duplicate
The error's probably not coming from that snippet of code, Matievis
If the user blocked it, it'd be Cannot send message to this user
You'll need to get the colum and line number to figure out exactly what line was causing it
Urm wherr do i get that? It doesnt seem to show it in the error
Can you share the stacktrace
This is the entire error (node:7767) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions at item.request.gen.end (/rbd/pnpm-volume/4fd4dbbb-ae95-4584-a8a2-26a80b2bb456/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15) at then (/rbd/pnpm-volume/4fd4dbbb-ae95-4584-a8a2-26a80b2bb456/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21) at <anonymous> at process._tickCallback (internal/process/next_tick.js:189:7) (node:7767) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 8)
thats missing perms
Ik
catch error
like if you want a allias on your cmd: js if (command === "1" || command === "2") {}
problem solved
I denied it perms on purpose
i made a pastebin post command :P
try and catch not always solution 🙅
Matievis, can you share your message listener in a paste (e.g. hastebin)
hey @green kestrel i'm getting no error messages but the index.js process instantly errors after i start it
did you install the missing packages
i believe so
did you use npm install
There's no errors?
nope
With pm2 or just regularly using node
How do you know it errors then
i did pm2 list and it said errored
I really must look into pm2 for running native programs.
might wanna add --lines 100 or something because it's pretty small by default
Unrelated to your error but you really shouldn't have that check up there
If it wasn't commented out (and also not broken) it would dm anyone that sends a message in a channel where your bot can't send messages
That's horrible
Thanks :)
It comment out my not working code until i get the thing to work
29mb is nothing
yeah
Does the bot work when ran outside pm2
but it's the only thing i can reason
Check the logs
Missing Permissions can really be anything (from sending a message to setting a guild role). You may want to watch as your code executes to track down exactly what caused it to error (through debugging).
yeah
pm2 logs 0 --lines 100
it's been on glitch for a couple months
Do you have other deps like DBL updater
That run on a timer
And are those installed
uh
The only code being executed is the bot sending a message into the channel
I'm betting it errors out when hitting the require of such a dep
@earnest phoenix why does that penguin have boobs
oh apparently sqlite isn't installed even though i just installed it just in case
Oh, kids cartoons 👍
Simply running npm install should install everything in your package.json
ctrl c
ah thanks
@late hill I don't do npm or glitch, are these things all automatic on glitch which is why @dense patio is stuck now after moving it to proper hosting?
probably
Just trying to understand why someone can run a bot for months and not know about these things
Yeah, seemed like it should have been prerequisite knowledge
Just developed my first bot over the past week and im now waiting for approval. It should be pretty lit.
I fell into same trap with my bot yesterday forgetting to put -rdynamic onto the g++ command and wondering why modules wouldn't load
Proper captain obvious moment
it just hit me with a bunch of warns saying "no such file or directory"
and an error sayin "This is related to npm not being able to find a file."
Maybe your working directory is set wrong
how do i change it
I'm actually learning as much as @dense patio ATM as node isnt my bag so I'm learning how to support you all lol
use pwd to see the current working directory
and cd PATH to change it
oh yeah i was in the right one
Hmmm
why would it be renaming files
I got something important to ask asap
Type whoami please @dense patio

here?
@late hill that
Why don't you just test your own commands?
No, in your shell
not a bot command
try npm cache clear
OH
;d
lol
Does it say root?
Ok....
Important advice
Make a new non root user
Set up your bot there
Running it as root is like running Windows XP as administrator
tbh it doesn't really matter what account you set it up on
yeah what would that change
It definitely does
That does not really effect much unless you had some kind of eval command
^^
what does it affect
Everything?
nothing
ok boys
Nothing unless you have an eval command
you're familiar with windows right
then root shouldn't exist
Noone can "hack" a Discord bot and even if they got your token it's a seperate session
That annoying run as administrator thing you need sometimes
holy shit i hate this new discord markdown preview
yeah
Gives you time to think before doing something stupid
no
@prime cliff what if one of your deps has a security vulnerability, or node does
yeah what about it
That's the same reason why you shouldn't be using root for regular things
Especially being new to linux
Still does not effect anything
@dense patio try npm cache clear for your issue
You might mess up everything with 1 wrong command
They can't leverage that unless it's with an eval command
Never ever run any public service as root. Apache and ngix don't run as root, nor does any other Linux Daemon, you shouldn't make one that does
The bot would work fine
ok so how do i change it so it's not on root
But it still isn't a good idea to run everything from root

add a user with adduser
that's a waste of time but ok
ok
add -m if you want it to create a home dir
@topaz fjord really, I think this is a conversation for those who know what they're talking about
Re the "this isn't needed"
ok...
implying I don't know what I'm talking about
Yes that's exactly what I implied
@green kestrel what do i do from here
I'm not often blunt and offensive but telling a newbie root is fine, is really really bad advice
telling a newbie it's fine when it is fine isn't bad advice
@green kestrel don't worry about it, i'm listening to you
Ok so you'll need to ssh into the server, but use those new credentials
i think i'm in already, no?
ok
You can either do it all again or you can go back in as root and do something like:
i moved all of the files to the new user
cp -r /root/bot /home/panicakr/bot; chown panicakr:panicakr /home/panicakr/bot
well, it's currently transferring
You'll need to change its ownership as above
Or reupload will do the correct permission
Carry on where you left off
Your bot is now more secure than it was
👍
very secure isn't it 
TIL that adding a new user makes a piece of code secure
Well, a programming error can't accidentally wipe the whole server now or kill it. And you have the options to set /etc/security/limits.conf etc.
it technically can
How?
os.exec
How can a non root user wipe the server
And setting limits.conf will prevent fork bombs or memory consumption beyond a sane limit
But you can't do that running as root
tbf brain i turned my school's server system OS into a webpage
on a student account
so its defo possible
good school
ik
i still get the rename error
Try running the bot without pm2, see what happens
legit
Look at output for errors
run npm cache clear
how do i run it without pm2
Now go with what turtle says :)
I know Linux not node



