#discord-bots
1 messages · Page 544 of 1
did u try b!purge 10
he has that
okay, that doesn't mean you don't have the capability to solve that issue yourself
Yes but nothing happens
typehint amount with int
doesnt matter really will only raise an error if its a str and not an int
it's true but I can't find what's stuck since last night and even by searching on the internet
do you have any errors?
Try py async def clear(ctx, *, amount : int):
without a number
why star
and then use ur command :3
Have you tried to see if the bot sends any messages with the command?
is the bot even online...
Lmao
the bot is online and it responds with the "ping" but nothing happens with the command.
Mmmmmm
U got no errors?
not one
how :|
debug it then
add a print statement right above your .purge
see if it prints
Thats what i said
if it doesn't then your command isn't even being called
add prints everywhere
lmao

He debugged it already
is that "ping" of yours an on_message event
No it's for something else sorry I had to delete the part of the code
@bot.event
async def on_message(message):
if message.content.lower() == "ping":
await message.channel.send("Pong")
oh god
that's why
replace @bot.event with @bot.listen()
and it will work :)
^
ok I will try that
Whats the difference?
I have no idea why because I haven't read the source code
bot on_message with @bot.event won't process commands
bot.listen appends to bot.extra_events
K
oh and in the default on_message is the command processing
yea
makes sense
oh it works with that!!
👏
Thank you very much!!
how to fix object has no attribute keys
don't use keys attribute
just fix it
what to use instead
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
very helpful
well what's db
we clearly know what db is
attitude
no idea
what's db
database i think
oh its replit’s db
oh
it’s just json on steroids
oh
so how to import their database to my vs code
well I don't think you can connect to replit's db in VSC
ofc it wont work outside replit
damn it
managed to figure out everything from nothing
just use an actual database
?
you can't
lol
but bot profile's usually get edited in the dev portal
just like you can't change the bot's name from code
"use an actual db" was the right answer
yeah but how
the only answer*
without being able to use a database, your programming career wouldn't go anywhere
which other database can i use that wont ruin the code
every single one of them
no database
nothing would ruin the code
yeah but for this specific bot
replit’s db is shit
ikr
replit overall
you would have to rewrite your code to adapt to the new db u choose
use postgresql 
it's potentially the most loved db
any SQL
or NOSQL (like mongo)
postgres is just a really good database
or sqlite 
databases:
SQL
NOSQL
?
even nosql databases are described with not being sql
it doesnt sends all the limited commands but prints all of them
How can I see the member permissions?
embed.add_field(name="User Permissions:", value=member.guild_permissions, inline=False)
This is not working...
whats self.channelLimitations
with open("./botFiles/limitations.json", "r") as f: self.channelLimitations = json.load(f)
@waxen granite may you help me please?
why wouldn't it
do u have member intents as true?
why wouldn't it work
and whats guildLimit
wait nvm
its in the code
member.guild_permission.list()
or just iterate over it directly
Like that ?
for channelid in channelList:
channel = self.bot.get_channel(channelid)
limit_msg += f" **Channel:** {channel.mention} | **Channel ID:** `{channel.id}`\n"
print(limit_msg)
if len(limitmsg) + len(limit_msg) < 2000:
limitmsg += limit_msg
else:
limitmsglist.append(limitmsg)
limitmsg = limit_msg
``` @waxen granite shouldnt you be sending it after you print it
So if i have a bot with slash commands only i can add it to servers ??
that's not how you apply the built-in list()
list(member.guild_permissions) basic python smh
wdym? i hav to check it for char limit
then why are you not sending it after you check it
for limitmsg in limitmsglist: await ctx.send(limitmsg) i am?
ok, can you print limitmsglist before sending it
like put print before the last if statement
if len(limitmsg) + len(limit_msg) < 2000: limitmsg += limit_msg else: limitmsglist.append(limitmsg) limitmsg = limit_msg print(limitmsglist)
here?
print(limitmsglist)
for limitmsg in limitmsglist:
await ctx.send(limitmsg)
``` there
okay
Help 😩
no
what database would u guys recommend as an alternative to replit's database
@kindred epoch well it prints only what it sends
seems to be somethng wrong with append i guess
idk what tho
is there a way we can add a function to the bot as well
ur trying to undo that perm
what
i asked for help in #databases
it should work then
but it is not complete msg
i want it to send all the commands/stuff that it can print
yea cuz ur using a for loop?
yea how can i send full msg?
Hello, I have problem with command in discord.py, I want help command, but when I create help command like:async def help(ctx): after start program, it will write into console this error:discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias. But problem is, I dont have anywhere help command, no aliases, no command.. Please help
bot.remove_command('help')
in your main.py
help is default cmd
Ok, where can I put that? Just in the code?
under your bot = commands.Bot stuff
in ur commands.Bot add help_command=None
in your main.py use ```py
bot.remove_command('help')
because help command is already used to view all your command
Thank you, it worked. :)
ur using a for loop thats why its not sending it in a single message
well that to avoid the limit no?
i am not trying to send all the stuff in a single msg
then why do you want to send it in a single mesasge
my issue here is that it sends only half or so of the stuff
then why didnt you say that before? tf
take a look here under # what output it gives or prints , it has a lot of commands below the coinflip
but it sends only till coinflip
did i ? 😮
i want to use a particular function in many of my cogs, is there a way to do it
idk
try sleep?
yea maybe that can help
how can i sleep in this case?
@slate swan How can I make this?
list(member.guild_permissions) this is print the whole permissions and type true or false...
use .join()
It returns an iterable, iterate over it, check if it's true, append to a new list, then apply .join on it
Iterating is basic python 😟
for limitmsg in limitmsglist: await asyncio.sleep(0.5) await ctx.send(limitmsg) like this?
ye
it still sends upto coinflip
then idk
good
i tried lowering the limit of 2000 to 1500 and it send 4 more commands
not all yet
any idea for it?
change it to 0
isnt that what u wanted
no...
ghelloooooooooooooooo
hiiiiiiiiiiii
help me
print('hello word) is not working
if member.guild_permissions == True:
list(member.guild_permissions).append()
``` LIKE THIS???
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
help meee if you know
ok
where should i ask
I have a custom welcome message and my bot is in a couple of test servers and whenever someone joins one of the test servers it sends a message in my server when they never joined mine, how do I fix that?
@commands.Cog.listener()
async def on_member_join(self, member):
guild = self.client.get_guild(784515826765529098)
channel = guild.get_channel(784515827319439400)
await channel.send(f"You made it {member.mention}! Welcome to **{guild.name}**, enjoy your stay 💚")
Add a condition to make sure that the guild the member has joined is the same one you want to send it in
Just compare the guild ids
You are using the channel id
Meaning
It always sends to that channel.
How do I fix it ._.

