#development
1 messages ยท Page 832 of 1
[Python] how can I remove all word duplicates from a string/list, example: lets say I have a string that is "Hello Im Hello Pynter Im" so I need it to be "Hello Im Pynter"
How much time ago? -__-
I found it
but when i do canalestatusbot.send "send" appears as a word and not a object
@solemn quartz ^
what appears as a word?
just a word, lets say if i have two ',' in it i want to keep them
@narrow kettle arrays.pop(number in the list)
thanks, I'll look into it :>
@solemn quartz do you want to send an embed?
yea
You need to use
@narrow kettle "".join({*message.split(" ")}) maybe
not sure if it keeps order
canalestatusbot.send({botOnline})
@solemn quartz
send(embed) works too
@narrow kettle something like "".join(OrderedSet(message.split(" "))) possibly
@pale vessel he renamed it
He said python
o h
who what python?
Pynter
there's too much people that need help
ah yeah
i was talking to bg super
ah hahah
array.pop(number in the list) works to @earnest phoenix
Would this work for aliases
if(!client.commands.get(cmd.slice(prefix.length)) || !client.aliases.get(cmd.slice(prefix.length))) return;
client.commands.get(cmd.slice(prefix.length)).run(client,message,args);
client.aliases.get(cmd.slice(prefix.length)).run(client,message,args);```
if (command.aliases && Array.isArray(command.aliases)){ command.aliases.forEach(alias => client.aliases.set(alias, command.name));}```
it's not python
whats not python?
Ik and I am aware
I didn't accidentally code js while tryna code python
Lmao
@golden condor ok so i don't think client.aliases.get(cmd.slice(prefix.length)) requires aliases to be the same length as prefix
Try {embed: botOnline}
No
like i said send(embed) or send({embed: embed}) works
@earnest phoenix python
It removes the prefix from the alias
@earnest phoenix that's js
idk
js
btw the error is
(node:12340) UnhandledPromiseRejectionWarning: DiscordAPIError: Cannot send an empty message
at C:\Users\nope\Desktop\Super Bot\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15
at C:\Users\nope\Desktop\Super Bot\node_modules\snekfetch\src\index.js:215:21
at processTicksAndRejections (internal/process/task_queues.js:94:5)
(node:12340) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:12340) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
canalestatusbot.send({embed: botOnline}) @solemn quartz
@golden condor ahhh right so not the command hahah
Yeah
command handler
I was tryna add aliases to my bot
however. i think what u want is slice(0, prefix.length)
no?
ignore me
im dumb
Same
all right, where did you define the commands?
It works fine for commands
ok so how does client.commands.get work
client.commands?
I have client.commands = new Discord.Collection()
whats a discord collection 
map
Commands
canalestatusbot.send({embed: botOnline})@solemn quartz
@earnest phoenix IT WORKED
FUCK YEAH
now i set the color :p
do all your commands not have arguments?
Now my command handler doesn't work at all lmao
revert
did u touch the command part
no right? the slice and commands.get is still fine?
That was always fine
i'm guessing it's something like client.commands.get("ping") to fetch the command
*is still identical to original?
I have code for aliases but my command handler is different
ok

