#development
1 messages · Page 357 of 1
if u read discord.js.org u can probably find out how
i havnt used emoticons before in bots so idk
okey
http://r.u.a.retarded.men/5536—1421?!?!?!
I want this module sent to a function, can i do so within itself like this?
is there a way i can access both "D" and "E" to send it through the function?
what does d function do
it doesn't matter what the function does
idk what ur trying to do :/
i just explained what im doing
i dont understand lol
I want {D:{}, E:{}} aka the "module.exports" to go through the function
i was wondering if i was able to achieve it like above, or if there is an alternate way without me taking the entire module from my map
@languid dragon I think you can do this.D or this.E
ty lizar ❤
what do I do if this api endpoint returns not found for my bot's id? https://discordbots.org/api/bots
for the record i'm pretty sure the proper way to accomplish it is to define d and e in the module then export them later
let D = ...;
let E = () => D;
module.exports = {D, E};
How can I make so if there is an error it doesn't continue with the code?
Like if a command is missing permissions
Using discord.js
return;
Still sends?
.catch(error => {
return message.channel.send(`**Error: ${error}**`);
});
message.channel.send({embed: {
description: `**Sucessfully delted ${args[1]} messages.**`,
color: 0xb93a32
}})``` That's the code for it
@quiet bobcat when js throws an error, it immediately stops execution up to the outermost try...catch block
Isn't that a catch block?
It looks like this https://gyazo.com/48c2a2ad94807cd9634831d656b26844
@quiet bobcat oh i see
you can't really do that with the callback pattern
either stick your "messages successfully deleted" code into a success handler for the promise or use the async/await pattern
How do I do the async/await pattern?
Ok
I dont have a website, can my bot get certified nonetheless? (because of this requirement: The use of at least one of our widgets on your website/github page.)
Only on my discordbots.org bot page ^^
I dont, but I can put it on github .. 🙃
How can I add to a value without making it stack. I want it to be eg 100 and I get 100 so it's 200 but instead it's I have 100 and get 100 and I get 100100 for some reason? Any way to just add it like addition instead of adding it after the current value?
Using discord.js
if its a string
parseInt(string) to make it an integer (i think i spelt it right)
@quiet bobcat show code
I looked up parseInt and it showed me to do this
parseInt(currency[message.author.id + message.guild.id].money) + args[2]
currency[message.author.id + message.guild.id].money is a string
@topaz fjord
?
currency[message.author.id + message.guild.id].money + parseInt(args[2])
So parseInt(currency[message.author.id + message.guild.id].money) + parseInt(args[2])
ok
Still doesn't work
then try ```js
parseInt(currency[message.author.id + message.guild.id].money) +parseInt(args[2])
well fuck
Got any other ideas?
Yo @surreal peak the video search command I have only allows for YouTube videos to be searched. None of which are “nsfw” (by which I’m assuming you mean pornographic), so I’m not sure how I could change that...
How can I get guildMember from message.author?
Uhh some of them are @long forge
that's why you dont see bots with that command 99% of the time
Wait really? There’s porn on YouTube? Jesus. Ok well then I guess I’ll remove that command then.
Never intended bot to have that
oki
for the better i guess
some stuff such as "naked art"
even seen some sex guides with real people -_-
so yea bad idea
Could it be better to add a tag blacklist to the search, so it will fail on non-NSFW channels if an NSFW tag is used?
There’s an idea.
That's what I use for my booru commands anyway, and it seems to work well
I can't believe I've gone almost an entire month without realizing that discord.js pretty much requires the error event to be handled.
🤦
lol wat
I mean unhandled rejections basically does the same lol
but that's not d.js
that's node for you
How can I make like this and then set a modlog channel to something and it updates?
use a db
no
Still wating
I added a prefix table to my discord.js bot, but now I need to count the number of characters up to and including the !
How would I do this?
Pretty sure there's a string position function in JavaScript. Just look that up.
Though keep in mind people might use ! for punctuation
Or maybe I'm not understanding
@shrewd field What library do you use?
d.js
Eris is better
He could either use the SQLite module thing. I use SQLite too, for now.
whats needed for a randomizer?
ive defined result as
"rock",
"paper",
"scissors"
];``` but idk how to send 1 of those in a message
Math.random()
Yo I have a blacklisted words list on a json that I am using.
could I just simply copy https://gist.github.com/miguelmota/11266467
Is that the right format?
mmmmmmm
how to use Math.random()?
array[Math.floor(Math.random() * array.length)]
what is array defined as
what?
ok
you're using result as your array, are you not?
you're just taking its length and multiplying it by Math.random() which returns a variable between 1 and 0.00(god knows how many zeros) and flooring it
let options = [
"rock",
"paper",
"scissors"
]
let result = options[Math.floor(Math.random() * options.length)]
ok
&&
&&
How to make a bot in visual studio code?
lol
"rock",
"paper",
"scissors"
];
module.exports = {
run: function(bot, config, msg, args, suffix) {
let result = options[Math.floor(Math.random * options.length)];
msg.channel.send(result);
if(suffix == "rock" && result = "paper") {
msg.channel.send('Aww, you won');
}
},
help: {
name: 'rps',
description: 'Play RPS With The Bot',
usage: 'p!rps <rps>'
}
}```
```potatoebot@server:~$ node .
/home/potatoebot/commands/rps.js:11
if(suffix == "rock" && result = "paper") {
^^^^^^^^^^^^^^^^^^^^^^^^^^
ReferenceError: Invalid left-hand side in assignment```
help?
===
you're trying to set "result" to "paper" in an if statement
( this is what you're doing right now )
THIS IS WHAT
IS CAUSING ERRORS
THIS IS THE THING, YOURE DOING
THE THING UR NOT SUPPOSED TO BE DOING
variable = "test" is an assignment of a variable
variable == or === "test" is testing to see if the variable equals "test"
oo ok
no im checking if result is paper
?
ohh
i see
lol whoops
ik i saw when i went to edit
uhm
i have ```msg.channel.send('Aww, you won');
anyone here using discord.py?
no
how do I know if an user is a bot or not?? anyone xd?
in js its if(msg.author.bot)
hmm will try
hes clearly not asking for js
@languid dragon it looks similar xD
lol, it looks like that it worked..
I wanted to use that for adding EXP if an user writes something (Bots were leveling up xD) . So for now, it does work....
@crude mantle thanks..
lol
so u let bots use ur bots commands?
It's to ignore other bots
I only want the users gaining xp, so I need to ignore bots
ik
i have```
msg.channel.send('Aww, you won');
its saying cannot send an empty message
help?
@tawny lava
I did
no no like the error
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): DiscordAPIError: Cannot send an empty message
is that the entire error?
Don't think it's from that