You should be able to compare member.guild.id, and the id of the guild you are sending the welcome message in
change the channel id to what you want it to.
or do it via channel
Name
what would be the best way to store roles in such a way that its stored in a list like:```json
[
{
"role_name" : "something",
"role_id" : 123
},
{
"role_name" : "something_else",
"role_id" : 456
}
]
store the role object or id ,ez
the db doesnt recognize the role object
oh then store the role id
as you can get the role by id
how do i store both of them together like that^^
the name and the id
i want both under one field
you have a table for roles?
make 2 columns , one for name and one for id
id's datatype should be bigint
which db are you using
how do i use https://discordpy.readthedocs.io/en/master/api.html#discord.ui.View.wait for my buttons? im confused
no... json
https://github.com/Rapptz/discord.py/blob/master/examples/views/confirm.py check this example
json and db are different things
mongodb stores data using json strings
its similar to json
ah I'm not familiar with mongodb , sorry
ok
legend
pickle is better than json??
is anyone familiar with the library google trans?
raise NotFound(response, data)
discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
how do i create an error handler for this weird error, i dont even know what it is, my commands work perfectly fine. I dont want it to show up
try and except
you need to add owner_ids in bot's attribute bot.owner_ids
!d discord.ext.commands.Bot.owner_ids
The user IDs that owns the bot. This is similar to owner_id. If this is not set and the application is team based, then it is fetched automatically using application_info(). For performance reasons it is recommended to use a set for the collection. You cannot set both owner_id and owner_ids.
New in version 1.3.
oh i forgot how to set them , my bad
i've got a function that i want to use in different cogs in different python files, is there a way i can define it once and use it everywhere
yes, you need to import it in the files you want to use
it worked before the new API anyone know why is doesent work anymore?
can you use github libraries in a discord bot
new api?
what
Can someone help me, or know how to fix that?
old discord api?
looking at the error
i think its something with cogs
im not sure im kinda new myself
theres a new discord api?
disable whatever extension manager you've got, see what those errors are
because "could not be loaded" doesn't say much 
ye
and idk why you have a cog for every single moderation command
and idk why you're removing them to
😂
only the help command is a default command which you should remove if you dont want it
imagine not asking for help
do you know how to quit a command
quit()
return
i`m start the bot
and
typr
type
something command
but
bot
not
send
message
no error message in console
help
pls
you
like
being
a
crackhead
a) show code
b) stop being overdramatic
c) give backstory (when it didnt work, when it did work)
ok
what code
my bot have 344 lines
do all commands not work or just one
only 1 command is not working, or all are not working?
this something of code
answer the questions.
bot.remove_command('help')
#events
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=f'-- w.help --' ))
print("Bot is ready!")
#user
@bot.command(aliases=["whois"])
async def user(ctx, member: discord.Member = None):
if not member: # if member is no mentioned
member = ctx.message.author # set member as the author
roles = [role for role in member.roles]
embed = discord.Embed(colour=discord.Colour.blue(), timestamp=ctx.message.created_at,
title=f":notepad_spiral: Informations of user : - {member}")
embed.set_thumbnail(url=member.avatar_url)
embed.set_footer(text=f"Rquested by {ctx.author}")
embed.add_field(name=":id: ID:", value=member.id)
embed.add_field(name=":name_badge: User name", value=member.display_name)
embed.add_field(name=":house: Create acc :", value=member.created_at.strftime("%a, %#d %B %Y, %I:%M %p UTC"))
embed.add_field(name=":thumbsup: Joined :", value=member.joined_at.strftime("%a, %#d %B %Y"))
embed.add_field(name=":raccoon: Roles :", value=member.top_role.mention)
await ctx.reply(embed=embed)```
bruh
shutup
@zenith zinc
e
dude, if you want help; then answer questions.
then first test with only 1 command in your bot file, comment all the others
just to see, if your bot is responding even to a single command
anyone know how to use *members: discord.Member
hey does anyone have a discord bot that bypasses linkvertise links
or knows how to make one
hello has anyone got any experience with Cogwatch? im having issues getting it to work path='commands': Root name of the cogs directory; cogwatch will only watch within this directory -- recursively. does this mean that i need to set the name to the folder name where the cogs are contained?
hi, i have a command mad of a single word, i wanted to do it made by 3 words, how do i do that
like !a b c instead of !a
?
i'd want to make a command made of 3 words
like !launch a coin instead of just !launch for example
You can do !launch_a_coin not !launch a coin
ty
ew this sucks
he answered ur question
so how does the new discord update apply to dpy
if your bot is in less than 100 servers it won't need to be verificated, if it is in more than 100 you will need to get the discord verification and you can get it only by having slash commands
wich will not be implemented in discord.py
but there are some forks that already have them like. diskord.py
im trying to figure out how to add music commands to my bot, and i have the following code:
@bot.command(pass_context=True)
async def join(ctx):
channel = ctx.message.author.voice.voice_channel
await bot.join_voice_channel(channel)
and it gave me this error:
Ignoring exception in command join:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 13, in join
channel = ctx.message.author.voice.voice_channel
AttributeError: 'VoiceState' object has no attribute 'voice_channel'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceState' object has no attribute 'voice_channel'
its voice.channel
still same error
bot.join_voice_channel is not a thing, it's replaced by VoiceClient.connect
show code
@bot.command(pass_context=True)
async def join(ctx):
channel = ctx.message.author.voice.voice.channel
await Voicebot.connect(channel)
if forks have it why dont dpy
how exactly does the code communicate to discord?
Did you read what Danny said?
he quit
no one wana take over
Ye and
why do people fork if they could take over the main
its await channel.connect()
"take over the main?"
Ignoring exception in command join:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 13, in join
channel = ctx.message.author.voice.voice.channel
AttributeError: 'VoiceState' object has no attribute 'voice'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'VoiceState' object has no attribute 'voice'
Bruh
Are you ok?
Oh yea I'll just take over this discord server
So eassyyyyyyy
Wtf?
no one wanted to take over
@visual island
but people wanna run forks?!
Yea and do you know who that no one is?
All the ppl he trusts that will keep the lib maintained
And its not easy to maintain it
Sounds easy
how hard is it convert to another fork
Tell me, how much time do you think it took Danny to make this lib?
if i wanted to continue with my bot
the people whom Danny trust* not everyone
ill need to switch to a fork with dlash
Yes
why voice.voice?
because its a fork i just gotta change discord to x
bcs this
and it works right?
I don't get what u mean
the dpy code will work
do I say voice.voice.join? Or just voice.join
i thought u were talking about the underscores
error:
Ignoring exception in command join:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 14, in join
await channel.connect()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 1277, in connect
voice = cls(client, self)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/voice_client.py", line 199, in __init__
raise RuntimeError("PyNaCl library needed in order to use voice")
RuntimeError: PyNaCl library needed in order to use voice
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: RuntimeError: PyNaCl library needed in order to use voice
code:
@bot.command(pass_context=True)
async def join(ctx):
channel = ctx.message.author.voice.channel
await channel.connect()
pip install pynacl
You don’t need to use slash commands if your bot is in <75 servers
You’re running it in the file, do pip install pynacl in the console
bruh, how did you install discord?
import discord
Well — you ask don’t need to switch to slash commands if you’re building a moderation bot and discord verifies it ( I think )
Then bot go poof unless you switch to slash commands
But otherwise you’ll need to switch to slash commands
By April though there will definitely be a dominant fork
"install" not "import"
huh?
anyways #discord-bots message
how did you download discord
i dont have the app, jokes on you
never done anything in the console before
dont know how
it kinda does that automatically @visual island @fallow mauve
not the app...
ooh
okay then, just do import pynacl
That little yellow arrow in the console where you got the error - write next to it
ok
that no work
PyNACL is the voice support for discord right?
ill use a fork
Okay
not that discord 🤦
oh, i never used it 😔
Does anyone know?
you did message.content.lower() but you're comparing it to a list of strings with uppercase letter in it
ill try that thank you
Whats the best library to have Slash commands, Buttons, and Dropdown menus? There are so many.
I'd recommend discord-components, but that's just my opinion
however, it does not have slash commands
I generally use a combo of discord_slash and discord-components because of this
why dont you just use one lib?
tbh cause I'm too lazy to find one that combines all of them since I already am used to both systems :p
when i do a option with my bots buttons in the help command how can i make it not say "this interaction failed" when i dont wanna do anything for that interaction
if you're using a button you could disable it
but i need the button
it depends on what library you're using
i click the button it changes the page and says interaction failed
discord_compenents
pycord
like how do i say to discord the interaction succseded
well I'm not an expert on it since I haven't used it much, but you should join their official discord and ask there
ok
I need some help with making Message Components with Python. Anyone know which one of these 2 libraries I should use?
https://pypi.org/project/discord-components/
https://pypi.org/project/dislash.py/
I can't decide what one to learn.
I'm trying to create an error handler for a InvalidBodyForm error. What would the name of it be in commands? As example MissingRequiredArguementand CommandOnCooldown
just create the error and use that
Wdym
like just create a quick testing code that would invoke that error
and just read the console
and you need like the name of it?
I'm trying to look for the name of it in discord.ext.commands
To create a simple if statement
to be clear this is a discord.HTTPException error
https://discordpy.readthedocs.io/en/latest/api.html#discord.HTTPException.code
ah
except discord.HTTPException as e:
if e.code == ....:
#do something
else:
#don't do something?```
You can check for the error code via something like this, invalid form body is `50035` I think
The error code is correct
what are the permission overwrites to manage/read/write to private & public threads? Idk if im blind but i cant find them in the API reference
anyone happen to know how do i make it to send specific timezone current timestamp|?
check out the pytz module
import pytz
utc = pytz.utc
pst = pytz.timezone('America/Los_Angeles')
now = datetime.datetime.now(tz=pst).timestamp()
print (now)
it wont continue
https://hastebin.com/juwamibese.py
after question 2
gotcha
thanks
anyone
Help?
currently this version of discord.py does not support threads
dang
at least I think
do you know why mine isnt working?
don't quote me on that lmao
you'll have to be more specific on your question
sorry?
i dont get what you mean
does it stall when you type a
yes
what about if you type b
Well that's because you did a there
look at your if statement, if a user types a the code doesn't go anywhere
does it not go to else?
if msg.content.lower() == 'a':
await ctx.send('https://i.kym-cdn.com/entries/icons/original/000/027/195/cover10.jpg')
score += 15
await ctx.send (f'Your social credit score is {score}')
await ctx.send('What happened on July 4 1989?\n(a)Massacre\n(b)Nothing\n(c)My birthday\n\n')
else:```
If a user types `a`, the code stops after that last `ctx.send`
No it doesn't
how do i fix that
consider refamiliarizing yourself with if statements https://www.programiz.com/python-programming/if-elif-else
I'm not sure anyone can fix that for you exactly it requires completely rewriting it. I'd try something simpler to start with
In this article, you will learn to create decisions in a Python program using different forms of if..else statement.
how do you detect if a webhook is created?
personal recommendation, you probably can get away without nesting much of anything inside if/else beyond the score += or -+
if x = y:
await ctx.send(image)
score += 15
else:
await ctx.send(image)
score -=15
await ctx.send(trivia question)
def check(......
#continue here instead of nesting it inside the else```
@commands.Cog.listener()
async def on_member_join(self, member):
if member.id == id:
await member.ban()
Am I just being dumb, or is something wrong with this
whats the error
It's not erroring
It's just not banning the specified ID that I have for when the account joins
Do you have member intents enabled?
also dont use id as a variable since it's a py function
im talking about where you're comparing the id's
you can do that
i know, its just bad practice
????
there's no other way to check if the member who joins's id.
since on_member_join only takes member
therefore it would be member.id
@client.command()
async def unban(ctx, *, member):
Does anyone know what is the purpose of the "*" in the code?
im talking about this line if member.id == id: im assuming id is a variable unless you just put it in there for now
you dont have intents enabled?
means everything after <prefix>unban goes to member signature
ohh ok, thank you!
?
do you have members intents enabled?
I just tried enabling them bro
Not trying to sound rude but this is decently irritating
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
just follow this and you're done
That's literally the code I wrote
Is this possible in discord.py? Also is it against discord TOS?
you need to monkeypatch the source code
🙄
show it
He means the id variable
😐
Do you have that defined somewhere
bro you're trolling right
its a pylint error, what happens if you try running it?
Let me try
discord/gateway.py lines 377 to 379
'$os': sys.platform,
'$browser': 'discord.py',
'$device': 'discord.py',```
You haven't imported discord
wow LOL that was the issue
It works fine
now anyway
h
you don't have to import intents from discord if you just ```py
import discord
yes
is it against TOS?
¯_(ツ)_/¯
Thought he meant nuking a server
definitely not