don't worry
client.commands.get(cmd.slice(prefix.length)).run(client,message,args);
client.aliases.get(cmd.slice(prefix.length)).run(client,message,args);
hmm
It gets the args
you can put || and find the alias
Yeah but that won't work it
here might be the problem?
Already done that
thats the problem
In index.js
set it to command not command.name
define the aliases inside the command
I have
Like this
in the collection, there should only be command name and the command itself
you can access the command and find the alias
in the foreach
aliases
what do u set it to
andcommands
set(what, what)?
don't make it complicated
maybe I can help on glitch?
if u have the command name in aliases.
client.commands.get(client.aliases.get(cmd.slice(prefix.length))).run(client,message,args);
-_- rip
Hold on
u have bad wifi
I am loading up vsc and the glitch extension
i don't
Yeah Arun is right
client.commands.set(commandName, command);
if (command.aliases && Array.isArray(command.aliases)){ command.aliases.forEach(alias => client.aliases.set(alias, command.name));}
f
I have it open using the vsc extension
so you'll have to get it from commands after getting from aliases, no?
you just need to put aliases inside the command and access it from client.commands. that's it
oH
try client.commands.get(client.aliases.get(cmd.slice(prefix.length))).run(client,message,args);
because alias is the name right?
You're making it complicated
No
so its tryin to run the name
client.aliases 
And then I want other version
you don't need it.
Your pfp define your reaction @earnest phoenix
Like say avatar and pfp
you just need to put aliases inside the command and access it from client.commands. that's it
but you did this right client.aliases.set(alias, command.name)???
Yes
exactly.
what's inside your command file? let's say ping
are <reaction>.users.size and <reaction>.count always the same?
so. then it's client.aliases.set(alias, command)?
@grizzled raven should be, yes
don't let him do that
if (!client.commands.get(cmd.slice(prefix.length)) || !client.commands.get(client.aliases.get(cmd)))return;
client.commands.get(cmd.slice(prefix.length)).run(client,message,args);
if (client.aliases.has(cmd.slice(prefix.length).toLowerCase())) {
client.commands.get(client.aliases.get(cmd.slice(prefix.length).toLowerCase())).run(client, message, args)
}``` What about this
ok so depends whether u have client.aliases.set(alias, command.name) or not tbh
can you console log your client.commands?
if client.aliases.set(alias, command) then the original should work fine
if it's client.aliases.set(alias, command.name) then this new version should work
@earnest phoenix mo
No
also one thing. i'd put cmd.slice(prefix.length) and cmd.slice(prefix.length).toLowerCase() in a variable
If he did it cmd.run will not work
I'm sorry I am really confused
@pale vessel explain how your thing would work then
Cxllm
I'm sorry
Somebody is confusing you
client.commands should have only the command name and the command itself, which have the aliases needed
Yes
client.commands is a dictionary yea
Ok
you can access client.commands and see if the alias exist inside a command
Can't you just access the command file?
ehh
that's what I said
that's even more complicated
no?
learn module.exports
More like getting string from object
what i suggest is setting 2 keys in command to the same thing
@earnest phoenix congratulations i guess but this isnt place for that
Yep
Please don't make me more confused if possinle
Nicw
Right this is my code in handling it
let command = require(`./commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, command);
if (command.aliases && Array.isArray(command.aliases)){ command.aliases.forEach(alias => client.aliases.set(alias, command.name));}```
Send a format of your commands @golden condor
Ok
okay. do this: console log the command collection
Wait no
@golden condor lets try the easy way
you're the one who does that
Wrong thing sorry
@earnest phoenix if i want to do the same thing, but when it is offline how do i do this?
client.commands.set(alias, command)
no.
bot.off('ready', bla bla)
on*
i dont think ready statuys good with off lol
I will show
Use disconnect
?
disconnect is for voice channels

nope
Then nothing
๐คฆโโ๏ธ
try what i said cxllm
i think im going to figure it out my self
What did you say
if it's offline, how can it send a message
client.commands.set(alias, command)
Bot never have event off
@pale vessel lol
because it's not like the ever conflict right?
The aliases are already set!
require(command)?
read the pastebin @pale vessel
Look at the hastebin!
@golden condor i mean put them in the command lookup
the just put aliases inside the command object
How
so if u commands.get an alias
its already there
client.commands.set(alias, command)
aliases: ["pong"]
You don't need client.aliases
Yes
^
Exactly
Ok
In the message event waht do I do
I mean
@golden condor use the old code
message.js
the only line u need to add from the working version
The format you send
is this
Have cmd.run
if (command.aliases && Array.isArray(command.aliases)){ command.aliases.forEach(alias => client.commands.set(alias, command));}
Run and aliases
Ok
This is my code
const config = require("../config.json")
let prefix = "c!"
const Discord = require("discord.js")
const fs = require("fs")
exports.run = async(client, message, msg) => {
if (message.author.bot) return;
if (message.channel.type == "dm") return ;
const db = require('quick.db')
let prefix = await db.fetch(`prefix_${message.guild.id}`);
if (!prefix) {
prefix = 'c!'
}
if (message.content.startsWith(prefix)) {
let messageArray = message.content.split(" ");
let cmd = messageArray[0];
let args = messageArray.slice(1);
if(!client.commands.get(cmd.slice(prefix.length))) return;
client.commands.get(cmd.slice(prefix.length)).run(client,message,args);
}
}```
if it's offline, how can it send a message
they actually can, sending messages is a REST endpoint, you don't have to be connected to the gateway for it
@earnest phoenix ๐คฆโโ๏ธ
ya
what @earnest phoenix ?
that should work if u set up the commands with that new line
What credentials are needed to post a message, again?
Not working
It'll not
no wait
hang on
What credentials are needed to post a message, again?
it's literally an api endpoint, you just need the token in the Authorization header
do u have the thing with client.commands.set(alias, command)
Yes
Yeah and it make your bot online @earnest phoenix
weird.
what @earnest phoenix
right below the client.commands.set(commandName, command); right
hahah
We are talking about bot is offline like fully not offline status
In the commands
cxllm if you let me see your glitch project I can probably help you
are you blind
So guys?
Ok
it's literally an api endpoint, you just need the token in the Authorization header
Not sure what I was expecting ๐คฃ
I will dm you
I'll remove the token
You use token for sudden moment it'll connect your bot to gateway
@golden condor not talking to you
I am taling to flazeoe
Yeah I made a spelling mistake
this is becoming a loop
But still it needs to connect to discord api
are you blind my dude
it doesn't need to connect to the gateway
when someone answrs to it ping me
@solemn quartz
what
lol
@golden condor -_- it should literally just be 1 line tbh
Hey cry! I seeeeeeeeeeeeeeeeeeeeeeeeeeeee youuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
What?
not sure what flaz is sayin but sounds complicated
this thing
if (command.aliases && Array.isArray(command.aliases)){ command.aliases.forEach(alias => client.commands.set(alias, command));}
category = await message.guild.channels.create("////////////", {
type: "category",
position: 0
})
```how can i make the category be at the top?
But still it needs to connect to discord api
@earnest phoenix It doesn't need a gateway connection
You just send a HTTP request with your bot's token for auth
wtf is that @earnest phoenix
It's a one-time HTTP request comrade
@earnest phoenix Discord bots need to connect and identify to the gateway to send a message
Oh post
Discord bots need to connect and identify to the gateway to send a message
no they do not
@earnest phoenix bro
look at the image above
Gateways are Discord's form of real-time communication over secure WebSockets
yup
they have to connect once
that says ONCE
yes
in a lifetime of the app
yeah
But that sudden moment of time it connects
gateway is only if you want websockets is it?
yes
oh lol
and to people who say you need to be connected to the gateway to send them
you do not
so how the fuck do i fix it?
whats broken
i didnt even started scripting it
oh
Idk how to do that
๐
feels a bit hacky
but i mean it's basically the simplest way to do it so 
look for your library's disconnect event
thanks
category = await message.guild.channels.create("////////////", {
type: "category",
position: 0
})
```how can i make the category be at the top?
@fallen arch anyone know why?
once the event fires, grab your channel and send a message to it
@solemn quartz http POST request
I already told him about disconnect event
@fallen arch u want to move the category?
when creating
hmm
i want the category to be at the top
do i do something like this?
bot.off('ready', () =>{
const botOffline = new Discord.RichEmbed()
.setTitle('Sono Offline!')
.setThumbnail(${bot.user.avatarURL})
.setColor('idk what red hex color is');
const botsupportserver = bot.guilds.find(guild => guild.id === "673538782707974196")
const canalestatusbot = botsupportserver.channels.find(channel => channel.id === "691244815861547058")
canalestatusbot.send({embed: botOnline})
})
idk how to do this
Bot.off isn't something
yep
position 0 not working huh...
Go to discord.js.org and find disconnect event
@fallen arch where is it creating it
it'll show up with anything you type in
the autocomplete isn't valid because js isn't typed
the IDE/editor doesn't know what exists and what doesn't
@solemn quartz go to discord.js.org
IDE knows if u have an extension for your library
or a good linter/extension
OKAY
category = await message.guild.channels.create("MEMBER COUNT", {
type: "category",
position: 0
})
this is creating the category
also .off('ready' doesnt make sense anyway
ya where is it placed @fallen arch
READY is an event fired by discord through the gateway to tell you that your bot has finished receiving all available guilds
at the bottom
@earnest phoenix he is a beginner
it is defaulted to the bottom
but i want it to be at the top
@earnest phoenix he is a beginner
@earnest phoenix fuck you : )
in any guild i want it to be at the top
u have more than like 3 categories right
also
.off('ready'doesnt make sense anyway
@earnest phoenix ik lol
hmmm
Is there a event for a reactionCollector that detects when someone removes a reaction from a message? right now I have it on collection.on("remove") but its still not working :/
hmmm
then im fucking ded
u have more than like 3 categories right
@earnest phoenix yes
How To Keep my Bot Online 24/7
weird...
im just gonna watch a bad yt video on how to make a webhook make a message when the bot goes down
@hollow granite read the docs. they state that the remove event is only fired when all reactions are removed, dispose event is fired when a single reaction is
@robust moth host it on vps
@earnest phoenix wrong
it's the other way around
nevermind
yeah
Will emit on all reaction removals, as opposed to Collector#dispose which will only be emitted when the entire reaction is removed.
hahah yeah
which is weird
@earnest phoenix i am using glitch
@hollow granite u console.logged inside the on('remove' to see if it's working?
Ask glitch support @robust moth
We're not glitch
^

glitch turns off by default
stop using free hosting
@earnest phoenix they can
i never said they can't
And they will maybe they don't have money
I know thak @earnest phoenix
@robust moth this is a hack https://support.glitch.com/t/how-to-make-a-glitch-project-to-run-constantly/2439
hmm
?
what happened
if u mean that it's not a real "hack" the glitch people posted there and are fine with it
anyway... re: category
lookin through the docs and they renot helping ๐ฆ
Yeah, i've tried both dispose and remove but i havent got either to work. But collect works just fine. Maybe i am making a dumb mistake?
const filter = (reaction, user) => user.id == msgAuthorID
const collector = await startMsg.createReactionCollector(filter, { time: timer * 1000 });
collector.on('remove', (reaction, user) => {
console.log("REMOVED")
})
collector.on('dispose', (reaction, user) => {
console.log("DISPOSED")
})
collector.on('collect', (reaction, user) => {
console.log("COLLECTED")
})```
maybe permissions idk tbh
@robust moth check glitch status
They always have a glitch
at Object.run (/app/commands/guild/autorole.js:59:98)
at Client.<anonymous> (/app/luffy.js:117:13)
at Client.emit (events.js:201:15)
at MessageCreateAction.handle (/rbd/pnpm-volume/228a8c0d-8425-40da-b0ab-ae02f7a524e3/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/client/actions/MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (/rbd/pnpm-volume/228a8c0d-8425-40da-b0ab-ae02f7a524e3/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/rbd/pnpm-volume/228a8c0d-8425-40da-b0ab-ae02f7a524e3/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/client/websocket/WebSocketManager.js:386:31)
at WebSocketShard.onPacket (/rbd/pnpm-volume/228a8c0d-8425-40da-b0ab-ae02f7a524e3/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/client/websocket/WebSocketShard.js:435:22)
at WebSocketShard.onMessage (/rbd/pnpm-volume/228a8c0d-8425-40da-b0ab-ae02f7a524e3/node_modules/.registry.npmjs.org/discord.js/12.0.2/node_modules/discord.js/src/client/websocket/WebSocketShard.js:293:10)
at WebSocket.onMessage (/rbd/pnpm-volume/228a8c0d-8425-40da-b0ab-ae02f7a524e3/node_modules/.registry.npmjs.org/ws/7.2.3/node_modules/ws/lib/event-target.js:120:16)
at WebSocket.emit (events.js:196:13)
(node:29419) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:29419) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
help
have you tried reading the error
yes
and what does it say
idk LOL
then you haven't
now what's problem
What's code
autorole
I said send the code
LOL ๐คฆ
thanks
lmao
@quartz kindle yeah lmao
Real dev finds a solution first before asking
๐
real devs debug before asking stupid questions
real devs rarely ever need to ask questions
guys
i think i will wait 52104129401824184012084 years before of doing that bot.off thing
I WANT TO DEVELOPE MY OWN BOT MUSIC HOW CAN HELP ME PLLEAS
can you calm the fuck down first?
I finally got the reaction Collector to work. All i needed was to add "dispose: true" to the collector options ๐
what ?
i love this
people giving an error and a bible of code, without giving a second thought, expecting other people will magically solve and fix the code for them.
debug people, learn to debug
debugging is the most important skill developers have
even the best dev will make mistakes and will need to debug their own code or the code of others
it's essential to being a developer in the first place lmao
how long does it take for a bot to get verified
it depands
Uhh
I upgraded both node.js and discord.js
A function has changed
member.guild.channels.find
Anyone know what the new one is?
i want help 
iirc they changed it to cache now
i think its member.guild.channels.cache.find
so would it be
it changed?
member.guild.channels.cache.find?
let me test
read the docs
or just use fetch mmweeeeeee
Or just use python
imagine using interpreted languages
@royal portal syntax error member.guilds.channels.find
imagine using anything but go
fetus deletus
that's one long ass string
... and this is why my d.js version is pinned before the cache update
idk about u but i really cant be fucked to use a compiler on AI
or bother learning CPP ai
how many commands to get accepted
and setActivity stops working after like 4 hours
imagine using interpreted languages
I'm ngl, I don't regret learning Python
It's actually easier for me to calculate stuff with it
compiled languages are better and faster like c++
@celest viper well no because i have bot.on
so use bot.user.setActivity
how do you host your bot
I don't need "faster" in my case
no
Though compiled is cuter
setActivity isnt working for me
Debugging is amazing, especially when you use print or console.log to find where it stops
latest
show me all your code @royal portal (not the token)
setPresence not setActivity then @royal portal
nevermind setActivity exists too
client.user.setPresence({
activity: {
name: "bots cant get viruses",
type: "PLAYING"```
i odo that
i do that
activity != status
@earnest phoenix I mean the activity
do you want to set the activity or the status
as in idle
const emojiList = message.guild.emojis.cache;
let emojis = emojiList.slice(0, 10);
if (emojis.length < 1) emojis = [`\u200b`];
How can I get the first 10 emojis from a guild? - discord.js v12
y tho
Not working
.slice(0, 9);
i hope you're aware that the emojis are objects, not strings
it says slice is not a funtion
wut is your error log
[Python] How can i break the loop threw a if? example:
For x in range(5)
if(x == 3)
break(here i want to break out of the loop, not just the if)
print("hey")
So if the if is true hey wont print
array = no loneger an object
const emojiList = message.guild.emojis.array();
let emojis = emojiList.slice(0, 10);
``` = v11
Bu i cant get it to work on v12
it's a collection, which extends a map
AT ALL
I still can't do the idle
no
I can't make my bot idle for 24/7
@modest maple They are in a for loop
so the break i wrote will break the loop?
weird
yes
by any chance
break() will break the loop
either it does not work in my main code or im just retarted
can i just say
try 1,5
is it ment to put
I am bad at coding but yeet
"hey" every iteration
so it does exactly what it should do? xD
in here
in my main code it does not work for some reason
how do i show the code in python again? was it like
'''p
break
'''
nope i have no idea
def show_hidden_word(secret_word, old_letter_guessed):
secret_list = list(secret_word)
for x in range(len(secret_list)):
for y in range(len(old_letter_guessed)):
if(secret_list[x] == old_letter_guessed[y]):
secret_list[x] = old_letter_guessed[y]
break
else:
secret_list[x] = '_'
print("".join(secret_list))
so
this function is suppose to be a hangman kinda
that is very different from your example xD
yeah yeah i just needed to know about the break thing :>
seceret word is a string of the word they need to guess and old letters guessed is a list of the letters they guessed
can i ask why you havent just do in old_letter_guessed
Anyone here good a discord.js?
instead of getting indexes
const emojiList = message.guild.emojis.cache;
let emojis = emojiList.slice(0, 10);
if (emojis.length < 1) emojis = [`\u200b`];
Error:
(node:12) UnhandledPromiseRejectionWarning: TypeError: emojiList.slice is not a function
basicly if secret_word = owo and old_letter_guessed = [o, i] so it needs to print o _ o
yh?
i mean 'o _ o'
so you could just not have the indexing
wym?
one sec
my_list = [1, 2, 3]
for i in range(len(my_list)):
print(my_list[i])
>>> 1
>>> 2
>>> 3
# The above is just the same as doing
for item in my_list:
print(item)
>>> 1
>>> 2
>>> 3```
one sec lemem see it
eh
i think i understood it? its just my first time seing it since im still learning python
well y is litterally just getting indexes
so you can just yeet all of thaty
and just get each item in the list
btw
i really wouldnt advise going into bot making without knowing the basics fully
its not a simple thing to get into
ik im not even thinking about making some real bot
im just doing some stupid stuff like that so i can slowly learn
and maybe have some bot at the end
sec
def show_hidden_word(secret_word, old_letter_guessed):
secret_list = list(secret_word)
for x in range(len(secret_list)):
"""We can remove the range and len stuff because we dont need the indexs just to get the items, this can be just doing like bellow"""
for letter in old_letter_guessed:
if secret_list[x] == letter: # these brackets were completely redundant
"""Once we have compared the item in secret list to our letter """
secret_list[x] = letter # we've just simplifed everything much more
break # This only breaks the inner most loop btw
else:
secret_list[x] = '_'
print("".join(secret_list))
@narrow kettle ive tried to do the example of how you can remove range(len()) and just use in list
did you ever print out args.slice(1).join(" ") to see what it is
also you're looking in the cache and they're probably a chance that the channel isn't in the cache
whats the error here? im in js
im trying to do a music bot but when i put the command it does nothinf
then you shouldn't make a music bot yet
https://prnt.sc/rknfg4 i dont understand why im getting that
module.exports = {
getMember: function(message, toFind = '') {
toFind = toFind.toLowerCase();
let target = message.guild.members.cache.get(toFind);
if (!target && message.mentions.members)
target = message.mentions.members.first();
if (!target && toFind) {
target = message.guild.members.find(member => {
return member.displayName.toLowerCase().includes(toFind) ||
member.user.tag.toLowerCase().includes(toFind)
});
}
if (!target)
target = message.member;
return target;
},
formatDate: function(date) {
return new Int1.DateTimeFormat('en-US').format(date);
}
}```
functions.js
const { getMember, formatDate } = require("../../functions.js");
const { MemberEmbed } = require("discord.js");
const { stripIndents } = require("common-tags");
module.exports = {
name: "whois",
aliases: ["userinfo", "user", "who"],
category: "info",
description: "Returns user information",
usage: "[username | id, | mention]",
run: async (client, message, args) => {
const member = getMember(message, args.join(" "));
// Member variables
const joined = formatDate(member, joinedAt);
const role = member.roles
.filter(r => r.id !== message.guild.id)
.map(r => r)
.join(", ") || "none";
// User variables
const created = formatDate(member.user.createdAt);
const embed = new MemberEmbed()
.setFooter(member.displayName, member.user.displayAvatarURL())
.setThumbnail(member.user.displayAvatarURL())
.addField('Member information', stripIndents`**> Display name:** ${member.displayName}
**> Joined at:** ${joined}
**> Roles:** ${roles}`, true)
.addField('User information', stripIndents`**> ID:** ${member.user.id}
**> Username:** ${member.user.username}
**> Discord Tag:** ${member.user.tag}
**> Created at:** ${created}`, true)
.setTimestamp()
if (member.user.presence.game)
embed.addField('Currently playing', `**> Name:** ${member.user.presence.game.name}`);
message.channel.send(embed);
}
}```
whois.js
because members is an object, specifically https://discord.js.org/#/docs/main/stable/class/GuildMemberManager
how do i change it then
read the docs
they make no sense
yes they do, it's your lack of language knowledge that's the problem here because you don't know js
its the fact how i dont bloody understand the sections
??
what sections lol
the docs are 90% mappings of methods, properties and events
those aren't sections
it's a list of objects that are implemented in the library
thanks for the help
hello me and my friend have a problem
const emojiList = message.guild.emojis.cache;
let emojis = emojiList.slice(0, 10);
if (emojis.length < 1) emojis = [`\u200b`];
Error:
(node:12) UnhandledPromiseRejectionWarning: TypeError: emojiList.slice is not a function
I am trying to get 10 emojis from the guild in discord.js version 12.0.2
you're attempting to call slice on a collection
call the array method on the collection and then you can use slice
But array is not a functions
on a collection, yes it is
const emojiList = message.guild.emojis.cache.array();
yeah
likrthis?
me and my friend have an error
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\lol\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 892, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\lol\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 790, in invoke
await self.prepare(ctx)
File "C:\Users\lol\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 751, in prepare
await self._parse_arguments(ctx)
File "C:\Users\lol\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 670, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\lol\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 526, in transform
return await self.do_conversion(ctx, converter, argument, param)
File "C:\Users\lol\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 479, in do_conversion
return await self._actual_conversion(ctx, converter, argument, param)
File "C:\Users\lol\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 450, in _actual_conversion
raise BadArgument('Converting to "{}" failed for parameter "{}".'.format(name, param.name)) from exc
discord.ext.commands.errors.BadArgument: Converting to "int" failed for parameter "amount".```
thats the code
leanguage: python
Somebody is trying to type in "all" instead of a number
no
thats for economy
like
-deposit all
it worked normally but in embed it doesnt want to work
use your brain for a moment
i tried with my friend
you're asking for an int as a parameter
but then later you want it to be a string, specifically all, which isn't an int
let owner = await bot.fetchUser(message.guild.ownerID); = v11
let owner = await bot.fetch.User(message.guild.ownerID); = v12
Is this correct?
@shadow shale (might know now)
ok
news.guilds.channels.cache.get(server.voicechannel.channel).setName(server.voicechannel.message.replace("[voicecount]"
^
TypeError: Cannot read property 'channels' of undefined
at Timeout._onTimeout (/app/luffy.js:258:19)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)```
what's problem
have you tried reading the error
news.guilds is undefined
guilds is not declared
guild
and if you go browse the docs, which you should have done in the first place, you can see that there is no property named guilds
fixed thanks
How can i do that when someone adds the bot to his server the bot send to that peson a message to dm
you usually don't want to send dms unless the user specifically triggered it via a command
(im new on this)
js
discord.js
Most of the time it's safe to assume d.js
You don't really know who added the bot
So sending a message to that specific person won't be easy
i would like to my bot to say thanks for adding me to the server or something like that
https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=fetchAuditLogs, you want to search the entries for one which has an action BOT_ADD and the target is your bot, and then message the executor of that audit log
You don't really know who added the bot
@late hill fyi, you do, with the recent additions with new audit log types and events
ah
how do i log in using my account
you don't
yes
but isn't that still kind of a stinky way to do it
stinky, but it works
no
I've personally noticed that the audit logs don't seem to always be that fast
wait
As in, I'll receive an event for something but it's not in the audit logs yet
they used to be slow, like extremely slow (up to a minute for an action to register) but that's been patched a long time ago
how do i login using my bot
i usually wait for 300-400ms to let the action register before fetching the audit logs, wesley
which library are you using, thisguysteve?
i want to make if owner or anyone delele voiceoline channel
delete channel id from data
let server = guilds.get(channel.guild.id)
if (server.voicechannel.channel)
guilds.delete(server.voicechannel.channel)
})```
embed.attachFile({ attachment: canvas.toBuffer(), name: 'thumb.png' });
embed.setThumbnail('attachment://thumb.png');
How to send in the attachment in an embed?
in v12.0.2
let vc = message.member.voiceChannel;
if (!vc) return message.react("โ");
vc.join().then(connection => {
const broadcast = client.createVoiceBroadcast();
const stream = "https://radio.expressradio.co/radio/8000/radio.mp3";
broadcast.play(stream);
connection.playBroadcast(broadcast, {
bitrate: 96000,
volume: 0.1
});
message.react("โ
");
});
bot joins the vc, and appears as if its playing audio, but no audio is coming through the bot, what did I do wrong?
discord.js v11.6.2
nah it aint that
then idk
Code:
@commands.command(name="deposit", aliases = ["dep"])
async def _deposit(self, ctx, amount = ""):
e = discord.Embed(color= 0x8B0000)
e.set_author(name=f"{ctx.author}", icon_url=ctx.author.avatar_url)
if amount == "":
e.add_field(name="Deposit failed:", value="You need to specify the amount you want to deposit", inline=False)
base_dir = os.path.dirname(os.path.abspath(__file__))
db_path = os.path.join(base_dir, "Economy data/economy.sqlite")
db = sqlite3.connect(db_path)
cursor = db.cursor()
cursor.execute(f"SELECT bank FROM users WHERE user_id = {ctx.author.id}")
bank = cursor.fetchone()
cursor.execute(f"SELECT wallet FROM users WHERE user_id = {ctx.author.id}")
wallet = cursor.fetchone()
if wallet is None or int(wallet[0]) == 0:
return await ctx.send("Can't deposit emptiness (your wallet is empty)")
elif str(amount).lower() == "all":
sql = ("UPDATE users SET bank = ?, wallet = ? WHERE user_id = ?")
values = (int(bank[0]) + int(wallet[0]), 0, ctx.author.id)
if str(amount) != "all" and int(amount) > int(wallet[0]):
e.add_field(name="Deposit failed:", value="You don't have enough money in your wallet to deposit", inline= False)
elif wallet is not None or int(wallet[0]) != 0 and str(amount).lower() != "all":
sql = ("UPDATE users SET bank = ?, wallet = ? WHERE user_id = ?")
values = (int(bank[0]) + int(amount), int(wallet[0]) - int(amount), ctx.author.id)
await ctx.send(embed = e)
cursor.execute(sql, values)
db.commit()
cursor.close()
db.close()```
input: !deposit all
output:
```File "c:\mydir\mydir\mydir\cogs\economy.py", line 131, in _deposit
values = (int(bank[0]) + int(amount), int(wallet[0]) - int(amount), ctx.author.id)
ValueError: invalid literal for int() with base 10: 'all'```
python
something's wrong with your if checks
wow ik
then go over them and debug lol?
check if its undefined
bank[0] or wallet[0]
not undefined lol this is py
None?
allready fixed
ok
can i ask in this channel about coding questions that are not about bots?
Yup
sure
ok so [Python], I need to make a function that gets two tuples and makes every couple possible with them(Im pretty sure i didnt explain it well so im sending an example)
I just cant think about how to do it
like i have an idea in my mind but im note quite sure about how to do it with tuples?
tuples can just be referenced like any other iterable object
if you think of it like expanding brackets
start with the first item in the first tuple
make all the possible combinations with just the first item in tuple 1 and tuple 2
then go to seconds element
can i just say print(first_tuple[0], second_tumple[0] but run it in a loop?
and 0 would be x and y
well that example is adding all the tuples its made to one tuple and printing that
Strange question but is there a library out there that, basically has the same prototype as PHP, but instead of PHP scripts, you write PHP scripts in javascript
Not looking for something like EJS
how would that even work? considering php scripts spawn a new thread for every connection while js answers all connections in the same thread
or are you looking for some kind of js > php transpiler?
embed.addField("Discord API Latency", `\`${Math.round(bot.ping)} ms\``);
It shows as nun
nul
nun
yep
@heavy marsh what's your d.js version
you mean nAn?
btw if v12 its <client>.ws.ping
mine is 12.0.2
It will give the discord API Latency right?
yes
it gives you the ping of the websocket connection
client.ws.ping
can confirm bot faster?
no
because there's a queue
Tip: If you're tired, you should sleep.
- I am tired of waiting ๐ฉ
what does it mean by Invalid server format when I'm adding a new bot
@fossil oxide what does it mean by Invalid server format when I'm adding a new bot
How do I shard a bot across multiple physical servers? i.e. not multiple instances on one server
in which library
@bitter sundial what does it mean by Invalid server format when I'm adding a new bot
baby yoda, stop being annoying and pinging mods
it means what it means, you've provided the wrong format
but I need help
the servers this bot is in section is formatted incorrectly
discordjs
it needs to be server ids separated by commas like so
1234, 5678
it's optional so you can also leave it empty
pass the shard ID to run on, itsjake
see: https://discord.js.org/#/docs/main/stable/class/Client (constructor) and https://discord.js.org/#/docs/main/stable/typedef/ClientOptions?scrollTo=shards
finally finished my bot
aha, I see. I was trying to find info in the guides but there wasn't much there. I'll check that out, thanks!
Which database is best for saving some player datas?
(Currently, i'm using quick.db)
And I'm not happy with this database module
Because you didnt read the docs https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=delete
cry i just want to say thats one of the best videos that exist
hello, how i can do stats command with top.gg stats of my bot?
what
post your stats to top.gg?
yes
is @tight osprey
make a POST request to the endpoint (https://top.gg/api/docs#bots - last one, dbl's docs are trash)
lol
loadImage('./images/PYSBump.png').then(bg => {
const canvas = createCanvas(bg.width, bg.height);
const ctx = canvas.getContext('2d');
loadImage(user.displayAvatarURL().split('?')[0] + '?size=2048').then(avatar => {
ctx.drawImage(avatar, 0, 0, canvas.width, canvas.height);
ctx.globalCompositeOperation = 'destination-in';
ctx.drawImage(bg, 0, 0);
const embed = new discord.MessageEmbed()
embed.attachFiles({ attachment: canvas.toBuffer(), name: 'avatar.png' });
embed.setDescription(`**Avatar For ${user.tag}**`);
embed.setImage('attachment://avatar.png');
Error:
(node:12) UnhandledPromiseRejectionWarning: Error: Unsupported image type
Discord.js v12
can you pass me a code or something, i dont entend
for what is that code
or canvas
const { createCanvas, loadImage } = require('canvas');
for what is it?
displayAvatarURL() returning as .webp
ooh
try displayAvatarURL({format:"png"})
Thank you it works
https://cdn.danbot.xyz/O7fSXHqJ
how i can do it?
Thank you it works
https://cdn.danbot.xyz/O7fSXHqJ
@heavy marsh but how i can do that?
also you dont need to add .split('?')[0] + '?size=2048'. URL is a function.
@heavy marsh
:/
ooh
displayAvatarURL({format:"png", size:2048})```
Is it possible to pay for montly advertise?
^404 ?
ah wait
lol
Hi
how i can use canvas?
button {
text-decoration: none;
padding: 9px;
background-color: aliceblue;
border-radius: 8px;
}``` I have text decoration on none, but it still shows the blue lines on hyperlinks
Anyone know how i can remove the blue lines underneath?
One way to get around this is to make the buttons clickable, not the text
how would i do that?
I'm a shit at html/CSS, can't helm
element:hover {text-transform: none;}
Or so I recall
[Python] hey, so i need to make a function that gets a string and returns it as a dict but in the dict is the key which is the letters in the string(space not included) and their value is the times they are in the string, example:
How do you use setPresence on discord.js?
im not sure where i need to start from but i know i need to check with count(While its a string) how many times each charcter appears and then bind it to the key, but im not sure how i bind it to the key and where do i start from?
The string count() method returns the number of occurrences of a substring in the given string.
right, but how do i bind it to a key?
Iterate over the string
check if character is in a dict already:
if not, add the char as key and string.count(char)
else skip
Anyone know how to use setPresence on discord.js
@royal portal yes
mhm
Have you tried reading the docs
its an object so


