#development
1 messages · Page 605 of 1
If the bot say gets invited to someone's server and they don't have the emojis will it still display?
Or will just the ID print?
That's the only thing that is confusing me ATM, because I have the emojis on my support server, but if I add them to the bot in say a help/shop Embed near said item, I'm worried it won't display the emoji and will only display the <ID>
If that server allows the bot to use external emojis it will work
Understood!
So I can put just a little disclaimer then saying allow it for full effect
Thanks Wesley and advaith
Uhhh, how do you make rich embed not spew out an error?
Answers would be greatly appreciated
spewing out errors isn't the default state. Try reading them they'll tell you what's wrong.
const Discord = require("discord.js");
const client = new Discord.Client();
const DBL = require("dblapi.js");
const dbl = new DBL('Your discordbots.org token', client);
// Optional events
dbl.on('posted', () => {
console.log('Server count posted!');
})
dbl.on('error', e => {
console.log(`Oops! ${e}`);
})
so this shows how many servers is the bot on if im correct?
jep thanks
is some external portal where I can check somebody user is online? ;-;
no
:C
why do you need that?
I want make badge on my page which would show my status.
that is possible yes
you can use the oauth2 api to get user information with your own account
or have a bot report your status for you
user.presence.status
Returns online, idle or offline
Yes
the problem is, the api doesnt support unnatended access unless you're using websockets afaik
but for bot I want the same if it crashed
so you have to either have your website maintain a websocket connection, or use a bot to relay information
or maybe its possible to use the rest api with your bot token, idk, i havent used the rest api before
I thought it was an easier way, eg. badge as GitHub readmes
i looked at the discord docs, and it should be possible to use your bot token
try sending a request to https://discordapp.com/api/v6 using your bot token as the authorization header
Integrate your service with Discord — whether it's a bot or a game or your whatever you wildest imagination can come up with.
and here's the get guild member endpoint https://discordapp.com/developers/docs/resources/guild#get-guild-member
Integrate your service with Discord — whether it's a bot or a game or your whatever you wildest imagination can come up with.
I try it later
@real portal well the badge as GitHub Readme is just a website that has the image on it
I know how it works 😂
how can ı add my bot here
@quartz kindle @real portal you need a websocket connection to get online status
only presence update events give that information
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\alanw\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 255, in _run_event
await coro(*args, **kwargs)
File "C:\DiscordBotExport\snow.py", line 17, in on_ready
await client.change_presence(game=Game(name='CS:GO'))
TypeError: change_presence() got an unexpected keyword argument 'game'
can you guys help me
how to fix
first
have you looked in docs
dont give us your token also
okay
look
please help
are.... are you using notepad
yes then it is copied and run in python
wat
this guy is coding in 3019 while we are stuck in 1960
lol
its not game=Game
then what
ok
also I will dm you the official discord.py discord server
you can ask help there also
yes
NN2 please stop swapping servers
okay
i cant understand lol
read
Yes please red the docs first
Lol thanks spooder
its in the pins lol
ok but read http://slash7.com/2006/12/22/vampires/
just read that
bro please tell me codes that i want to change
No
no, read that
You won't learn that way
You need to understand what you did
what the error means
and how to fix
your error says your error
+_+
i'm pretty sure there's a rule that you can't spoodfeed people, @crude bane
He left
Probably is going to ask for the entire code because they don't want to learn
That is Pure Laziness
I looked there
like me using Discord Bot Maker for my first few bots
He asked how to fix
they gave fix
he ignored fix
asking to get fix
which was already given
then got it fixed
some people smh
Ye
hey, i recently made a crash game for my bot, but if someone were to bet 50 and cashout at 4, they would for some reason quadruple their balance or only lose 50
and idk why
yea
like i had to read the documentation for discord.js just to understand it, and i asked minor questions along the way
where should i send it
here
its to long for discord though
just that part
Put it in a hastebin
maybe a screenshot
yes
ok
stupid question is it stored externally
@unreal rampart I think its this
mal = [author, float(oldCoins) * float(stop)]
you are times it
well, lets say i go "-crash 50 1.6" if the bot chooses a number lower than 1.6 i lose, and if the bot chooses higher than 1.6 i win and what i bet is multiplied by when i cashed out (1.6 in this case)
Leaderboard Command Code: https://hastebin.com/xupasutoto.js
Problem: Bot don't send my real xp on leaderboard
No error in console
Hello! How do you make the bots game status to "Watching (how many guilds the bot is in)"??
read the docs
The latter will output all guilds your bot is in
The former will just output the amount
ye
You could separate that question into 2, actually
client.on("ready", () => { client.user.setGame(client.guilds.size) });
But whatever
Is that right?
client.on("ready", () => { client.user.setGame(client.guilds.size) }); @mossy vine
is that right?
yeah
thanks
if you want it to display "watching x" then continue reading the docs
actually no
dont use setGame
use setPresence
it works
setGame is deprecated
wait so
setGame works now, but will be removed any day
client.user.setPresence({ game: { name: client.guilds.size}, status: 'online' })
yeah
how do you define client?
var Discord = require("discord.js");
no
var client = new Discord.Client();
@mossy vine
are you sure its in your ready event?
ye
send code
client.user.setActivity(`${client.guilds.size} servers|${client.users.size} users`);
Works fine for me
but he is not even doing that
setPresence is Status like online, idle or offline
no lol
they almost the same
almost
client.user.setPresence({ game: { name: 'with discord.js' }, status: 'idle' })
client.user.setActivity('YouTube', { type: 'WATCHING' })```
what is wrong here? I know it's a syntax error, but what is wrong with it?
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNIQUE ON CONFLICT REPLACE,
money INTEGER DEFAULT 0,
bank INTEG' at line 2```
my SQL:
CREATE TABLE currency (
id UNIQUE ON CONFLICT REPLACE,
money INTEGER DEFAULT 0,
bank INTEGER DEFAULT (0),
bankmax INTEGER DEFAULT (1000),
inventory,
itemcount INTEGER DEFAULT (0)
);```
@magic smelt witam pana
anyone can help me with my bot's website i have some trouble
i uploaded my html website file to wordpress and i can't make it the homepage
i have wp file manager plugin
for example i cant type bot.com i have to type bot.com/bot
why wordpress if you're using plain html?
wp is great to use with themes, plugins and all the crap they have
so what can i do to use html only
a normal webhosting service
i use infinity free
anyway, idk your wp setup so i cant help with the configuration, but one of the things you can do is automatically redirect the base url to /bot
many websites do that
try it netlify
@quartz kindle can i show you the website and tell me if it's good
also, if you have a vps for hosting your bot, you can host your website there as well
just install a webserver like nginx and link the ip address to a domain name
there are services that offer you free domain names with custom dns
yes i know
you want to show me the website for a design evaluation?
yes
@unique nimbus i use mongodb for levels
hm
@magic smelt why do you make it start at index 1
And not 0
I'm guessing you have 2 documents saved in your database
And you're skipping the one that actually has xp
You should also add a limit to the query as if your bot grows you probably don't want hundreds of users displayed on it
You can do this using .limit()
Just put it after your sort
class mouseSetup {
constructor(ctx, shape) {
this.canvas = ctx.canvas;
this.ctx = ctx;
this.shape = shape;
this.canvas.addEventListener("mousedown", this.mouseDownReaction.bind(this))
}
mouseDownReaction() {
this.canvas.addEventListener("mousemove", this.mouseMoveReaction.bind(this));
this.canvas.addEventListener("mouseup", this.mouseUpReaction.bind(this));
this.canvas.removeEventListener("mousedown", this.mouseDownReaction, false);
}
mouseUpReaction() {
this.canvas.removeEventListener("mousemove", this.mouseMoveReaction, false);
this.canvas.removeEventListener("mouseup", this.mouseUpReaction, false);
this.canvas.addEventListener("mousedown", this.mouseDownReaction.bind(this));
}
mouseMoveReaction(evt) {
var bcr = this.canvas.getBoundingClientRect();
this.shape.newX = (evt.clientX - bcr.left)*(this.canvas.width/bcr.width);
this.shape.newY = (evt.clientY - bcr.top)*(this.canvas.height/bcr.height);
}
}```
When i'm doing this, whenever i let up my mouse it doesnt actually remove the mousemove listener because it still follows my mouse, i've added console.log's shpwomg these events ARE being ran it just doesnt want to remove them any idea why?
the code you gave us and the code the error says you have is different
^^ thats not how you use for loops
Yeah yikes
yeah i got it
how to create a function that will always work? js
Please be more descriptive @earnest phoenix
when the bot is running I want to call a function in which certain actions will be performed
How in client.on('ready',()=>{}) to call this function?
like send something when the bot are online?
@earnest phoenix
I can get the user that issued the command with ${message.author} right?
Yes, message.author returns a user
I just updated discord.py's pip and the client function stopped working, what should I do?
@earnest phoenix super late but thats the ready event. events fire when the action theyre listening to occurs. in this case, the ready event fires when your bot is ready, meaning the code you put inside of there will always run when the bot successfully turns on and connects. you dont have to call events
your question wasnt very specific so thats all i can really say
@slender thistle Yeah, I saw before that with the new version many things have changed, for now I'm going back to the old one, lol
Ah okay
@modern sable hello bro am fix my bot add my bot again
can you give me your bot ID?
invited it
@modern sable thanx bro
@delicate zephyr @coral trellis thank you buddy for help me lot 🙂
No problem
I run a bot on my pc how do I keep it on 24 7
buy a vps
you can either do that, host on glitch with uptime robot (not suggested), or you can use a raspberry pi system on your pc
don't use free hosting
that's why i have "not suggested" in parenthesis
i forgot to say, some vps systems that are good are https://discordapp.com/channels/264445053596991498/272764566411149314/435070769924538370
how to add emoji in bot status?
have you tried copying an emoji from a website and putting it into the status name?
i did that once and it worked for me
What code system are you using?
@real portal
code system?
language
they, im nonbinary but misgendering is okay bc you didnt know
as in like actually node.js or are you using general javascript
then i'd say your gender is it
yeah okay let's go with that
im running on three hours of sleep so fuck it
anyways @real portal node js coding or general javascript
or discord.js
^
discord.js
ye
For that I just copied and pasted an emoji into the game status and it worked for me
Might just be me being stupid but it worked
NevBot
ok that works, thanks
@York#0001 you can add "HostMyServer" for 2.5 € / month (EUR) 2GB ram - 1 CPU - 20GB SSD
and neesp.fr (French) 2 € / month - 1x E5-2680V4 - 2GB Ram DDR4 - 50GB HDD - Anti-DDoS : Game
he left the server
also i can reccommend hostmyservers.fr as well
good service for cheap price
i have 2.22€ on this website but, the vps is 2.5 😭
I would like some help for when its does a command the bot says on which shard it is (ping me)
You have to be more specific. What language are you using to code the bot?
the library matters as well
Discord.js so Javascript
This is for a command that says the number of servers that has more than 500 users and I would like her to specify the shard
@worldly obsidian which lib are you using
Discord. Js
you can have servers with 500 users across multiple shards. if youre only searching the shard that the guild sending the command is in, then <Shard>.id is the array reference of your shard (meaning it starts at zero)
to get the first shard, you use <Shard>.id + 1
message.guild.owner.user.tag in which channel type is user undefined?
i have already if (message.channel.type == "dm") return; before
message.guild.owner.tag
then .tag is undefined
Wait
message.guild.owner.user.tag works if i use eval for it on my server
the owner isnt cached
you have to request download of all users then you can use it
but it works on most Servers but sometimes says in console that user is undefined ^^
or use id
guildID: message.guild.id,
guildName: message.guild.name,
guildOwner: message.guild.owner.user.tag,
guildOwnerID: message.guild.owner.id,
guildMemberCount: message.guild.memberCount,
prefix: 'a!'
})```
im using it for enmap
owner isnt always cached. use client.fetchUser(guild.ownerID)
okay gonna try 😛 ty
you can use that too^
remember that its a promise and you have to resolve it to access the object
I forgot how to change status with eval how do you do that again?
!eval Client.user.setStatus(“meow”)
you mean client.user.setPresence?
nodejs uses " quotes :D
how to get number of category ? i try message.guild.category.size but doesn't exist
Do guilds have categories
👀
oh those
let category = message.guild.channels.filter(c => c.type === "category") like that ?
@earnest phoenix
.size
yes
okay
how using discord.js collect arguments with spaces: !command "first argument" "second argument"?
https://www.npmjs.com/package/djs-commands
has anybody used this?
i've only used fs for command handlers
@earnest phoenix i suggest Klasa
is that a npm?
it is but use their master branch from github
aight
thanks
im reading the docs rn
@real portal message.content.split(/ +/g)
Does anyone know how to keep a bot on 24 7 with discord bot maker
Dont use that shit app
Is there a bot that allows me to check invite leaderboards?
no, there isnt, at least im not aware of a method
@vale storm yes, search on the site lol
I've tried multiple but they don't work
Yes but you need to fetch invites, count invites etc @vale storm
he is asking for an already existing bot, and this aint the channel to ask that
I thought since its #development he meant how to make one lol
client mods
ban
but according to the d.js documentation its base10
so i guess you just convert it to hex?
convert base 10 to hex/rgb ez
oh okay
why does discord use base 10 colors instead of something that is standard everywhere like hex/rgb/hsl?
as you can see, discord is very unique and special
discord uses numbers
most languages already convert hex literals to numbers anyway
and storing a 3 byte number takes half the space than a 6 byte hex literal
isnt rgb also 3 bytes?
discord's color number is rgb
yeah but why represent it as another base?
numbers don't have base
json defines numbers as being encoded in base10
so you send them as base 10 text
after encoding to json
in memory, there's no base
just N bytes
but like, couldnt they store it as 000000000-255255255?
and use literally 3x as much space?
gg
On nodejs lib
webhookAuth: 'password'
Can someone give a link to explain what webhookAuth means 
like it is something we should setup on the website dashboard or something with the http server 
so it's not required ?
and i guess it's headers.password right ?
how would i add a reaction to the bot's message?
i have it like the following, and it's not working:
message.channel.send(sayEmbed)
message.channel.sayEmbed.react("⚔")```
what library are you using
node.js
and d.js
i'm not quite clear on how to use the .then, and so i'd rather not use it
thanks
np
yeet
one more question, @gusty tartan
how would i make it check for the user's id, and make sure it was the message author that reacted?
oof
use a reaction collector
if you are using d.js i'd suggest joining the proper server
okay wait
let m = message.channel.send(sayEmbed).then(m=>m.react("⚔").then(m=>m.awaitReactions(filter, {time: 30000})).then(m=>(collected => console.log(`Collected ${collected.size} reactions`)))).catch(console.error)```
I did that, right.
But it's saying that m.awaitReactions is not a function
message.guild.emojis.size
doesn't work
sad
i just miss the "s" at emojis

hey is there a link for embeding?
ping me or dm me if you find something
or i might find something on firefox
Wdym
are you asking how to embed?

guys i need help! sometimes a guild is on both my active shards at the same time and the bot responds double to users. Even after restart (pm2) its that way.
a guild is definitely not on two shards
google has an api idk how it works tho, but there's probably something better
nvm, found a way
regex scrape google images 
For my bot i kind of have hit a wall, im stuck at 18servers, i think most came from the 'new' page? is there anything else i can do other then have a few people vote on it? anyone have what they did?
ping me lol or dm
¯_(ツ)_/¯
Advertise it actively
make good bot -> people invite it -> people dont kick it -> people see it -> people use it
Go on forums, send it to your friends etc
baller thanks
Somehow my bot hit the API limit on discord after nearly 6 months of the same/similar style code, and the same code for about a month as a whole.
¯_(ツ)_/¯
I think I know what happened based on logs to my DB, which may be something that is a comment fix
oke sorry
Do i need now to fill code for the app.get or the module will do it him self 
i added this but the on vote event is never emitted
Is it allowed to create a customizable prefix per user? 
why wouldnt it be
some bots are silent on the server because they respond to more than three different prefixes

yeah but thats global. per user prefixes are defined willingly and only work for one user, no?
sure
hey
need some help
Error: Cannot find module 'C:\Windows\system32'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:496:3
dm me or tag me if someone can help me..
@graceful warren not sure if you’re joking or not, seems like a joke. But anyways, what’re you trying to do?
mhm, I want to make a spam bot discord to get t!reps
and it's not a joke
I mean to t!rep myself
I think the bot doesnt respond to other bots
Yep, it doesn't
Meaning that you physically can't
nop, account tokens
we won’t support you here
Self-bot, violation of Discord and Tatsumaki ToS
and I can get banned from discord?
Yep
Yes
thanks for the info I'll let it down
And period, no one here will help you, and hopefully most places.
Also discord.js removed user login support so you can’t even
lmao they did?
Latest version still supports it lmao
oh
Latest version of what?
Py or js
python
Oh ok
It's only the fact that you don't get your token through authorization header in network tab somewhere deep inside Discord requests
uuuuuuh hello yes i wrote a bot in python but idk what options i have to host it so i don't have to run it on my computer can someone point me in the right direction of some hosting options please?
Well you’re gonna have to pay for it
well yeah ik that
vps
^
best suggestion i can give you
The only really*
Sad I can't have all my XP as a list, just want to confirm before I have to completely rewrite or change can I just write them one after another?
Other methods to do this?
I mean you can if you add the id for each person with their xp
Noob here btw
Still learning is all
I need around 100 ish XP levels, but the json standard won't do the trailing commas
oof I mean idrk myself
you can’t have commas after the last value in the json
It's not the last value
I need to add around 40 more, I can just write them all out, just wasn't sure if it's going to blow up on me because of the large list
How often can I update the game on my bot without it being API abuse
it isn’t but that trailing comma error is due to you doing this
{
1,
2,
3,
}```
instead of
{
1,
2,
3
}```
i believe it is 5 minutes iirc
Okay okay! I see, so it's not going to blow up if I continue down the list?
the point is, the last value can't have a comma after it
so if you need to add more it shouldn't be an issue
unless you have 3 bytes of ram or something
you should be fine with the json if you add more
Thanks guys I guess I'll just give it a red hot go
ohh hi
A guide made by the community of discord.js for its users.
how to get correct info at ram usage by my bot? i'm looking for bot informations and i see various values, and i don't know my bot shows reliable value
psutil is good
30mb of course
node.js
node.js by itself uses around 60-70mb
so its normal for a discord.js bot to use 100mb+
even with very little guilds
So i am trying to install mysql but i keep getting this error, not sure what this means
damci, use process.memoryUsage().heapUsed / 1024 / 1024 to get your current memory usage in kb
😮
@queen bone can you share the log?
Yeeess, that command helped, thank you all for help

ill remember that command when im having a similar issue
@carmine echo maybe like one change per minute?
even half a min would probably be ok
Yea I decided to do 30 sec
Does .toString() not actually ping the role?
Ah I see nvm

Nvm I dont it wont actually tag the role lol
Lmao nvm I'm just dumb
It wasnt that
kay
i can't figure out exactly what is wrong with this? am I missing a bracket somewhere that I'm not seeing or am I using outdated code or something?
the double }}
and yes i have the require discord js thing at the very top, this is a bottom thing
^
and another }
What's with the 2 }} on 432
im dumb is what

get a linter
im blind my god
also, you should probably separate your code because 430 lines is absurd
also the command i did isnt even working so im like,,,,, wasted question
well nothing will work if you dont join a channel so uh
guys - I just made a bot, is running on a vps, great. Now I need to show it to some guys for review, how do I go about that?
send them the bots invite link
you submit it for review on the website
invite them to a private server, add the bot, let them test it
https://discordjs.guide, you should really read this nev
i didddddd
@idle basalt where do I get that invite link?
I have Dumb Bitch Syndrome
your bot page in the discord dev dashboard
or you can generate one through code (the method depends on which lib youre using)
actually, every lib can generate an invite
ah oka
https://discordapi.com/permissions.html just get your client id from the development page @lyric canyon
A small calculator that generates Discord OAuth invite links
thats not necessary
/yardım
the native discord dev dashboard creates the whole link for you
from my experience it only creates one without permissions attached
it just adds the bot scope and you have to manually add permissions
@idle basalt I don't have an option to generate a link
unless im just stupid and dont know what im doing half the time
Do you mean, send them a link like this? https://discordapp.com/oauth2/authorize?client_id=bla&scope=bot&permissions=2048
yes
Ok cool, thanks guys!
yes
just replace bla with your client id
nev, if you visit the oauth2 tab in the dev portal and select the bot scope, youll get a permissions checklist below
Is there a clear guide on how to 'publish' or whatchamacallit the bot when everybody's happy?
here
let me get a screen shot
if only i wasnt on mobile lol its too hard to take good screenshots
nvm
why does this while loop go infinite times?
gjett = Guess
forsok = Tries
bokstav = character
Because forsok never becomes 0 @unreal rampart
The else statement only happens when the if statement is false
So if the if statement is True the else won't happen.
And you have an if, else statement wrapped in a different if else statement
So thats probably where something is messing up
d.js
Hey. help make command which displays the leaderboard from the level.json file.
require the file and iterate over the values
cant give specific advice without seeing your structures. also, you probably dont want to use json files as a database for user xp
{
"3666074412xxxxxxxx": {
"xp": 75702,
"level": 32,
},
"4069125348xxxxxxxx": {
"xp": 51316,
"level": 28,
},
"4564881476xxxxxxxx": {
"xp": 40977,
"level": 25,
}
}```
iterate over the values with Object.values() to sort them and then post them however you like
But can you give an example, I tried many ways but nothing happened
Object.values(yourjsonfilehere).forEach(val => console.log(val))
if you also want the key, use Object.entries(yourjsonfilehere).forEach(([key, val]) => console.log(key, val))
anyone who uses discord.py for their discord bot, because I have no clue how to implement the trigger_typing() method and how to disable the help command, so help would be appreciated, btw i tried reading the docs but i am hopelessly lost
You want to remove the default help command @fading zealot?
yes @pastel tiger
bot.remove_command("help")
If you defined it as client then make sure to swap bot out with client
oh thanks that worked
No problem
do u know how to do the trigger_typing() thing @pastel tiger ?
await ctx.channel.trigger_typing()
what is ctx
it stands for context
is it the same as context?
async def googler(context):
1.0.0
Rewrite then
?
Well ctx is a required argument for commands
1.0.0 is also called the "rewrite" version
yeah
Im guessing you need this for a command?
yes
so i mostly copied the code from a tutorial, and dont know how some of it works
ok
@pastel tiger
@client.command(name='google',
description="format: -google <optional: [(number of results) <= 9]> <query>",
brief="Googles Stuff",
aliases=["search"],
pass_context=True)
async def googler(context):
await client.tr
a = context.message.content
stuff = ""
try:
b = int(a[8])
except:
query = a[7:]
num = 2
else:
query = a[9:]
num = b
search_results = google.search(query)
for i in search_results[:num]:
name = i.name[:i.name.index("/")-6]
stuff += f"**{name}**\n{i.description} \n(<{i.link}>)\n\n"
if len(stuff) > 2000:
await client.say("Bro your request size is to **big**, try and tone it down maybe a little bit")
else:
await client.say(stuff)
Did you write that or a straight copy?
i wrote this, but copied the frame work
What is your traceback?
this is one i copied straight
@client.command(name='8ball',
description="Answers a yes/no question.",
brief="Answers from the beyond.",
aliases=['eight_ball', 'eightball', '8-ball'],
pass_context=True)
async def eight_ball(context):
possible_responses = [
'That is a resounding no',
'It is not looking likely',
'Too hard to tell',
'It is quite possible',
'Definitely',
"No you're just bad, plus you owe me money"
]
await client.say(random.choice(possible_responses) + ", " + context.message.author.mention)
what is traceback?
sorry i am unexperienced
The error
nothing, i just need help implementing the trigger_typing() command
A cog is a seperate file with commands
await channel.trigger_typing()
This is what i can think of
Or
await client.channel.trigger_typing()
ok so i did await channel.trigger_typing()
and got NameError: name 'channel' is not defined
Define channel
so i would do channel = context.message.channel?
Yes that should work
now i got AttributeError: 'Channel' object has no attribute 'trigger_typing'
i did
channel = context.message.channel
await channel.trigger_typing()
You must fetch the channel directly and then call the appropriate method. Example:
channel = client.get_channel(12324234183172) await channel.send('hello')
I was probably mistaken on the channel
I have never used this method before so i have no other ideas
ok how do i do that then?
async with channel.typing():
# do expensive stuff here
await channel.send('done!')```
ah
you dont need to get the channel by id, you can use message.channel as you were using
ok
where would u put async with channel.typing():
@client.command(name='google',
description="format: -google <optional: [(number of results) <= 9]> <query>",
brief="Googles Stuff",
aliases=["search"],
pass_context=True)
async def googler(context):
a = context.message.content
stuff = ""
try:
b = int(a[8])
except:
query = a[7:]
num = 2
else:
query = a[9:]
num = b
search_results = google.search(query)
for i in search_results[:num]:
name = i.name[:i.name.index("/")-6]
stuff += f"**{name}**\n{i.description} \n(<{i.link}>)\n\n"
if len(stuff) > 2000:
await client.say("Bro your request size is to **big**, try and tone it down maybe a little bit")
else:
await client.say(stuff)
@quartz kindle ?
no idea, i dont use python, i just showed you what the docs say xd. but my guess would be anywhere as long as you define channel, you could try defining it right after context
ok
@fading zealot you add that before the block of code you want to be executed while your bot will be typing
like this?
@client.command(name='google',
description="format: -google <optional: [(number of results) <= 9]> <query>",
brief="Googles Stuff",
aliases=["search"],
pass_context=True)
async def googler(context):
async with context.message.channel.typing():
a = context.message.content
stuff = ""
try:
b = int(a[8])
except:
query = a[7:]
num = 2
else:
query = a[9:]
num = b
search_results = google.search(query)
for i in search_results[:num]:
name = i.name[:i.name.index("/")-6]
stuff += f"**{name}**\n{i.description} \n(<{i.link}>)\n\n"
if len(stuff) > 2000:
await client.say("Bro your request size is to **big**, try and tone it down maybe a little bit")
else:
await client.say(stuff)
try it x)
d.js
help make command leaderboard tables from a json file. Here's what I got.
const userpro = require("config/userpro.json");
const Discord = require("discord.js");
exports.run = async(bot, msg, args) => {
let completeString = '';
Object.entries(userpro).forEach(([key, val]) => {
let rankString = `${key} - ${val.xp} - ${val.level}\n`;
completeString += rankString;
})
console.log(completeString)
}```
How can this be limited to 10. and sort?
ok
@rocky gyro now i have AttributeError: 'Channel' object has no attribute 'typing'
try just context.typing() ? idk
oh you're using async
well i really have no idea xD
well that didnt work
i thought you said you were using rewrite 🤔
async is the old version which isnt good
things like slowmode and nsfw check aren't (easy) to access using async
@bright spear i am using rewrite
malarne says you're using async 
when was rewrite made?
as well as await client.say(stuff) is now await channel.send(stuff)
it's been a while now
how do i upgrade?
but clearly, you're using async
pip install discord.py should now install rewrite by default iirc
just know that it's gonna break your code A LOT
Requirement already satisfied: discord.py in c:\users\<>\appdata\local\programs\python\python36\lib\site-packages (0.16.12)
Requirement already satisfied: aiohttp<1.1.0,>=1.0.0 in c:\users\<>\appdata\local\programs\python\python36\lib\site-packages (from discord.py) (1.0.5)
Requirement already satisfied: websockets<4.0,>=3.1 in c:\users\<>\appdata\local\programs\python\python36\lib\site-packages (from discord.py) (3.4)
Requirement already satisfied: chardet in c:\users\<>\appdata\local\programs\python\python36\lib\site-packages (from aiohttp<1.1.0,>=1.0.0->discord.py) (3.0.4)
Requirement already satisfied: multidict>=2.0 in c:\users\<>\appdata\local\programs\python\python36\lib\site-packages (from aiohttp<1.1.0,>=1.0.0->discord.py) (4.5.2)
Requirement already satisfied: async_timeout in c:\users\<>\appdata\local\programs\python\python36\lib\site-packages (from aiohttp<1.1.0,>=1.0.0->discord.py) (3.0.1)
thats what i got
it says v 0.16.12
-> async
wait i'm gonna check out that
@fading zealot pip install --force-reinstall --no-cache-dir discord.py --user maybe ?
i got
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\users\\<>\\appdata\\local\\programs\\python\\python36\\lib\\site-packages\\~ultidict\\_istr.cp36-win_amd64.pyd'
Consider using the `--user` option or check the permissions.
retry x)
pip install --force-reinstall --no-cache-dir discord.py>1.0.0 --user ?
is your bot running or anything using it?
wellll..... yes
shut it down first lol
ooops
just know it'll be broken until you fix all your code to work on rewrite
yes, that should be rewrite
it should be rewrite now
ok thx
and i'm absolutly not gonna hold your hand into every change you now have to do on your code, because i'm gonna sleep lol
nah i get u, i just needed help because i was looking for a command that didn't exist
https://discordpy.readthedocs.io/en/rewrite/ just use that link
ok thx
the rewrite docs are pretty good, you should find everything you need here. its a single page, just scroll and scroll and scroll xD https://discordpy.readthedocs.io/en/rewrite
yup
what is a way i could save user-specific non-api data somewhere? like if i wanted a point/currency system or something for my bot
yes?
Use the link I sent instead
it says 1.1.0a in the corner though, isnt that the earlier version
latest isnt async?
oooohhhhhh
rewrite was released
ok, im learning the new syntax now