yes
take screenshot
oh wait
Yeah those errors are usually that big only
probs
already got my bot in 1 server from discordbots.org
hm i do p-rps
my bot says undefined
code:```let options = [
"rock",
"paper",
"scissors"
];
module.exports = {
run: function(bot, config, msg, args, suffix) {
let result = options[Math.floor(Math.random * options.length)];
msg.channel.send(result + ' ');
},
help: {
name: 'rps',
description: 'Play RPS With The Bot',
usage: 'p!rps <rps>'
}
}```
Too much coding
what?
Coding
waiting for ur bot to be approved i guess
Yes
how to set code to connect the bot code file to a specific folder so the bot satrts with the folder?
?
read the question
which lang, which lib
like do you expect people to read minds lol
js eris

how to set code to connect the bot code file to a specific folder so the bot satrts with the folder in eris?
How do I update to v12 discord.js?
Nope
I think you need to get it from git or smth
ok... then
npm install hydrabolt:discord.js#12.0
or no
npm install hydrabolt:discord.js#12.3.0
try that
w8 shit.
lol
nevermind I have no clue what I'm talking about
haha
Won't work
eris vs d.js which is better
d.js starts breaking at 15k guilds
Ok
isn't that what shards are for?
^^
and you should start sharding at 2k guilds, so that isnt an issue that should be encountered
how do you shard?
And you should continue sharding every 2k guilds
Check the docs
^
It just comes down to personal preferance
Btw it was npm i hydrabolt/discord.js
@wooden shoal
i think d.js has more customisation
well, master is. but that's on another branch I guess
That is the master

i found the code for sharding
const Manager = new Discord.ShardingManager('./YOUR_BOT_FILE_NAME.js');
Manager.spawn(2); // This example will spawn 2 shards (5,000 guilds);```
Just make a weeb bot ez 500k guilds

