#development
1 messages Β· Page 437 of 1
you use the reaction thing from discordjs.guide right?
stable
okay so
Can anyone help me with how to edit bot's message after X seconds, please?
what happens is that you try to get the reaction what was removed already so your const reaction = message.reactions.get(emojiKey); returns undefined
thats why your emitted event also throws that error
@waxen quest I can if it's in js
It is
use setTimeout
^^
in a .then(
Would there be a fix to the reaction thing?
but then it won't work for uncached messages no?
sure thanks for your help
I got my discord bot to update server count on the website on ready, guildCreate, and guildDelete
Hmm
That's unecessary
There's a thing that updates it automatically
const dbl = new DBL('Your discordbots.org token', client);
That will update it automatically periodically
does anyone know why it says invaild syntax when i try to run my discord bot because every time i add a new command it would invaild syntax and show a red line on client
you forgot to close a bracket
?
you forgot to close a bracket
idk how to close a bracket
( unclosed bracket () closed bracket
LOL
WTF
HE DIDNT MEAN LITERALLY
For each bracket you open there needs to be one to close it
k
Or else the program assumes everything after is in the brackets
im not really a "good"developer so idk how
Look up the basics of the language you're trying to use (Python in this case), it will come in very handy! I mean if you don't know how to close a bracket then how are you possibly gonna help if someone needs help with your bot not working or if there's a bug that needs fixing? Keep at it though, the more you do the more you'll remember and learn along the way! π
how to make this so it sends the xp in the channel and not in the console?
let taget = message.mentions.users.first() || message.guild.members.get(args[1]) || message.author;
con.query(`SELECT * FROM xp WHERE id = '${target.id}'`, (err, rows) => {
if(err) throw err;
let xp = rows[0].xp;
message.channel.send(xp);
});
}
module.exports.help = {
name: "xp"
}```
what doesnt work? is there an error?
I'm trying to shard starting with 2 spawns, but the Debug console keeps outputting
It looks like it also keep restarting shards, but they wont stay on for more than half a second
try without the inspector
sharding starts a separate node process, which cant be attached to the same debugger address
So I actually have to run it?
either without the inspector, or configure the inspector to use a different port
Thanks. That fixed it. I thought it was just a wrong line or something
Even though it was literally three lines of code
let now = Date.now();
let timeLimit = 2000;```
error: (node:392444) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined
are you using discord.js?
i cant find any ratelimits in their docs
master has a rateLimit, but its a different thing
yes
bot.ratelimits isnt a thing
@topaz fjord it could be a custom variable.
then .ratelimits doesnt have the method .get
like bot.ratelimits = new Discord.Collection(); or something
collections have .get() right?
but in his case, it doesnt have a get()
ohk
but the real issue is that they just posted some code and an error without context
helpful af
and then they're gone
spam account?
no i mean, post a question then go god knows where
ping them
can babies ask questions about programming on discord?
or an alien
how do i make my help command split into categories? it just lists them all in one bunched up list right now
there are many ways to do it
for example you can split it into different categories yourself, and have a command argument for each of them
like help 1 help 2 etc
or name them
make help and index, and help name the actual thing
like General, Moderation, etc
sounds complicated though, and it wouldn't work since if you give my help command an arg it'll show command information
to split it into different fields in the same message, you can use this to help you design it
well
i know how to add fields
const { RichEmbed, version } = require('discord.js');
module.exports = {
name: 'help',
description: 'Lists all the bots commands, and can optionally provide in-depth information on a specific command or module.',
usage: '',
aliases: ['h'],
execute: async (msg, args) => {
const help = new RichEmbed()
.setColor('#7289DA')
.setTitle('Listing ' + client.commands.size + ' commands:')
.setDescription(`Start any commands listed below with \`!\` to use the command, or optionally add a command name on the end of the help command to get information on a command. If you need any help, [click here](<removed>). \n\n${client.commands.map(command => `\`${command.name}\``).join(', ')}`)
.setFooter(`running discord.js v${version}-stable`)
msg.channel.send({ embed: help });
}
}
thats my commands code
it basically maps the commands, but it won't sort
if you want everything in the same message, use fields
if you want it split over different messages, then you have to add arguments
um
you don't understand my question
i want to use fields, but i don't know how to adapt my dynamic help command so it sorts the commands into the correct field/category @quartz kindle
instead of this ${client.commands.map(command => `${command.name}`).join(', ')}
use a logic that sorts them and puts them into fields, instead of description
or write them yourself manually
so maybe add a .filter before .map?
you can add a filter, if it fits your needs
.addField('General', `${client.commands.filter(command => command.category === 'General').map(command => `\`${command.name}\``).join(', ')}`, true)```
would this work?
yeah
yeah test it out
nice
^^
Rethink all the way :^)
is rethink really that good?
i know of rethink, its alright
unsure if it'd be good for a bot though that might grow
i don't want to touch sql or anything
rethink? @ amy
im using json lul
but my bot is not big
what about leveldb?
doesnt work with shards tho
never heard of it
levelb was developed by google enginners
but its like a very optimized flat file db, not an actual rmdb
can only have one connection/process at a time
doesn't really sound good for a mod bot
its more than enough
any db is probably more than enough for a discord bot
these things are designed to support millions of transactions, discord bots are nothing for them
connections though is small
like if there are lots of actions happening it can make the bot hang right?
only if you're a bad coder
which i probably am π
if you do things right and use non-blocking calls, it wont hang
or put everything into memory, unless you need to cache big things like images
for example, my commands only save to db, never load from it
everything is loaded into memory at once when the bot starts
so whats your db choice fishy?
mongodb
a very popular one indeed, i havent tried it yet
high availability cluster makes it my favorite
is it easy to use?
i kind of want the ease side, like database.get(msg.author.id)
eh sorta?
I use an ORM
This is an example query:
[ err, result ] = await to(
ReactRole.find({
guild: target.guild.id,
channel: target.channel.id,
msg: target.id,
emoji: {
$in: target.reactions.map(v => {
return v.emoji.id ? `${v.emoji.name}:${v.emoji.id}` : v.emoji.name
})
}
})
);
i know of enmaps, unsure though since people called it a beginners database
its simply a wrapper that does the connection for you. you can still chose which db you want to have behind it
ah
would sqlite be a good choice? since i see it allows rethinkdb too but um, i dunno
the difference is that enmaps automatically saves whenever you do .set()
hm
i'll think about it anyways.. and can you guys help me with my aliases? they don't work
I use mysql for my bot
what framework is this
discord.js
And the command framework?
i'm not sure what you mean
Discord.js doesn't provide frameworking for commands
i made my own
then you should know how to use it?
well it should work honestly
but i don't know why aliases don't work and i'm asking for help to fix them
i'm new to making bots
@keen drift Did you make the command?
so no one wants to help?
whats wrong?
read up
you need to provide code for us to help
where is the module being imported at
Can we see it?
can I see your package.json
i don't have one
package-lock?
nope
What do you use to import dependencies?
commands/
help.js
avatar.js
files/
config.js
messageHandler.js
app.js
logo.png
thats my file structure, and i import dependencies per-file
like when needed
Import dependencies, as in your dependency manager
you don't have a package-lock.json?
@keen drift Sup
nope
@earnest phoenix https://gist.github.com/RumbleFrog/7d1e5ca660dfe80147c27029bc7fd60b
the fuck
Did you deleted the lock file or some shit
Fishy a bots saying youβre swearing...
there was never a lock file
npm install discord.js --save does not generate any lock?
i is install
idk how you work with js projects with a dependency manager without a lock file
What other dependencies did you pull via npm
why is this related to my handler though? and none really
all i've used is discord.js
Because client.commands does not exist within discord.js
it does?
client.commands = new Discord.Collection();
i define it myself
const client = new Discord.Client({ disableEveryone: true });
global.client = client;
client.commands = new Discord.Collection();
in app.js:
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
try {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
console.log(`+ ${command.category.toLowerCase()}/${command.name} loaded`);
} catch(err) {
console.log(`- a command failed while loading: \n${err.stack}`);
}
}
.has looks for map key name
if h is an alias, you should be using .find
It's returned here if (!client.commands.has(commandName)) return;
well that isn't where aliases are triggered
where is alias triggered
this is where, in messageHandler.js:
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
But can it proceed to that if the previous statement returns?
umm, i think so?
...?
So you are saying if (!client.commands.has(commandName)) return; returns and it will still proceed?
it should be returning
should i remove it and try that?
yeah
well it didn't
Β―_(γ)_/Β―