so how can i save user-specific non-api-related data, like if i wanted to give my bot a currency system or something
Introducing databases!
i know what a database is, ive just never used a database with javascript before (im using node js for my bot)
There are plenty of databases
you want to choose one that's good and that you like
oh apparently node js works with mysql, i know mysql d:
i am having issues, i tried the second link that you provided, and did everything as per the instructions, but now i am getting this error:
Unhandled rejection SequelizeDatabaseError: SQLITE_NOTADB: file is not a database
at Query.formatError (/home/runner/node_modules/sequelize/lib/dialects/sqlite/query.js:419:16)
at Query._handleQueryResponse (/home/runner/node_modules/sequelize/lib/dialects/sqlite/query.js:73:18)
at afterExecute (/home/runner/node_modules/sequelize/lib/dialects/sqlite/query.js:247:31)
at Statement.errBack (/home/runner/node_modules/sqlite3/lib/sqlite3.js:16:21)
this is a fuction reportschannel.send("message ")
but i got (node:1652) UnhandledPromiseRejectionWarning: TypeError: reportschannel.send is not a function
and i have let reportschannel = message.guild.channels.find(`name`, "logs"); if(!reportschannel) return message.channel.send("Plz Run a.setup");
anyone know why this is happining
I think that way of using find is deprecated
Might be using too high of a version to use it like that
@soft eagle
yeah
change the way you defined reportschannel
let reportschannel = message.guild.channels.find(c => c.name === 'logs');
ah ok
does anyone have some anti-discord-invite RegExp i can steal
i'd rather not put effort into making one if it's already been done
nevermind i found a decent one, here it is if anyone wants to use it .*(?:https?:\/\/)?discord(.*(gg|com|app\.com))\S?([A-Za-z0-9]+){7}.*
not sure how effective it is but it catches invites which works for me
yes
add io to link endings
How would i allowed more then one owner to use dev commands etc
"owner" : ["528832428463095818"],
["456", "123"] for lists
would it work even if i do it this way if (message.author.id !== client.default.owner) return message.channel.send("Failed, you tired to use a dev command!");
Oh how would i go about it then?
if(client.default.owner.includes(message.author.id)) {
return message.channel.send("Failed, you tried to use a dev command!");
}```
@mossy vine I tried that but not working?
"owner" : ["528832428463095818", "554186251612323842"] is what i have in client.default
oh right
i forgot to negate it
if(!client.default.owner.includes(message.author.id)) {
return message.channel.send("Failed, you tried to use a dev command!");
}```
@earnest phoenix thats what you need
youre welcome, sorry i didnt get it right the first try im tired lol
const mention = new RegExp(`^<@!?${bot.user.id}>`);
const prefix = `${message.content.match(mention)} ` ? `${message.content.match(mention)} ` : db.default```
i'm trying to do a space
between mention and args
like @user ping
but doesn't work idk why
its probably an issue with your regex
Regex101 allows you to create, debug, test and have your expressions explained for PHP, PCRE, Python, Golang and JavaScript. The website also features a community where you can share useful expressions.
great site for making and testing regex
Hey, does anyone know how I can put a YouTube API key into my code and allow my bot to connect to it? Google isn't providing clear answers.
And no, I don't have code ready yet.
what do you need to do with the youtube api?
you dont need a youtube api key to do that
It isn't letting me connect, and somewhere it said that I needed one
what lib are you using?
Discord.js
for youtube
I'm confused
so you just want to play music from youtube in voice channels?
Yeah
there are several libraries/packages you can do it with
ytdl-core, lavalink (optionally discord.js-lavalink), etc.
I've tried to code it into NevBot several times. I have the music player thing installed
It's the yt-dl one that I have
I don't know if I installed FFMPEG wrong or not, though
I'm pretty sure I installed node opus right tho
@mossy vine i think its bc i have a handler let commandfile = bot.commands.get(cmd.slice(prefix.length)) if(commandfile) commandfile.run(bot,message,args); just this
Guys i have a strange problem. I use discord js and pm2 on my digitalocean ubuntu vps. Sometimes, (i think after getting an error+ pm2 restart) the bot starts to send messages twice / two bots are running and have the same server on them. The bot is sharded but only running on 1 shard with 1k guilds. What can it be?
module.exports = async (bot, member) => {
const lID = await db.fetch(`lChannel_${member.guild.id}`)
if (lID === null) return;
let lId = member.guild.channels.get(lID);
if (!lId) return;
const wID = await db.fetch(`wChannel_${member.guild.id}`)
if (wID === null) return;
let wId = member.guild.channels.get(wID);
if (!wId) return;```
(node:12590) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
I have that error
someone know how to fix that?
console.log(member) returns what?
someone?
const gettotal = format(number)
const result = Math.round(gettotal)
message.channel.send(result)``` when i remove "Math.round" the bots says `120,000` and when i re-add him, the bots say `NaN`
a comma
?
, !== .
Math.round convert number with commas
so, how to round a number with formated number and with commas ? 
Round before format
its not possible
👀
bruh moment
In your example there's no reason to round
Correct
What result are you expecting
..?
i'm just testing something for my database, show coins 120,000 to 120K
That's not what round does?
no because in my db number doesn't have ,
and i need to do format(number) for get ,
You want to use Math.round() to remove the numbers after the comma?
yes
Ok well it makes sense that that doesn't work
lol
Create your own function that removes them?
its hard
👀
i can but, idk if the bot send number of coins in a channel and fetch him, its an api abuse
what
wat
just the bots send 120,000 in a private channel and then fetch the message for round him 
why would you do that again
Your format function is a function you made?
Or create your own function for it
Like
If a number is bigger than 1000 -> divide by 1000 -> add "K"
Shouldn't be that hard to create a function like that
yeah i do that in my old bot, but bots stop at the first function
Uh
@late hill i just remplaced , by . and its working
You're changing 120000 to 120.000 now
100 000 isnt 100.000