lol sad but true
the the site says around 2.5k guilds is when you HAVE to shard
2.4 is when you should start
idk where this guy is getting 15k from lol
What does shards do?
Discord recommends that as well iirc
Around? You mean at 2.5k
Sharding is chipping up your bot into multiple pieces
It means you split up your bot over multiple processes, so that only a small number of guilds are connected to 1 process
You MUST shard if your bot is in more than 2500 guilds, but it is recommend to start earlier, at like 1000 guilds
(if your bot is more than 100k guilds, you have to make sure your shard count is in multiples of 16, but you probably won't hit that limit and things might change if you hit it one day)
@quasi marsh so, mi bot got 10 svs xDDDDDDDDDDDDDDD... so SHARD MUST BE DONE
Certainly
(no, most people recommend sharding at 1000 guilds)
But if your bot is good, you will probably get there some day
@quasi marsh I was just joking jdsjsd, but thanks.. I think my bot could reach that number some day.. 😛
wait why do u have to shard? i dont understand
@earnest phoenix what discord.js ver do you use
@earnest phoenix can u help me with my code
kk
Quote from Discord4J docs
When a bot becomes part of a lot of servers it becomes too clunky to handle all the events on only a handful of threads, this is why sharding it introduced, to allow multi threaded delegation of events posted from discord to the API more efficiently.
Basicly, if you have a bowl of soup, you can help people get more soup if you add another spoon.
You can only get so much soup out of the bowl to a person with 1 spoon
(But in reality, the spoon is shared with 2500 other people, but when you have 5000 or 10000 people, it'll take longer, so you add more spoons)
Yeah that's fine
how do u shard?
^ xd
mhmm
ya
I don't use js myself, so read up on the docs
ok
You can probably find examples on github as well
or be lazy like me and wait for the dbm update xddd
@quasi marsh https://this-is.definitely-not-a-sketchy.host/ccadba532e.png not really
the discord devs need to manually move you to the new system
Oh
Like when a guild has a lot of members they need to ask for more space otherwise it'll just go down all the time?
@crude mantle you need some help?
with?
i saw something about js
👍
I've invited Haru to my chat trying to figure why commands dont work. Any help would be appreciated
anyone know how to get the server's vanity url through d.js?
how should I display a sort of carousel thing without using js or anything?
hey
guys
who knows what is this error because of?
d.js
lib
client.commands = new Discord.Collection();
client.aliases = new Discord.Collection();
fs.readdir('./commands/', (err, files) => {
if (err) console.error(err);
log(`Loading a total of ${files.length} commands.`);
files.forEach(f => {
let props = require(`./commands/${f}`);
log(`Loading Command: ${props.help.name}. 👌`);
client.commands.set(props.help.name, props);
props.conf.aliases.forEach(alias => {
client.aliases.set( alias, props.help.name);
});
});
});```
code
Are there there any pokemongo bots??
@shrewd field what is props.help for?
how to get an invite for a server a bot is in. discord.js example a bot is in a server that I don't own and I am not in. how do I get an invite for that server
its not in the docs so i dont think ya can ¯_(ツ)_/¯
xd
Why don't you go to the actual D.JS server
instead of constantly asking for help here
You never read the documentation and constantly ask for help for the most rediculous errors
also my mistake, you can create invites
yep
i wonder why 
are you banned?
no im not banned
Ok.
i dont ask stupid questions constantly
Idk why they banned me and I don't ask stupid questions constantly.
what
we need to literally send you to the documentation every time
Read the docs @shrewd field
and walk you through step by step
I did read the docs when they said to read it.
you read the section we send you to
and come back for help every second
like
you never go to the documentation first?
No
if you did you wouldn't ask half the questions you do
Ok then how can I get unbanned?
and I will next time see the docs before doing that.
Also at that time I didn't know what was the docs for?
How to count voice chat with discord py?
@languid dragon your "retarded men" link crashes discord every time I click it
xD
its nothing important lul
lol
all you need to do is search Deni in #development and you'll find a lot

@gilded plank demote Ken
@gilded plank demote @gilded plank
@gilded plank demote Oliy
@gilded plank take over the server and give me admin while you're at it
@gilded plank demote all of the ppl that are higher ranks than me and then give me website administrator and ownership of the website plx k thx
Hey to set a modlog channel and then update it in a server settings command I need to use a database yes?
Like this I mean
yes
this is waht i mean
When I change server log to a channel it will upadte using a database
right?
ya
Hey, the permssions on the oath url of a bot are they reqiured to be fullfilled all of them to do a regular command in the discord server even if the bot doesn't have the same permssions on the invite link given.
Because when I do a regular info command it gives meDiscord API Error Missing Permissions.
wat
just do a perm check for each command
ok
How do you get the name of an unbanned person from their ID.
This is an example. http://prntscr.com/hx6xw0
how do you get the tag? I looked through this on docs. https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=unban and https://discord.js.org/#/docs/main/stable/typedef/UserResolvable
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
@shrewd field https://discord.js.org/#/docs/main/stable/class/User?scrollTo=toString might help you
User.tag
Hello, is anyone online?
@wraith burrow I am
In my bot, I can't mention myself
Use the mention format
<@userid>
but it doesn't work
Use that
@wraith burrow
That is for your mention
(that one is escaped so it shows up like that)
Thanks, it worked.
Will it also mention me in the servers which I'm not a member of?
no
How does this bot mention @Scrapy (This user/bot isnt on the server)
Your client has the user cached
So it can resolve the mention properly
Or at the very least you may share a server with that user and it caches/can resolve it
User/bot point is across
I dont share a server with the @gilded plank
You do, it's called here
Sorry I meant Srapy is not sharing a server with @gilded plank
But not when the user is not on the server
Yes you can
The mention will still go through but only resolve to a name and profile if the end user has the person cached
ah ok
in my bot i put:dbl = require('discordbots');
dbl.postStats(bot.guilds.size);i got this error: ```/home/potatoebot/index.js:13
dbl.postStats(bot.guilds.size);
^
TypeError: dbl.postStats is not a function``` anyone help?
I can't help you with that unofficial module
or is it discordbots-api
here is an example: ```js
const snek = require('snekfetch');
snek.post(https://discordbots.org/api/bots/${<Client>.user.id}/stats)
.set("Authorization", "key")
.send("server_count", <Client>.guilds.size)
.then(() => console.log("Done"))
Replace <Client> with your Discord.Client()
npm i snekfetch
yes
in the Authorization header
and what function do i put it in
any
ok
ok
I run it in a loop ;)
.. ok :(
do i replace key with my token?
yes
kk
why are they so long xD
ok
Long == secure
if ((long) token == "secure") return;
``` 
do i need to log done?
Same
xD
Long dick buddies
same
lol
it didn't do anything? @vital lark
it didn't?
no
wait it crashed
throw er; // Unhandled 'error' event
^
Error: socket hang up
at createHangUpError (_http_client.js:331:15)
at TLSSocket.socketOnEnd (_http_client.js:423:23)
at emitNone (events.js:111:20)
at TLSSocket.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1056:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)```
thats discords problem
how to fix
try again
ok
happened again when i went to my bots page on discordbots.org
@vital lark
help?
it's probs Discord
how to fix
ok
my bots token on discordapp.com/developers/applications/me?
@ohlookitsAugust#1793
@ohlookitsAugust#7360
@vital lark
yes
ok
@crude mantle show code pls kthx
what code
the code your using to send
k
.set('Authorization', 'my token')
.send('server_count', bot.guilds.size);```
my token is replaced with my token from discordbots.org
you are putting the token as your dbots token right?
mines set to bot
amd mot bot token
Can someone help me? I'm using discord.js and I'm trying to figure out a way to add a value to my json file. I want to add to the number using addition but right now I'm using js currency[message.author.id + message.guild.id].money += '100'; and instead of making the two values eg 200 is makes them 100100
What do you mean?
parseInt(first_object) + parseInt(second_object)
two objects must be strings containing a number
it didn't do anything

Should I do like math.round(parseInt(firstobject) + parseInt(second_object)?
or math.floor
or whatever

kek u cant add a string to a number
@quiet bobcat https://i.imgur.com/3vSueLW.png
hm
can u also do
console.log(typeof currency[message.author.id + message.guild.id].money)
did u console.log the thing i told u to
Yup
what did it say
string
console.log(typeof parseInt(currency[message.author.id + message.guild.id].money))
It says number @topaz fjord
so then
console.log(parseInt(currency[message.author.id + message.guild.id].money) + parseInt('100'))
what does that return
@quiet bobcat
200
then it should work 
ik
It stopped adding completeley
it's still the same after I added 100 to my balance

The balance is still 100
when I tried to add 100
@topaz fjord
😦
should I try to do parseint on one
and then just a number as the other?
@topaz fjord 
f*help
@earnest phoenix
How many times my bot can change its Playing status?? I mean, how often should I set the period to not get banned?
@narrow flare 1/15s
my bot's playing status updates whenever it joins/leaves a server 
@inner jewel thanks..
also, isn't it 5/60s
ya
1/15s
Good enough not to ratelimit
If you ratelimit your bot game status you get d/c from the gateway
Dunno ho I'm supposed to tell, but I fixed the reason why my bot was muted.
parseInt(currency[message.author.id + message.guild.id].money) + 100)
or just this @topaz fjord @quiet bobcat 
heck why not just save the money property as a number to begin with and you wouldnt need to parse anything?
@quiet bobcat
if it's stored in JSON then you could even make it be stored like so. Then if you load the json (lets say it is in a let called jsondata) then you could do jsondata[msg.guild.id][msg.author.id].money
{
"guildID": {
"memberID": {
"someProp1": "someVal1",
"money": 100
}
}
}
I use sort of a similar structure in my own bot's warning system so it should work
I personally use jsonfile: https://www.npmjs.com/package/jsonfile
can someone help me with getting this bot running as i am trying to code python.
@floral stump
A friend made me my script with python for the command "kick" but I know almost nothing xD. Watch the script ↓
if message.author.id in botadmins:
utilisateur = userSearch(parametres[0], guild=message.guild)
await message.guild.kick(utilisateur)
idk pytrhon
:d
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\BANIEN\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 223, in _run_event
yield from coro(*args, **kwargs)
File "C:\Users\BANIEN\Desktop\Dossier Emmanuel\#1\#2\Bot.py", line 128, in on_message
elif command == "kick":
NameError: name 'command' is not defined
XDD
Hey guys, I need a bot that can convert time zone in chat.. do you know something?
I have another problem too.. I can’t find my server from the list.. why?
if it is truely your server that you madem then you should be able to find it, if you didn't made the server then you need to have administration perms
is that not the same as administrator ¿¿¿
I only read this, thats why
I already had some servers, but I created a new one too for test, called TEST, but still can’t find it..
I have a superagent post request & the reply of the API is an Image in the body but superagent get it like a Buffer, how I can transform that buffer to an image?
The console.log of the request
you can just fs.writeFile it and it'll be an image file
oh
you should be able to just send that buffer
lol no
what lib?
lol
lol im idiot
I did image.url
im retarded
I added it
but anyways doing nothing https://sagiri.is-a-good-waifu.com/65843c.png
yay worked without embed
@inland salmon Not here
@frigid juniper idk
uh not quite
guilds is a collection of guilds, so it almost certainly has no property called users
more likely there's some field called bot.users that stores cached users
or if you want to only include users in the bot's guilds, you can map each guild to its member count and fold the resulting list with a summing combiner
er i guess so
ok ty
Make a forEach statement to get the size of each guild then add them together
ok
there are... more idiomatic ways
how do u get guilds? bot.guilds
bot.on('message', msg => {
r.db('moosebot').table('guilds').get(msg.guild.id).run().then(data => {
if (data) {
var prefix = data.prefix;
console.log(`Guild: ${msg.guild.name} - prefix: ${prefix}`)
if (msg.content.startsWith(prefix)) {
if (!msg.channel.permissionsFor(msg.guild.me).has('SEND_MESSAGES')) return;
let args = msg.content.slice(config.prefix.length).trim().split(/ +/g);
let command = args.shift().toLowerCase();
let commands = require('./modules/cmds.js')
console.log('pre try');
try {
console.log('post try');
if (commands[command]) {
console.log('pre perms');
let perms = {
embed: msg.channel.permissionsFor(msg.guild.me).has('EMBED_LINKS'),
manage_server: msg.channel.permissionsFor(msg.guild.me).has('MANAGE_GUILD')
}
console.log(`passed perms`);
commands[command].func(msg, args, {embed: true}, bot, prefix);
}
} catch (e) {
console.log(e);
}
}
}
})
});```
This makes it to the if statement, then nothing happens
@zealous veldt which if 
if(commands[command])
Wth is that CMD handler...
xD
a custom one
not using async/await in 2018
if(msg.author.bot || msg.channel.type === 'dm' || !msg.content.startsWith(prefix)) return;
var command = msg.content.split(' ')[0].slice(prefix.length).toLowerCase();
var args = msg.content.split(' ').slice(1);
let suffix = args.join(' ');
var cmd = commands.get(command);
if(cmd) {
try {
cmd.run(bot, config, msg, args, suffix);
} catch(err) {
console.error(err);
msg.channel.send('Oops, Something Wen\'t Wrong! Please Contact PotatoeTheDev#6123');
}
}
});
``` thats mine
oo i need to remove that if statement lol
how to do forEach in js?
x.forEach(y=>doStuffWithY(y))
for (const thing of collection) {
// do something
}
Google tbh
if mayo was still here he'd say "use map because it's faster than foreach"
there are a great many ways to iterate in js lol
ok
Lul yes
but are you familiar with monads?
no
ok then yeah use a for...of loop i guess
how do u define something as something in for loop?
for(bot.guilds as servers)?
ForEach: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
For: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for
The forEach() method executes a provided function once for each array element.
This channel is nothing but js 
Just read the articles they will help you out
kk
const guilds = bot.guilds;
guilds.forEach(function(guilds) {
//add users
});```
this?
your getting there
what did i do wrong?
nothing
no it's like
suppose you have an array of numbers and you're trying to find the sum
that's essentially the problem you're trying to solve here
How to set bot music play speed with discord.py? (youtube_dl)
Uhhh can you even
I know one way and that's lowering the frequency of audio you send to Discord lul
44,100 doubles playback speed on Discord
I messed with audio on Discord a lot
oh thanks
Let me try.
In all honesty though I don't know the easy way
I use custom libraries and I found that as a funny thing
but it does work
not recommended changing frequency though
Is there still a way to fetch messages in discord.js v12?
yes
oh, thanks didn't see that
Uhm, can someone help me? I'm using discord.js v12 and have a music bot, but when I wan't to play music on it. I make it join the server and start playing a song. It sends the message that it's added to the queue but then it leaves. I tried console logging it aswell and everything worked out fine. But still no music. There's no errors in the console at all so I don't even understand where to start looking.
send your code
This is what I use to start playing the music ```js
if (!message.guild.voiceConnection)
message.member.voiceChannel.join().then(function (connection) {
if (!server.dispatcher)
play(connection, message);
})
else {
if (!server.dispatcher)
play(message.guild.voiceConnection, message);
}```
It worked fine two days ago, haven't changed the code since. I don't understand what's wrong
Here's the play function (forgot it) ```js
function play(connection, message) {
var server = servers[message.guild.id];
nowplaying[message.guild.id] = server.queue.shift();
var video = nowplaying[message.guild.id];
if (!server.dispatcher) {
message.channel.send({embed: {
color: 0x82eefd,
description: `[**Added to the queue:**](${video.url}) \n${video.title}`,
thumbnail: {
url: video.thumbnail
}
}})
}
log("I have started playing \"" + video.title + `" in ${message.guild.name}!`)
server.dispatcher = connection.playStream(YTDL(video.url, { filter: "audioonly" }));
if (volume[message.guild.id])
server.dispatcher.setVolume(volume[message.guild.id]);
server.dispatcher.on("end", function () {
nowplaying[message.guild.id] = null;
if (server.queue.length > 0)
play(connection, message);
else {
connection.disconnect();
server.dispatcher = null;
}
});
}```
if(server.dispatcher = null) {
connection.disconnect();
}
(add instead of else at the end of your code)
I have no clue, but give it a shot. Now it should only disconnect when there is no song playing right? I have no experience with anything to do with music bots though so I could be wrong.
It's worth a shot
Well it doesn't disconnect anymore
But there still isn't any music
hm ok, idk then. 😢
Thanks for the try
wait add in a line that says if the queue = null then disconnect, i dont have time to write the code
Ah I dunno then, ask someone else. Sorry man
Oh haha, nice.
Can someone help me with a command, im using discord.js btw. I'm trying to make a command so if the bot joins a server it sends a message automatically. It works, but it seems if there is no #general channel the bot crashes. This is my code:
client.on('guildCreate', guild => {
guild.systemChannel.send(Hello, I'm LMAOBOT. Thanks for inviting me, here are a list of all my commands! :alien:, {embed:{
title: '❌ Prefix',
color: 0x2471a3,
description: "The prefix for all my commands is 'lmao', e.g: 'lmao help'.",
fields:[
{
name: '🎉 Fun',
value: 'agree, dankrate, gayrate, 8ball, meme, pun, roll, coinflip, doge, kappa, lenny, lol, megusta, pepe, sanic, spiderman, spooderman, troll, wat, dolan, notsure, alone, pupper, kitty'
},
{
name: '🛠 Utilities',
value: 'help, ping, invite, servers'
},
{
name: '🔊 Sound Board - WARNING (EARRAPE)',
value: 'reee, airhorn, momgetthecamera, 20thcenturyfox, dedotatedwam, friendzoned, gofuckyourself, gottagofast, illuminati, ohmygod, pussy, sadviolin, smokeweed, ohbabyatriple, wombocombo, wow'
}
],
footer: {
text: 'LMAOBot created and developed by Pete#4164.'
}
}});
});
Would anyone be able to help me fix this, I had a look on the discord.js library and I couldn't change guild.systemChannel.send to guild.defaultChannel.send because they removed that. Is there another command that sends the message to the first channel the bot has perms to?
loop over all the channels and check if the bot has read + write perms
I made a whole new server with no roles or anything added and removed #general and made a new text channel with no perms, it wouldn't send.
said "TypeError: Cannot read property 'send' of undefined"
that's why you need to loop over every text channel
the bot has read and write perms
did you not read what i said?
ohhhhh gotcha
Hey guys I have this error that says cant find commands/general module but I dont have any general modules.
I see it only loads two commmands and when it reaches the help command it gives the error
the error is ```css
Error: Cannot find module './commands/general'
2:27 PM
at Function.Module._resolveFilename (module.js:489:15)
2:27 PM
at Function.Module._load (module.js:439:25)
2:27 PM
at Module.require (module.js:517:17)
2:27 PM
at require (internal/module.js:11:18)
2:27 PM
Jump to
at files.forEach.f (/app/app.js:38:17)
2:27 PM
at Array.forEach (<anonymous>)
2:27 PM
Jump to
at fs.readdir (/app/app.js:37:9)
2:27 PM
at FSReqWrap.oncomplete (fs.js:135:15)```
you've probably mentioned ./commands/general somewhere in your code. Press Ctrl+F on your code editor and search for ./commands/general and edit/delete it.
Does anyone know how I can restrict commands to upvoters only? I know the api but how will I get my bot to read it?
@earnest phoenix do you let JDA call a build function ¿¿
well, no reaction, can't help you then
i did
can you show (copy paste in a codeblock) how ? (remove the token if it is in there)
¿¿
@north fog
wierd, it should work
yeah
lmao
try adding a onready listener
is resulting offline
look if onready gets fired
got some kotlin code by hand```kotlin
class OnReadyReport : EventListener{
override fun onEvent(event: Event?) {
if(event is ReadyEvent){
println("Logged in as ${event.jda.selfUser.name}")
}
}
}
alright
Alright whatcha need @earnest phoenix
const dbl = require("dblposter");
const DBLPoster = new dbl(`API KEY`);
// Then, depending on what you called your client
DBLPoster.bind(client);
sooo i just put this in guild add and remove?
the code
If you wanna use the module yes that would work
and ofc install dblposter
Make sure you require the module out of the event
out.. so like at line 4 of bot.js not where guildadd etc..
oh k
That explains it
const dbl = require("dblposter");
const DBLPoster = new dbl(`the api key i need`);
// Then, depending on what you called your client
DBLPoster.bind(bot);``` should match my bot then
Yes that should work
okay thx
np
0|jb | Error: 400 Bad Request
0|jb | at _response.transport.finalizeRequest.call.then (/home/pi/Desktop/jb/node_modules/snekfetch/src/index.js:198:23)
0|jb | at <anonymous>
0|jb | at process._tickDomainCallback (internal/process/next_tick.js:228:7)
@ebon apex help
Have you gotten the api key and put it in the spot
yes
Let me see how you have your code, jsut replace the key with something else before posting here
0|jb | Error: 401 Unauthorized
0|jb | at _response.transport.finalizeRequest.call.then (/home/pi/Desktop/jb/node_modules/snekfetch/src/index.js:198:23)
0|jb | at <anonymous>
0|jb | at process._tickDomainCallback (internal/process/next_tick.js:228:7)
``` i used \` now and got this error
That would mean it's not getting the key
400 bad request is odd
That means something was provided incorrectly
401 means the key was not gotten by the api
Why not just use snekfetch
It might be eaiser to just post it manually without using the pre-built module
sec
// bot is your Discord client.
const snekfetch = require('snekfetch');
const key = 'YOUR DBL KEY';
snekfetch.post(`https://discordbots.org/api/bots/${bot.user.id}/stats`)
.set('Authorization', key)
.send({ server_count: bot.guilds.size })
.then(() => console.log(`Posted to dbl.`))
.catch((e) => console.error(e));
^
I edited it to be without shards that should work fine
oki
0|jb | at Object.<anonymous> (/home/pi/Desktop/jb/bot.js:17:61)
0|jb | at Module._compile (module.js:635:30)
0|jb | at Object.Module._extensions..js (module.js:646:10)
0|jb | at Module.load (module.js:554:32)
0|jb | at tryModuleLoad (module.js:497:12)
0|jb | at Function.Module._load (module.js:489:3)
0|jb | at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:73:21)
0|jb | at Module._compile (module.js:635:30)
0|jb | at Object.Module._extensions..js (module.js:646:10)
0|jb | at Module.load (module.js:554:32)
@ebon apex
what is line 17
uhh
this
snekfetch.post(`https://discordbots.org/api/bots/${bot.user.id}/stats`)```
Is your client defined as bot
yes
Alright I think I know what the problem is
y
Make sure the top two variables (The require and the key variables) are at the top of your file then the snekfetch.post part is in your ready event and your guild create and delete event
It's because the bot.user is not defined until the client is logged in
and it's trying to call it before that
If it is too big for discord then you can use https://hastebin.com
For the errors
and I can see if I can help you out
finally it works..
o
m!help
im using this code for a google command (command handler heh) but for example when i search whatever things it outputs anything related to google (example: i search youtube and it gives me out the yt channel of google)
const snekfetch = require('snekfetch');
const querystring = require('querystring');
exports.run = async (bot, message, args) => {
let searchMessage = await message.reply('Searching... Sec.');
let searchUrl = `https://www.google.com/search?q=${encodeURIComponent(message.content)}`;
return snekfetch.get(searchUrl).then((result) => {
let $ = cheerio.load(result.text);
let googleData = $('.r').first().find('a').first().attr('href');
googleData = querystring.parse(googleData.replace('/url?', ''));
searchMessage.edit(`Result found!\n${googleData.q}`);
}).catch((err) => {
searchMessage.edit('No results found!');
});
}```
oof
maybe... you should try doing it yourself first beforehand copypasting code?
what are you using
js
i think ik why tho
lemme try again brb
where do i put my token from discordbots.org?
rethonk
Ok I give up on finding a good youtube video to help me code my bot somebody tell me the program or just what to use and where
what lang do you plan to/are using
there is step one choose a lang
now look at the many libs for discord in js
there are some on https://discordapp.com/developers/docs/topics/community-resources and if look use google/github you can find more
most if not all libs have docs for you to look at
@shut heron
thanks
@carmine berry Whats the program I put the code in? I can't find it _('-')_/
thanks
wait you means to run it right?
yeah
then yes the link up there
how do I restrict commands so you have to upvote to access them?
How would i do that, is this correct?
var voteapi = "https://discordbots.org/api/bots/398413630149885952/votes";
client.on('message', message => {
if(message.content.startsWith(prefix + " test")) {
snekfetch.get(voteapi).then(r => console.log(r.onlyids));
}
});
I have no experience with json or api's so its a tad hard trying to figure this out
https://discordbots.org/api/bots/398413630149885952/votes?onlyids=true will get you an array of ids who have upvoted your bot in r.body
without onlyids you get other stuff like username too
ahhh righto, thats what I was looking for, thanks.
is this the right code to join a voice channel in python
@dusk verge.command(pass_context=True
async def play
bot.join_voice_channel()
read docs
i don't think so
anyone know how to use discordblocks?
It's a drag and drop bot builder, it's not that hard.
i did not figure it out
When I try to get bot stats from the api, it gives 301, why?