how do I take the logs from console.log and make them appear as a message?
I don't want to have to look at my log for every little thing
w h a t
instead of console.log(content) use <message>.channel.send(content)?
I saw the => but I was like "there's no way that's a pointer"
=>?
That's not how the command I'm using works
that's the es5+ way of func decl
I'm thinking WAY too much C++ rn
I didn't mean like legit coding C++. The program I use to find pointers before using them in C++, ReClass, it refers to Pointers using =>
I've been using it so long that everytime I see that I automatically see "pointer"
async def wait(self, user, channel, timeout=120, keywords=None):
def check(m):
if keywords is None:
return m.channel == channel and m.author == user
else:
return m.channel == channel and m.author == user and m.content.lower() in keywords
try:
resp = await self.bot.wait_for('message', check=check, timeout=timeout)
except asyncio.TimeoutError:
return False
return resp.content
``` I feel like this makes it easier
return m.channel == channel and m.author == user if
else:
return m.channel == channel and m.author == user and m.content.lower() in keywords #keywords needs to be a list```
Is there anyway I can do that without using the if and else statement?
Like possibly doing it on the return line
I doubt it but maybe
fuck I gotta refresh my python memory
I know a one line if statement but it doesn't work in this situtation
return m.channel == channel and m.author == user and (keyword is not None or m.contentlower() in keywords)
i think that works
That may work
Ok. Fishy. This is what I'm working with right now
try {
const code = args.join(' ');
let evaled = eval(code);
if (typeof evaled !== 'string') {evaled = require('util').inspect(evaled);}
message.channel.send(clean(evaled), { code:'xl' });
}
catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}
My only issue is that this seems to only send values that are strings. So Im wondering if just getting rid of the 4th line all together would work or completely break this
It worked @keen drift but I had to chnage some of it. I forgot you could use () xD
def check(m):
return m.channel == channel and m.author == user and (keywords is None or m.content.lower() in keywords)
try:
resp = await self.bot.wait_for('message', check=check, timeout=timeout)
except asyncio.TimeoutError:
return False
if keywords is None:
return resp.content
return True
@high lava You can stringify it
async def wait(self, user, channel, keywords=None, timeout=120):
def check(m):
return m.channel == channel and m.author == user and (keywords is None or m.content.lower() in keywords)
try:
resp = await self.bot.wait_for('message', check=check, timeout=timeout)
except asyncio.TimeoutError:
return False
if keywords is None:
return resp.content
return True
what are you using to find the channel
It doesn't matter what I stringify. I still get ```javascript
Promise { <pending> }
Even with the default stringifying from utils.inspect with the added stringifying on the results, it only returns an array in the console. not the message
How would I even start using MySQL with DiscordJS/Node
@grizzled totem I think you have to pass a channel object
So you have to search the collection
@high lava Because that's a promise, you have to await the result
oh null doesn't exist?
null does not exist though
that's how db interprets null
what do i have to set it as, undefined maybe?
if you want an empty value, pass an empty string
can i set it as undefined?
i think it's still null in db
what are you checking it with
if (!guild.modlog) return msg.reply('that config value doesn\'t exist.');
i console log'd modlog and it gave me 'disabled' which is the string i set it as