@boreal osprey nice
i used a id though
@boreal osprey show code
@bot.command(aliases = ['giverole'])
async def addrole(ctx, member : discord.Member, *, message, id : int):
guild = ctx.guild
rolename = discord.utils.get(guild.roles, name = message)
userid = await bot.fetch_user(id)
await userid.add_roles(rolename)
await ctx.reply(f"I have added {rolename} to {member.name}!")
code
your supposed to do
.addrole @boreal ravine 764802720779337729
did you read your params?
also
you have a *
so everything after message is gonna be taken in the message param
roles = message.author.roles
role = message.guild.get_role(822985879243980870)
if role in roles:
ik im doing something wrong
on the first line
show error?
ok
You need to make sure that message is actually in a guild, and not a DM
message.author can be User if the member is banned/removed from the guild
Otherwise, author would be a user
or that
And thus have no roles attribute
ok
And it would be simpler just to do if Guild.get_role(id) in message.author.roles
Guild being the discord.Guild instance, ex: message.guild
ok thx
why is false a string?
hi im new to py and was wondering for the console part how would i clear the screen lol
i have anscii art ready to put i just need to clear it
selfbot..
userid is not false tho? its [] an empty list
probably you meant if bool(userid) == False:
lets pretend its a discord bot 😄
anyone..
Self bots are against the tos, you account will be banned if you do "self bots"
It's probably just the bot's name
If you mean python then os.system('cls')
thx
you can't clear the screen without exiting the program first.
check the lib's docs for guild ids thingies
basic python, variables can't have spaces
@sick birch it isnt
once you exit the program, cls on windows will clear the screen
it isn't what?
@sick birch
oh sorry hard to see the underscore
Uh you can actually
Python can make command line calls through os module
you could
didn't think of that
though it's probably better to not for debugging purposes in the future
need commas between the decorator kwargs
THANK YOU!!!
Does anyone know how to fix a bot not leaving a vc
is there a way where if i have a command that will loop and wont be stop unless i close the script
is there a method where i can use a command to stop it?
just leave it in the vc
my bot isnt leaving a vc but my code looks correct? do i have an error
The leave command isnt working
@void crane stop copying old tutorials
I fixed it
i think
I got the code checked and the people said it is fine but it dosent work
errors?
while True?
I have checked it and I couldnt find any
Is that the built in python ide?
Or text editor?
This is an extremely clear error
You need to define them
i mean like my command triggers a qwhile true but i need a method to stop it when i execute another command
Just use a condition....?
while var:
# set var to False somewhere idk where
while True isn't an issue as long as you yield back to the event loop in 100ms iirc
while True becomes asynchronous if you await a coroutine inside it
it is built in the python ide
im trying to move it to atom
so how will the code be??
type = nextcord.ActivityType.playing
oh ok 🙂
Working on a dm ban message
but i cant get it to say what server they were banned from
that link is old but idk how to get it to display what server
@commands.is_owner()
async def testban(self, ctx, member : discord.Member, *, reason=None):
embedChnl = discord.Embed(title="Member Banned", description=str(member.mention), color=0x00ff00)
embedChnl.add_field(name="By:", value=str(ctx.author), inline=True)
embedChnl.add_field(name="Reason:", value=str(reason), inline=True)
test = "{} | Reason '{}' ".format(ctx.message.author, reason)
embeddm=discord.Embed(title="**Banned**", description= "f'You have been banned from ctx.guild_name for {reason}, color=0xff0000)
embeddm.add_field(name="Appeal at",value="https://forms.gle/jFpJm8DEVTDsYeWe6", inline=True)
await member.send(embed=embeddm)
await member.ban(delete_message_days=0, reason=test)
await ctx.send(embed=embedChnl)```
kinda got messed up when sending
but what would i need to change
ctx.guild.name```
?
just that?
bruh this is so messy.
I cant read that
if you're asking for server name, then yes
@commands.command() @commands.is_Owner() async def testban(self, ctx, member : discord.Member, reason=None): embedChnl = discord.Embed(title="Member Banned", description=str (member.mention), color=0x00ffe0) embedChnl.add_field(name="By:", value-str(ctx.author), inline=True) embedChnl.add_field(name="Reason:", value-str(reason), inline=True) test = "{} | Reason '{}' ".format(ctx.message.author, reason) embeddm=discord. Embed (title="**Banned**", description= "f'You have been banned from ctx.guild_name for {reason}, color=0xff0000) embeddm.add_field(name="Appeal at", value="https:///forms.gle/jFpJm8DEVTDsYeWe6", inline=True) await member.send(embed=embeddm) await member.ban(delete_message_days=0, reason=test) await ctx.send(embed=embedChnl)
@jagged aurora
should've used codeblock 💀
@jagged aurora u shud have done it like this
@commands.command()
@commands.is_Owner()
async def testban(self, ctx, member : discord.Member,
reason=None):
embedChnl = discord.Embed(title="Member Banned", description=str
(member.mention), color=0x00ffe0)
embedChnl.add_field(name="By:", value-str(ctx.author), inline=True)
embedChnl.add_field(name="Reason:", value-str(reason), inline=True)
test = "{} | Reason '{}' ".format(ctx.message.author, reason)
embeddm=discord. Embed (title="**Banned**", description= "f'You have been
banned from ctx.guild_name for {reason}, color=0xff0000)
embeddm.add_field(name="Appeal at",
value="https:///forms.gle/jFpJm8DEVTDsYeWe6", inline=True)
await member.send(embed=embeddm)
await member.ban(delete_message_days=0, reason=test)
await ctx.send(embed=embedChnl)
^^
how do i get that code block
wow, that " before f
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
EOL error
put that or get rid of it
send pls full screen of code
"f'You ....
``` just remove that `"` before `f`
bruh, or just google how to use f-string
:)
use three backticks then type py (without giving space)
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Here
The guild name.
.
I got it now
gg
nice
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
How to get a server's name?
And also how to get member count
!d discord.Guild.member_count
property member_count: int```
Returns the true member count regardless of it being loaded fully or not.
Warning
Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
Oh Kayle send it
The guild name.
Okay
await ctx.send(discord.Guild.name)
await ctx.send(discord.Guild.member_count)```
use ctx
not discord.Guild
your calling the properties of discord.Guild
Oh ok
show me ur code
oh
hey, how can i get my discord bot to indicate ••• User is typing...
it isnt Guild its guild
ctx.trigger.typing()
...
pls learn how to differentiate class names and how to use them
yes lmao, he confused Guild class with guild attribute of context
^
um where do i put it anywhere in the code?
async with typing():
await ctx.send("done")
hmm mind showing me your code?
no wait
bro, just put it as per your choice
💀
maybe, before your bot sends the message?
typing is not defined
is it a coroutine?
oh
works to me
AttributeError: 'Context' object has no attribute 'trigger'
what did u define it as?
Wait
yes
OwO look up to docs then, but it shold be similar to trigger typing lol
i usually don't remember them exactly ok :>
async with ctx.typing():
await asyncio.sleep(4)
await ctx.send("done")
Okay it is ctx.typing
h
do yall know how a bot can give a member a role based on their discord status
??
like if they have something in their status it will give them a role and if they take it out it will remove it
use a check
There is somekind of bot for that
if "kayle" in member.activity:
execute the code
Yeah i know the bot that does it but im trying to implement it into my own bot
Well I wanted to find it tnx
Me too
i dmed you
I found something on stackoverflow that does it but i dont know the imports i would need to do so
and what would need to be changed on it either
me doing breakfast rn lmao
Me gotta gi bye
anyone able to help me with give member role based on status?
it would be task.loop or client.event im pretty sure
is there any way to limit the embed to 2 per level?
like move the url down
so it's 2 x 2
dont copy from so
at th
e jump_url field add an inline=False kwarg
yeah but that moves the jump url to its own line and the video url to the next @boreal ravine
You can do a listener that checks whenever a status is changed
@jagged aurora "on_presence_update" is what you'd want
show me ur embed code
Brings back the memories of when I setup my adminlogs ;-;
embed = disnake.Embed(title=f"{4-n}{prefix[3-n]} Place Winner", description=f"For the {4-n}{prefix[3-n]} place, the winner is {user.mention}.\n", colour=0x00D1BA)
embed.set_author(name=self.bot.user.name, icon_url=self.bot.user.avatar.url)
embed.set_thumbnail(url="link")
embed.add_field(name='Message:', value=f'{"`"*3}{entries[0][6]}{"`"*3}', inline=False)
embed.add_field(name='Vote Counts:', value=f'{"`"*3}{score: ^10}{"`"*3}')
embed.add_field(name='Submission Date:', value=f'{"`"*3}{entries[0][7]}{"`"*3}')
embed.add_field(name='Jump url:', value=f'***[Jump to post]({entries[0][8]})***')
embed.add_field(name='Video url:', value=f'***[Jump to video]({entries[0][5]})***')
huh
what part?
wheres the inline kwarg at jump url
i removed it for now
why
since it's not the solution
it changes to this
embed = disnake.Embed(title=f"{4-n}{prefix[3-n]} Place Winner", description=f"For the {4-n}{prefix[3-n]} place, the winner is {user.mention}.\n", colour=0x00D1BA)
embed.set_author(name=self.bot.user.name, icon_url=self.bot.user.avatar.url)
embed.set_thumbnail(url="link")
embed.add_field(name='Message:', value=f'{"`"*3}{entries[0][6]}{"`"*3}', inline=False)
embed.add_field(name='Vote Counts:', value=f'{"`"*3}{score: ^10}{"`"*3}')
embed.add_field(name='Submission Date:', value=f'{"`"*3}{entries[0][7]}{"`"*3}')
embed.add_field(name='Jump url:', value=f'***[Jump to post]({entries[0][8]})***', inline=False)
embed.add_field(name='Video url:', value=f'***[Jump to video]({entries[0][5]})***')
here's the outcome
F
yall know how i could make a command that only works in certain discord servers
add a check
ok
How can I play a mp3 file in discord voice channel?
Like if I have test.mp3 and when I type !play I wana make my bot to play test.mp3 in my voice channel.
(I know how to join my bot to vc.)
Please help me
And how do I get my python version and print it???
I want a program for showing python ver
And how can I print user states when I say s?
No one here
I can't find it on docs
Ping to Awnser me.
import platform
platform.python_version()
!d discord.VoiceClient.play
play(source, *, after=None)```
Plays an [`AudioSource`](https://discordpy.readthedocs.io/en/master/api.html#discord.AudioSource "discord.AudioSource").
The finalizer, `after` is called after the source has been exhausted or an error occurred.
If an error happens while the audio player is running, the exception is caught and the audio player is then stopped. If no after callback is passed, any caught exception will be displayed as if it were raised.
!d discord.AudioSource
class discord.AudioSource```
Represents an audio stream.
The audio stream can be Opus encoded or not, however if the audio stream is not Opus encoded then the audio format must be 16-bit 48KHz stereo PCM.
Warning
The audio source reads are done in a separate thread.
!d discord.VoiceChannel.connect
Uhhh
Oh you know, my bad 
https://hastebin.com/wuvuneqemo.py
I have an getrole command here, but you can only choose one role. How can I make It possible that after selecting one they can select another one?
yes
ok
def test(a, b, c, d, e) #these are params
return a
test(1, 2, 3, 4, 5) #these are args
How do I make my bot leave the vc
!d discord.VoiceClient.disconnect @lilac latch
await disconnect(*, force=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Disconnects this voice client from voice.
hm
thanks
How to delete the button message when the timeout is up?
I tested py async def on_timeout(self): await self.message.delete() and worked it, but I still got this error ```py
Traceback (most recent call last):
File "main.py", line 39, in on_timeout
await self.message.delete()
AttributeError: 'Confirm' object has no attribute 'message'
172.18.0.1 - - [19/Oct/2021 06:33:29] "HEAD / HTTP/1.1" 200 -
Task exception was never retrieved
future: <Task finished name='discord-ui-view-timeout-aa7f1403466ba1a96fab0361ad4dd797' coro=<Confirm.on_timeout() done, defined at main.py:38> exception=AttributeError("'Confirm' object has no attribute 'message'")>
Traceback (most recent call last):
File "main.py", line 39, in on_timeout
await self.message.delete()
AttributeError: 'Confirm' object has no attribute 'message'
is there any other way to use / commands on discord bots than the discordbot slash library?
so like on_writing?
!d discord.on_guild_join
discord.on_guild_join(guild)```
Called when a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild") is either created by the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") or when the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") joins a guild.
This requires [`Intents.guilds`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.guilds "discord.Intents.guilds") to be enabled.
whats a discord bot slash library
it means that there is a python lybrary which is called discord_shlash but i dont want to use this because i hope there are more easy ways to do what this library does
from discord_slash import SlashCommand
use edpy 
It's the same as dpy2.0 but with slash command support
is this a bot?
oh, ok
Use disnake
but is there an other way then using any library? So like i implementet a command prefix without using the discord library and i hope this works for slash commands too
You're using dpy, dpy is a library itself
You just need to pass slash_commands= True to register all the commands as slash command, but it will take upto one hour
i am not using dpy
You can't
you can
It'll be a library for urself then
i can, it is complicated but
yeah, thats right
You'd still need aiohttp along many other libs even if you were to not use any of the existing discord python libs
You can't
What if he makes his own aiohttp
why do you think so? Librarys are also coded and i can use different languages so, it is possible
Like he is making his own discord lib
exactly

Visit discord API docs and use aiohttp to do the requests
magic
no, no librarys in my code
Then you can't
porbably i can, lets see, but thanks for the entertainment
You need a way to make requests, you can't do that without a library
i can code my whole own library, dont you think so? xd
You can but you're still going to need imports
Let us know when you finish
i will try to remeber
😂
That doesn't look like a discord lib error
Its from pyblox3
Well, 404s mean not found
Oh ok thanks
pls help me debug
E
I use .getenv, shorter
but with millions of lines of code 👻
¯\_(ツ)_/¯
i thought the ghost emoji would be more scarier
import discord
import os
client = discord.Client()
@client.event
async def on_ready():
print("We have logged in as {0.user}.".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("$bruh"):
await message.channel.send("bruh100%")
my_secret = os.environ.get('token')
client.run(my_secret)```
like this
but still error
what error
yeh
use a fork
3rd party libs buggy sometimes
client.run(os.environ['token'])```
str.format() is pain
thats the spaghetti of doing it that raises error if its not i the list
@devout quest whats the error
bruh
u exposed your token
u should make an env variable
@devout quest ur supposed to put ur key in there
click on the lock
He cant
import discord
from discord.ext import commands
import os
client = discord.Client()
@client.event
async def on_ready():
print("We have logged in as {0.user}.".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("$bruh"):
await message.channel.send("bruh100%")
client.run(“token”)```
@devout quest
i put my key in
oh
why
ur supposed to do
bot.run(os.environ["ur key"])
Replit doesnt support that anymore
oh
it does
@devout quest try using this
import discord
from discord.ext import commands
import os
client = discord.Client()
@client.event
async def on_ready():
print("We have logged in as {0.user}.".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith("$bruh"):
await message.channel.send("bruh100%")
client.run(“token”)```
Same thing but easy in my opinion