You know what. I'm a grade A retard
It wasn't the code in the bot that was wrong, it was the code I was trying to eval
lmao
I swear to god. I spend so much time trying to fix stupid mistakes like this
π€ Anyone use wakatime? Dashboard is showing stats but profile + leaderboard ain't. Does it take a day to update?
^new user btw, may be part of it
quick question: how to remove own reactions? like .send().then(msg.react()).then(remove reaction) ? something like that
d.js?
ye
im adding a reaction collector on a message for an hour, i want to remove the reactions (bots own reactions, not other peoples) after the reaction collector ends
does that work without manage messages permission?
Well, default is the client so I assume that it would, I haven't personally tried it myself
Msg.react().then(reaction => reaction.delete())
Or at least handle something with "reaction"
I don't think there is a delete
let me see
there's a remove
yeah what cosmo said but with remove()
default being the client
oh yeah it has default
so in your case <message>.reactions.remove() or <reaction>.remove()
inb4 anyone know about wakatime
@quartz kindle do you read the documentation
yeah i just did
Before asking?
@night imp Yeah I think it's cached
yes i did, the reason i asked is because i tried it before and it didnt work
but i dont recall exactly how did i try it
@keen drift ok I'll wait a day and see if it updates
Well i dont think its so much the methods you are worried about just your code logic tbh
wait let me try the api
i figured id try again
nvm bot is bad
i just asked to confirm the methods are correct
if(message.author.id === `${botID}`) {
message.delete();
}
This doesn't seem to work at all
if (message.content.startsWith('\'nou') || message.content.startsWith('\'help') || message.content.startsWith('\'thot') || message.content.startsWith('\'copy')) {
message.delete();
}
I assumed it would work the same way as this. This works perfectly at the moment. The bot just won't delete its own messages
This is the entire command
if (message.content.startsWith(`${prefix}` + 'clear')) {
if(message.author.id !== `${ownerID}`) return;
if(message.author.id === `${botID}`) {
message.delete();
}
}
The ID number of my bot, and the ownerID is my ID
Do u need have .then and .catch
And are you ignoring bot users
Yes. right after Client.on()
if (!message.content.startsWith(prefix) || message.author.bot) return;
I didn't realize that would have an effect on deletion. thanks
Well the thing is
Any message any bot sends is instantly ignored and the entire code returns/stops at that point
So there is no way for your message.delete method to run
Or anything else related to messages that were made by a bot
i keep getting this issue
the underlined bit (reason) is empty no matter what and then the command errors
despite me putting in like a billion fallbacks
command code (purge.js): https://hastebin.com/begonadove.js
you make too many checks to see if reason exists or not
i dont think that'd be why it doesn't work but try putting the rest of it inside try{} as well
alright
and only make 1 check to see if reason is empty
if (!reason || reason === undefined || reason === null || reason === "") {
that should do it
alright
also are you okay with nitpicks and suggestions?
of course π
Ok so you have require('../moderationActions') inside a function and generally it's good practice to declare it before module.exports or at the very beginning of the document
that way it's not called every time you use the prune function
ah, alright. so i can just do const { purge } = require('../moderationActions'); or something at the top of the file?
exactly
i'll change that for all my mod commands then, since i use the same require way
does your purge function have the RichEmbed feature?
whats that..?
ah yeah, i assume you know what's up with that error then?
is that related to reason being empty
yep
try give reason a default value say reason = "this is a reason" and test that
so.. set the reason as a default, then set the reason again if the user provides one?
actually yeah
set the reason as
"No reason provided."
and only change it IF there is user input
alright
that way, no matter what, reason will have a value
hm, stupidly either my bot isn't reloading right.. or its still not working
this is the code now: https://hastebin.com/semoqimija.js
but it still gives the same reason doesn't exist error
im going to make some edits and show u what i did to see if i can help you along
alright
you've restarted the bot and the code was reloaded and you're 100% sure you're working on the right file
try console.log(reason, userReason, amount) to see the outputs of everything
restarted again just to make sure, now its saying can't read property trim of undefined
just running !purge 5
oh lul 1 sec
okie
okay remove trim() from both [0] and [1] and put it on userReason
also do you know how async/await works?
alright i'll remove it, and um kinda
can you show me a bit of your code when you run .execute(msg, args)
like the message event?
yes
I have 2 shards just because at this point and they both work perfectly fine. I was just wondering if they automatically balance it over time?
balance what?
don't you need to start sharding at 2500 guilds?
Yeah, you can still do it earlier tho
ah ok
I did it so I could could code with sharding in mind at an earlier time
smart
have you ever used promises
uhh is that the .then().catch() kind of thing?
i have used them a few times i think, usually i try use try catch since it kinda looks nicer
ah
lol
canvasβ’
ok so i've rewritten your code as an example of how i'd write it
you dont need to do it that way, it's just another perspective and i think something that'll help out a bit
After reading this I just realized that there's a ping property for the client...
Jesus christ, I always do the hardest stuff
alright
im still learning about await/async myself tbh
but i think using throw "err" will be handy, i didn't include it because im really not sure
all i know is that throw = .catch()
and return = .then()

I've just been using try and catch with some .then().catch() here and there
@uncut slate would be able to tell you more about this, he's a JS god
the thing is with my bot i have it all promises, and so if an error occurs it is caught by my message handler, so i dont have to worry so much if i break some code
you have that for every command?
yeah that's the message handler
all my commands are promises and if an error occurs they reject() and send that back to the error handler
i can show you an example in #commands
I think I may want to do that at some point. lol. I know I don't catch everything so I feel like my bot can suddenly crash at any moment π
Sure
@languid dragon, read the Promise page in mdn if you want to know more about it, to understand async/await, first you need to understand promises.

Well, you said
all i know is that throw = .catch()
and return = .then()
By that it doesn't looks like you really understand Promise, specially as <Promise>.then(); has a second argument.

yeah im pretty nooby at explaining things tbf
It happens, if anything goes wrong, just send an mdn page + stackoverflow, always works.

thanks 
can't blame you for not understanding it
js has a poor implementation of asynchronous actions
js went from callback hell to poor man's async
@keen drift Have you made that image embed thing yet? sorry for being impatient.
didn't I link you it
I made one that gives you the gist and prob get you started
I thought I pinged you
hello i am a bit confused about something...
When i embed my bot info into my own webpage, it shows that i have 3 upvotes, but on my discordbots page, it shows only 2... why are they showing different numbers?
probably a total/monthly upvote thing
π Tonkku does more of the backend, I generally work on other stuff and DSL
q; do you plan on having the ability to register who voted for our bot, therefore able to reward them?
Sorry.. I'm chowing down like a fat piece of shit. I started writing without thinking. And I was not aware of that until now.
tmi
yeahh... I know. ;/
if you add more options onto a SQL query (like a WHERE clause, attributes (in the case of postgres)), does it slow down the return time of the query?
Not necessarily
If you index it correctly
Obv it will be slower with some conditionals
would also make updating/insert/delete slightly slower since it has to update more indexes
But it will be in the Β΅s
Does anyone know what extra I need to do for the bot = commands.AutoShardedBot in discord.py or do I just have that with no params and sharding works automatically? Tbh, I don't really get how it works in the first place lol
rip parentheses
Got a prefix set up or?
The sharding is automated, that's correct
Depending on how that lib shards it, there may or may not be extra things
That's why it is called "AutoShardedBot"
If it spawns multiple processes, and have a parent process, things that relies on full data collection will not work correctly
Some sharding method will just create additional socket connection with Discord, leaving it as one process, in that case there's nothing extra to be done
Multiple processes will always be superior, so there's a tradeoff between easy to use vs performance
I can't remember which one discord.py uses, I believe it spawns additional processes
Thanks, that's what I was wondering, if it requires me to do any extra setup but I just noticed this and it seems not so should be alright with literally just having that line in there to set it up.
A client similar to Client except it handles the complications of sharding for the user into a more manageable and transparent single process bot.
When using this client, you will be able to use it as-if it was a regular Client with a single shard when implementation wise internally it is split up into multiple shards. This allows you to not have to deal with IPC or other complicated infrastructure.
It is recommended to use this client only if you have surpassed at least 1000 guilds.
If no shard_count is provided, then the library will use the Bot Gateway endpoint call to figure out how many shards to use.
If a shard_ids parameter is given, then those shard IDs will be used to launch the internal shards. Note that shard_count must be provided if this is used. By default, when omitted, the client will launch shards from 0 to shard_count - 1
Yeah, I don't fancy messing about with IPC if I don't need to at the moment lol Thanks Fishy!
ready
and made a css file containing the following
.material-icons .thicc {
font-size: 96px !important;
}
I then do
<i class="material-icons thicc">icon</i>
but its still small
<div class="material-icons">
<div class="thicc">thingy</div>
</div>
remove the space
hmm
.material-icons.thicc {
font-size: 96px !important;
}
no problemo
How does one open() a file from a folder that is in the same folder as the .py file?
Hey
with open(r'folder/file.ext', 'r+') as f:
value = int(f.read())
f.seek(0)
f.write(DATA TO WRITE GOES HERE)
f.close()
That kind of thing?
Although you'll need to change it for what you want it to do, that will overwrite the contents of said file
(and the value line is specific to what I used it for so you can ignore that) but f.read() will get the contents @slender thistle (ping in case you missed the replies)
i get this error
(node:44092) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'trim' of undefined
const urban = module.require("urban");
module.exports.run = async (bot, message, args) => {
if(args.length < 1) return message.channel.send("Please enter something!");
let str = args.join(" ");
urban(str.first)(json => {
console.log(json);
});
}
module.exports.help = {
name: "urban"
}```
pls help
nvm fixed it
@latent copper No notification for the ping in edited message. Thanks both you and @native narwhal
ππΌ
Ah I wasn't aware of that cheers but no worries!
await bot.change_presence(status=discord.Status.online, activity=discord.Game(name=f'ready in {bot.guilds} servers'))
TypeError: change_presence() got an unexpected keyword argument 'activity'

That's rewrite for sure, because else my bot wouldn't run
Ignore the bot.guilds thing, actually. It's wrong
str(len(bot.guilds)) or len(bot.guilds) I had to use I think
Yeah, still the same error
Other than that, I dunno why it would throw the activity type error if you're using rewrite. You sure it's the latest version?
Yep
I mean, I would pretty much get some errors at least for my on_message events in main file :p
Does it matter which order you specify status and activity maybe?
hmm π
And you've got it under a @bot.event and on_ready() method? I really dunno what to suggest that's weird if you're using the latest rewrite like you say
what is the random cat website?
random.cat iirc
@latent copper Had Discord.py async version being used instead of rewrite one
No idea how my cogs that were supposed to only work on rewrite worked with async, then
Yeah that is rather odd, oh well at least it works now!
@safe berry
how do i make a cat command with this website?
https://aws.random.cat/meow
my code:
const api = "https://aws.random.cat/meow";
module.exports.run = async (bot, message, args) => {
let msg = await message.channel.send("Generating...");
let file = (await snek.get(api)).body.file;
if(!file) return message.channel.send("I broke! Try again.");
await message.channel.send({files: [
{
attachment: file,
name: file.split("/").pop()
}
]});
msg.delete();
}
module.exports.help = {
name: "cat"
}```
somehow it did
iirc d.js doesn't care and will download from the link if a link is given
bot.on("message", async message => {
var args = message.content.substring(prefix.length).split(" ")
switch (args[0].toLowerCase()) {
case "color":
let color = encode(args.join(" ").slice(7))
let {body} = await superagent
.get(`http://www.colourlovers.com/api/color/${color}`)
var embed = new Discord.RichEmbed()
.setAuthor("FDP MARCHE")
.setFooter(`Coded by Enzo`)
.setColor(body.hex)
message.channel.send(embed).catch(e => {
message.channel.send("WoW i cant show this :sob:")
})
} ```
o is my error
where is my error ?
how do i fix these undefind's?
Someone wishes to know what your code is 
module.exports.run = async (bot, message, args) => {
let embed = new Discord.RichEmbed()
.setAuthor("Help command")
.setDescription("These are the commands:")
.setColor("#42f4ee")
.addField("Avatar - Displays the person's avatar.")
.addField("Cat - Display's a cute cat image.")
.addField("Findusers - finds the user in the server")
.addField("Icon - Display's the server's icon")
.addField("Mute - Mute's a member.")
.addField("Unmute - Unmute's a member.")
.addField("Randomurban - Display's a random definition.")
.addField("Urban [name] - Displays the definition of the name.")
.addField("Userinfo - Display's your userinfo. (Still working on it.)")
.addField("Vote - Vote's yes or no. (Still wroking on it.)");
message.channel.send({embed: embed});
}
module.exports.help = {
name: "help"
}```
I think you arr adding a value bame but not a value text
are*
name*
I am on phone rn, can't edit messages
@vale gull is normal with addFiel we need 2 argument ()
example
.addField("First ","second")
Np π
in discord.py we are forced to provide both arguments otherwise an error will show 
nobody has a solution for me
in js too except that his undefined poster @ruby dust
no it's not, in js it will show a string of "undefined" while in discord.py it returns none which is impossible for discord's embed system
oh ok
you say coded in js
if(!message.member.hasPermission("MANAGE_MEMBERS")) return message.reply("No can do!");
let wUser = message.guild.member(message.mentions.users()) || message.guild.members.get(args[0])
if(!wUser) return message.reply("Couldn't find them.");
if(wUser.hasPermission("MANAGE_MESSAGES")) return message.reply("They can't be warned.");
let reason = args.join(" ").slice(22);
if(!warns[wUser.id]) warns[wUser.id] = {
warns: 0
};
warns[wUser.id].warns++;
fs.writeFile("./warnings.json", JSON.stringify(warns) (err) => {
if (err) console.log(err);
});```
please help
@vale gull add a comma after JSON.stringify(warns)
ok
comas are useless in js
They really aren't useless
but you can do without them
Half the stuff in js won't work without em
and it wasnt the error rn
wot? which case? I never had to use comas by necessity in js :d
commas are important actually
https://gyazo.com/89358d79a53fe375ffa4d47f5d872e79
For es6 it's important
without commas you can't even have multiple args
yey, I know
I thought commas were semicolon, idk, I'm tired sorry π
so yeah, semicolons are useless 
@inner jewel rest operator me harder daddy
hiya i'm being an idiot
trying to get dblpy working but i don't know what the parameter in the example takes
the_cog = list(self.bot.get_cog_commands(command))
if isinstance(the_cog, commands.Group):
cog_or_cmd = re.findall(r'\w+', command)
if len(cog_or_cmd) == 2:
msg = cog_or_cmd[0]
comd = cog_or_cmd[1]
the_cog = list(self.bot.get_cog_commands(msg))
cmd = self.bot.get_command(comd)
for comm in the_cog:
if cmd.name == comm.name:
result += cmd.signature + '\n\n ' + cmd.help + '\n'
command is user input. Any clues why this doesn't work?
One message removed from a suspended account.
hello everyone i just created my first bot and i have a problem to make him online can somebody help me?
using python
One message removed from a suspended account.
One message removed from a suspended account.
can someone help me fix my code?
One message removed from a suspended account.
he is offline i want him to be online
ill send u the code ok? in privte
can u chek him?
One message removed from a suspended account.
sent
can somebody help me? i dont know what to write in the Detailed description of your bot *
please
btw #memes-and-media or #general, I believe
One message removed from a suspended account.
One message removed from a suspended account.
@bold wigeon your bot prefix should be # not the list of commands. The list of commands should be in the long description or in a help command.
thank you
@neon schooner can you help me to make my bot online? im trying and thats not work. can you chek my code?
That would be up to someone wanting to take a look at it.
can somebody chek my code?
i cant make the bot online
i found the problem and i dont know how to fix
unexpected character after line continuation character
how to fix it pls
i'd be nice if we saw the actual error dump, or if you copied the line of the problem code
send it to me
sorry but no
I can check
ty
oh
One message removed from a suspended account.
okay, what's the error and which language are you using
One message removed from a suspended account.
One message removed from a suspended account.
^
^^
One message removed from a suspended account.
definitly javascript xd
One message removed from a suspended account.
im using python and someone know how to fix it?
yes
okay send it @bold wigeon
One message removed from a suspended account.
you need to put () after new Discord.Client
java != javascript
One message removed from a suspended account.
One message removed from a suspended account.
displayAvatarURL is that a thing? it might, I always use something else
One message removed from a suspended account.
no its displayAvatarURL
I use .avatarURL but I see it's on it too
One message removed from a suspended account.
are you sure bot is what you think it is?
One message removed from a suspended account.
One message removed from a suspended account.
-_- I was looking at it and have patience, you can't expect people jumping for you
thats kinda rude
I have my own bot to look after I have a ton of work to implement so me looking at your code is a favor
One message removed from a suspended account.
One message removed from a suspended account.
do a console.log(bot) the only thing I can think of that bot is not a client in this case
One message removed from a suspended account.
inside the run function
One message removed from a suspended account.
yeah
One message removed from a suspended account.
One message removed from a suspended account.
yeah, but what does the console say about bot?
take a screenshot of the contents of the log
Log it first
One message removed from a suspended account.
One message removed from a suspended account.
Client then maybe
so you have a problem somewhere else in your code
Or Bot
One message removed from a suspended account.
One message removed from a suspended account.
Where are the other files
One message removed from a suspended account.
You don't need new Discord.Client()
Cuz it should be in the main file
One message removed from a suspended account.
One message removed from a suspended account.

One message removed from a suspended account.
I gtg
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
anyone know how I can fix this error ``` const playlist = await youtube.getPlaylist(url);
^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)
One message removed from a suspended account.
await won't work in a function that's not async
@earnest phoenix I think we established that you have multiple instances of bot and that's the reason why bot is undefined, search in all your files where you make bot
@granite hedge how do i do that
show part of your code I can tel you where to put it
exports.clean = {
name: "clean"
, description: "cleans all the recent messages from the bot in that channel"
, permission: "243275264497418250"
, category: "DEVELOPMENT"
, process: async function (bot, msg, suffix) {
await msg.channel.fetchMessages({
limit: 100
}).then(messages => {
var test = messages.filterArray(m => m.author.id === bot.user.id)
for (i = 0; i < test.length; i++) {
test[i].delete(1).catch(e => {})
}
}).catch(console.error);
}
}
``` for me it looks liek this
One message removed from a suspended account.
lemme just redownload it from my server hold up
One message removed from a suspended account.
One message removed from a suspended account.
https://hastebin.com/gikumariyi.js @granite hedge
do you have like a function around it? How do you call it to be executed? is it when bot is ready? or ...
One message removed from a suspended account.
surround the piece of code you sent me with js async function() {//YOURCODEHERE}
One message removed from a suspended account.
@granite hedge its when theres a message sent is it not already async?
it needs the word async it's how javascript checks if it can use await
the environment can be async already but yeah javascript is weird in that way
One message removed from a suspended account.
javascript made a huge leap from callbacks to async and promises
I said before check where you overwrite your first botinstance and make sure all your files can access the 1 bot you made in your index file
One message removed from a suspended account.
One message removed from a suspended account.
@earnest phoenix I'll try out the code and see if I can get the problem
One message removed from a suspended account.
One message removed from a suspended account.
${bot.user.tag}
One message removed from a suspended account.
${bot.user.tag}
${bot.user.tag}
One message removed from a suspended account.
${bot.user.tag}
${bot.user.tag}
One message removed from a suspended account.
me
@granite hedge like this? http://prntscr.com/jz7p3q
nah right before where you check the youtube url
async function() {
if (url.match(/^https?:\/\/(www.youtube.com|youtube.com)\/playlist(.*)$/)) {
const playlist = await youtube.getPlaylist(url);
const videos = await playlist.getVideos();
for (const video of Object.values(videos)) {
const video2 = await youtube.getVideoByID(video.id); // eslint-disable-line no-await-in-loop
await handleVideo(video2, msg, voiceChannel, true); // eslint-disable-line no-await-in-loop
}
return msg.channel.send(`β
Playlist: **${playlist.title}** has been added to the queue!`);
} else {
try {
var video = await youtube.getVideo(url);
} catch (error) {
try {
var videos = await youtube.searchVideos(searchString, 10);
let index = 0;
msg.channel.send(`dfsffds`)
}catch(e){} }
}
}
@granite hedge this comes up with a red line http://prntscr.com/jz7rcs
Anyone can send me a link to a open source anti-spam?
https://www.npmjs.com/package/discord-anti-spam not this its bullshit
@desert bough you need to give it a name
???
Ye, that would be an option, but I think it will be bad, and also much work
?
@spring ember what do u mean
anonymous functions exist
so it should work
@spring ember im not 100% sure what u mean
Send full code please
something like this? http://prntscr.com/jz7u1w
Yes
π
lol now theres something wrong with it ``` async function ytsearch() {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)
Wait umm
Wait can you send code
I really can't help you when I see this little bit
Wait is it in a class
I need full context if you hide stuff from me I really can't help you
i just sent it all https://hastebin.com/iwamumahaw.coffeescript
Umm what line is the thing you need?
there fixed it
add async there remove the function and other stuff we told you to add
now i get this ```client.on('message', async msg => { // eslint-disable-line
^^^^^
SyntaxError: missing ) after argument list
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)
how to get users roles map like message.author.roles.map
It has a map?
What is the issue I don't get it
@spring ember im confused on how to proceed
@desert bough use a syntax validator like http://esprima.org/demo/validate.html to see on what line your error is
just copy paste your whole code in it
http://bfy.tw/IlMQ @bold wigeon
can somebody help me?
post qu e s t i o n
http://prntscr.com/jz84xm
this is the problem
someone know how to fix it?
how to delete six
manually removal I suppose
@desert bough what node.js version are you running
it may not support the async/await syntax
so how to fix it
make sure you have at least 8.x.x
6.14.3
what?
why do you need to remove it 
update to the latest LTS
ok how can i update
im on a linux server
ah
http://prntscr.com/jz84xm how can i fix it
thats gonna be a bit more difficult
you will need to install whats called node version manager (nvm)
7.6.0+ for async/await
is it a good idea to ping the local database each time a message event has been received?
no
help with this?
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect string value: '\xEC\x9E\xAC\xEC\x9E\xA5...' for column 'username' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3974)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1197)
at com.fernandopal.ferchy.core.db.Database.loadDataToUsersTable(Database.java:300)
at com.fernandopal.ferchy.Ferchy.main(Ferchy.java:58)
https://github.com/creationix/nvm#installation follow this guide
@bold wigeon wots ur pip version
oh
then what do you suggest? I had an idea to ping the db once every second and hardcode the list into a variable
@tawdry fox what's db collation/charset
@ruby dust Why you need to call it every second
@gusty topaz done
Is there new data every second
idk the other way to check if a user is blacklisted or not rather than keep pinging the db
I need to be able to do it on on_message because that way it affects all commands at once
One message removed from a suspended account.
@ruby dust Blacklist for commands? Or just all the messages
@keen drift username varchar(100) latin1_swedish_ci
check if a user is blacklisted to use commands
Yeah then you prob query the db that often
but I'd build a small memory cache
of like
10 minutes
@tawdry fox try utf8, if it's 4 bytes per character, utf8mb4
ok
@desert bough you will need to run nvm use v8.11.3 every time you want to start the bot
wouldn't that mean that if I blacklist someone it will affect in up to 10 minutes rather than instantly?
@ruby dust In theory, but you could flush the cache for added ones
but without cache it'll work fine
db should be able to handle it
I've seen way more intensive operation working smooth
idk the way of doing it, since commands are in a cog file and the variable with a list of blacklisted ids are in the main file
Any Help
it appeared when i used target.roles.map(m=>m.user.tag)
can i have a bot
Make one
if the blacklist is within a file, load the file into memory
That's what this is for
any help
target is the user
So GuildMember?
Yeah m.user doesn't exist
wait
m is a Role object, which does not contain any user data
if you want to check if an user has a role. do something like target.roles.has(roleID)
target.roles.forEach(m => /... print m.name somewhere ../)
wait .array().split(" "); may help
you mean join/
but i am autistic
i want to remove /n
huh
split /n join ,
where is \n from
@keen drift same error
[LEVELING] ID of TheEpTic already exists
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect string value: '\xF0\x9F\x87\xB5\xF0\x9F...' for column 'username' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3974)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1197)
at com.fernandopal.ferchy.core.db.Database.loadDataToUsersTable(Database.java:300)
at com.fernandopal.ferchy.Ferchy.main(Ferchy.java:58)
(is on uft8) username varchar(100) utf8_general_ci No






