#discord-bots
1 messages · Page 593 of 1
If you’re just calculating expressions, you can convert to postfix notation and use stacks to solve it without eval
I forgot it wasn’t mine sorry 💀
How do you make a prompt for user input? For example
please select an option
-1 for thing
-2 for another thing
-3 for another thing
-4 for something
and the user replies with, say, 1, and the bot replies with
you selected 1
and the user has 30 seconds to reply. How does that work/what is it called?
yntaxError: Non-UTF-8 code starting with '\xe2'
@bot.command()
async def rocklee (ctx):
embed = discord.Embed
(
title="Die Regel für den Rock Lee's Dojo Server",
description="\n\n§1 Regelwerk\n➥ Mit dem Beitritt des Discord Servers akzeptierst du automatisch die Regeln des Servers\n➥ Bei einem Regelverstoß, wird dies rechtgemäß bestraft!\n➥ Unwissenheit schützt nicht vor der Strafe, falls du gegen eine Regel verstoßen haben solltest!\n➥ Du solltest die Regeln vollständig lesen und regelmäßig auf Neuigkeit überprüfen!\n➥ Eine Verwarnung oder eine andere Sanktion ist nie unbegründet und soll stets die Betroffenen anregen über ihre Fehler nachzudenken!\n\n§2 Verhalte\n➥ Du bist dazu verpflichtet eine freundliche Umgangsweise auf dem Server zu haben!\n➥ Beleidigungen, Drohungen und Provokationen sind strengstens untersagt!!\n➥ Wird in einem Text-Kanal gespammt, so werden die betroffenen Personen für einen bestimmten Zeitraum gemutet und verwarnt!\n➥ Teammitglieder haben immer das letzte Wort!\n ➥ Rassismus, Sexismus oder Pornografie sind auf diesem Server verboten!\n\n§3 Nicknames\n➥ Nicknames müssen taggbar sein und dürfen nicht nur aus Sonderzeichen und Emojis bestehen!\n➥ Es ist strengstens Untersagt sich als eine andere Person auszugeben!\n\n§4 Datenschutz\n➥ Private Daten, wie zum Beispiel Adressen, Handynummern, Passwörter, etc. sind verboten öffentlich ausgetauscht zu werden oder gar veröffentlicht zu werden!\n§5 Support\n➥ Der Support ist beendet, sobald du von einem Teammitglied in den Support Beendet Kanal verschoben wurdest!\n➥ Im Support werden Probleme und Fragen geklärt! Das Ausnutzen des Supports wird rechtgemäß sanktioniert\n➥ Du bist dazu verpflichtet einen respektvollen Ton im Support an den Tag zulegen!\n➥ Im Support zu lügen ist ebenfalls strengstens Verboten!\n➥ Um Jemanden zu melden seid ihr dazu verpflichtet ein handfesten Beweis, wie z.B. Screenshots vorlegen zu können!\n➥ Das Ausnutzen des Report Systems ist strengstens untersagt und wird mit einem Warn inklusive Mute geahndet.\n➥ Den Support darf man weder aufnehmen noch anderweitig verbreiten und wird mit einem Ban sanktioniert.\n\n§6 Werbung\n➥ Werbung jeglicher Art ist Verboten, darunter zählt die private und öffentliche Werbung!\n\n§7 Scamming\n➥ Scamming ist strengstens untersagt!\n➥ Scamming kann nur gemeldet werden wenn klare und handfeste Beweise vorliegen!\n\n§8 Echtgeldhandel\n➥ Das Handeln mit Echtgeld ist serverweit verboten und wird mit eine rechtgemäßen Strafe bestraft!\n\n§10 Doppelaccounts\n➥ Doppelaccounts sind verboten, vor allem um sich Vorteile im Tipico Bereich zu verschaffen}n➥ Beim Verstoß der oben genannten Regel werdet ihr gebannt.\n\n§15 Falsche Channels\n➥ Bots werden nur im #┃bot-channel benutzt, andernfalls wird eine Missachtung dieser Regel verwarnt\n➥ Dazu zählt genauso das Feedback-System, mit dem Befehl !suggest werden ausschließlich Feedbacks oder Ideen geduldet, wird dies missachtet wird das mit einer Verwarnung bestraft!",
colour=discord.Colour.dark_purple()
)
embed.set_image(
url='https://c.tenor.com/R_46y_WzEn4AAAAC/line-colors.gif')
embed.set_footer(text= "Zeatman • 11.11.2021" ,icon_url="https://images-ext-1.discordapp.net/external/cJBUV5cIOm0u_YlsUia0EW4MpIM05dHrdb0maocfo3o/%3Fsize%3D1024/https/cdn.discordapp.com/avatars/371597683548225537/a_cc7d8579fb009c8f667ba781da9565c9.gif")
await ctx.send(embed=embed)
wth is that
This is my code/i wanted to do the rules for a server
yntaxError: Non-UTF-8 code starting with '\xe2'
ah
Its showing me this error
I saw it but idk
Still dont know
nope :/
helpp please 😦
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
Just use input() and ```elif````s
.....?
What do you want exactly?
Make the bot wait for the person to send a message lol
It's supposed to be a discord robot
If you haven't noticed yet....
Ohhhhh
deez?
Anyways it's 2 here. Gn
I did you can still use input for that tho
nightyy
Or just use checks 🤷♂️
ok then
If your trying to fill the questions in discord just use custom checks
mmm
here's an example
select option 1 or 2 or 3
1
wow you selected 1 well done
Yes use checks
okkee
ty
Yw
@velvet tinsel you can do is on a message it will ask for the inputs and when you do it will react with 1 2 3 emojis and when you tap it the bot checks it and says what input you gaved
oh yes...wait_for innit?
def check_if_it_is_me(ctx):
return ctx.message.author.id == 85309593344815104
@bot.command()
@commands.check(check_if_it_is_me)
async def only_for_me(ctx):
await ctx.send('I know you!')
wait, what will this do?
will it just say I know you if I message?
If you are the person with that certain id yes if not it will fail the check
I think
Doesn’t this guy want to get the input from a user
How does that have anything to do with what he wants
(I was thinking about the Dank memer prompt thing using the cell phone)
He wanted to check msgs
No, I was talking about discord bots
I mean yeah I know what you’re talking about. We're in a channel that says discord bots.
Ok 😛
He is tho?
Hes talking about a multichoice question for his bot that he wants to check with checks
Isnt that related to discord bots?
Yeah but command checks still holds no relevance towards that
oh
2 mins of typing
I thought you were going to do some complex algorithm explaining
What was brought up earlier is still relevant. .wait_for() is what you're looking for.
For the event you can use reaction_add or just message.
I mean yeah but hes just trying to check msgs
What i literally said earlier lmao
Np best of luck
Still commands checks are different. Those are for checks before command execution. Look at the docs for .wait_for()
Can I use logical operators with the wait_for()?
For example, I wanted different options, would I use wait_for("1" or "2")?
You can in the check that you pass in
ahhh ok
Ah yes you can just wait_for()
I see
@sage otter sorry for the ping but thank you for showing me the correct way

@client.event
async def on_message(message):
def check(m):
return m.content == 'hello' and m.channel == channel
msg = await client.wait_for('message', check=check)
await channel.send('Hello {.author}!'.format(msg))
what am I supposed to send in order to get a response again? 
nvm I googled it
your channel is undefined
these are never defined
Ok
client.command()
@commands.cooldown(1, 60, commands.BucketType.user)
# cooldown of 60 seconds to stop mass robbing.
async def bankrob(ctx, member:discord.Member):
await open_account(ctx.author)
await open_account(member)
bal = await update_bank(member)
if bal[0] < 1000:
messag = discord.Embed(title="Not worth it...", description="They're too poor", color=discord.Color.red())
await ctx.send(embed=messag)
return
earnings = random.randint(0, bal[0])
await update_bank(ctx.author, earnings)
await update_bank(member, -1*earnings, "bank")
num = random.randint(1, 10)
if num == 2:
rob_embed = discord.Embed(title="Robbed!", description=f"You stol {earnings} from {member}!",
color=discord.Color.green())
stolen_embed = discord.Embed(title="Oh no!",
description=f"{ctx.author} stole {earnings}",
color=discord.Color.red())
await member.send(embed=rob_embed)
await ctx.send(embed=stolen_embed)
else:
fail_embed = discord.Embed(title="Failure.", description="You failed to rob the bank.", color=discord.Color.red())
await ctx.send(embed=fail_embed)
after a user uses !rob, how do I make it so nobody can use the command on the same user (in the member argument)?
you will need to make a custom cooldown system
Ty!
use message.channel.send('message')
since you are using message in the async def commandName()
store them in a database after they are used and then remove it after 60 secs
Hello, I am trying to make a command that prints the bots in a guild.
@bot.command()
async def bots(ctx):
bots =([m for m in ctx.guild.members if m.bot])
print(bot)
``` When I print `bot` it prints this: [<Member id=892459054344048670 name='DuckyBot' discriminator='8851' bot=True nick=None guild=<Guild id=908019906862256138 name='DuckyBot・Soporte' shard_id=None chunked=True member_count=8>>]. How i can convert that into DuckyBot#8851?
In the list comprehension change the first m to f"{m.name}#{m.discriminator}"
Dont understand
list comprehension never heard that xd
bruh
oh yes xd
[] like this
bots =([f"{m.name}#{m.discriminator}" for m in ctx.guild.members if m.bot]) @sage otter
Yeah
<discord.ext.commands.bot.Bot object at 0x7ffb536585b0> now it prints this
i fixed it
nevermind xd
['DuckyBot#8851'] with this now i can do things
thanks! @sage otter
Honestly
You probably didn’t even need to do any of that
If you casted the object to a string it would of done the same thing
is there any support for catching if the command used was in a reply. then sending back to that person replied to. with discord.Message?
i see message.reply but i dont see anyway of checking for a reply and getting the user replied to
im using discord ipc to talk to my bot from my website
but i can only get variables to work if i transfer guild_id
if i try and add more it says
TypeError: Client.request() takes 2 positional arguments but 5 were given
await ipc_client.request("set_setting", value, guild_id, "cumulative")
where is 5 coming from
and this is where the function is
async def set_setting(data):
you are suppoed to do data.<variable> to get the args
is there anyway to catch if a message was a reply and get the replied author if possible in d.py? obviously i saw await reply but nothing for checking it or an attr on messageable @valid perch
how would i use this with on_message? since it doesnt look bool
Quick question how much time have you been programming?
await ipc_client.request("set_setting", value = value, guild_id = guild_id, setting = "cumulative")?
Try it and see
I'd need to look at my code to be sure otherwise. It's just what I seem to remember having todo
Bout 3 years
That's cool


ah thank you. another q, trying to notify the most recent guild booster by just slicing the either first or last element. and both are not the most recent one. done some testing and checking. im not sure if the boost by that user being a second or third boost has anything to do with it. but the list doesnt seem correct
I get docs are hard but they do have the info,
https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.premium_subscribers provided a list of members who have boosted. Members have an attribute that says when they boosted https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.premium_since
Now go sort your list based on that go get the boost order
Hey everyone, I just had a question about if its possible to have a youtube video play inside of an embed that you create with discord.py. I'm making a kind of music bot for my server that gives out multiple links to things like spotify and apple music, and I thought it would be nice to have the song playable inside of the embed like when you just send a youtube link directly
hi
why is this happening all of a sudden
ive uninstalled ind installed the lib multiple times
Show your code
And your bot var should look like this:
bot = commands.Bot(commands_prefix="") the basic one
code was good
I think when I installed nextcord earlier today it couldve messed with discords module
I had to uninstall all discord related modules then reinstall
Did you fix it?
yea
Good for you
just had to reinstall module
Nice
thanks though
Np
how do i make a command with several name
like i and inv
@bot.command(name=['inv', 'i'])
```this is not working
get_name is a method of your class
You access it through self
self.get_name
And your command doesn't have a self parameter
It should be the first one, before ctx
Same with get_name
No no you access it via self.get_name when your calling it.
Like where if (get_name) is
And like I said earlier
Your missing self in your methods
All methods of a class must have self as the first parameter
Unless they are staticmethod
Or a classmethod
what is Parameter 'coro' unfilled?
did it load your cogs?, are you using discord.Client or commands.Bot?
do you have an on_message event
that wont make it not recognize the commands unless hes inheriting commands.Bot into a class
I see coro in a lot of places such as documentation and error messages, I'm using bot.command. Can someone explain what coro is?
coroutine object?
Coroutine objects are what functions declared with an async keyword return.
A coroutine
its in asyncio
damn it, I was confused cause I kept reading it in a Mexican accent
I understand it now though
Third option has the same name as the second option
And the error clearly says what's wrong
how do i make command for rpm craft 1, rpm craft 2 in the commandrpm craft
or i need to make a new one?
use command groups
!d discord.ext.commands.Group
class discord.ext.commands.Group(*args, **kwargs)```
A class that implements a grouping protocol for commands to be executed as subcommands.
This class is a subclass of [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") and thus all options valid in [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") are valid in here as well.
ah i see
@bot.group(pass_context=True)
async def First(ctx):
if ctx.invoked_subcommand is None:
await bot.say('Invalid sub command passed...')
@First.command(pass_context=True)
async def Second(ctx):
msg = 'Finally got success {0.author.mention}'.format(ctx.message)
await bot.say(msg)
this?
outdated , but yes
is there any new ones?
click on the link in the embed from bot
.
@bot.group(pass_context=True)
async def First(ctx):
if ctx.invoked_subcommand is None:
await bot.say('Invalid sub command passed...')
@First.group(pass_context=True)
async def Second(ctx):
if ctx.invoked_subcommand is Second:
await bot.say('Invalid sub command passed...')
@Second.command(pass_context=True)
async def Third(ctx):
msg = 'Finally got success {0.author.mention}'.format(ctx.message)
await bot.say(msg)
its still wrong
I'm having trouble with the bot removing the user's reaction in line 136. How do I resolve this issue?
How do I do that?
.remove_reaction(reaction.emoji , user)
!d discord.Message.remove_reaction takes emoji and user object
await remove_reaction(emoji, member)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Remove a reaction by the member from the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
If the reaction is not your own (i.e. `member` parameter is not you) then the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is needed.
The `member` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
I did that but that didn't work
any error?
The message doesn't get edited
is pages a list of embeds?
Yes
possibly u already have the embed sent you wanted in the edit
It still didn't work sadly
lemme try running the code
could u sent it in text form pls?
`def check(reaction, user):
return user == ctx.author
i = 0
#await ctx.send(embed = pages[0])
message = await ctx.send(embed = pages[i])
await message.add_reaction('⏮')
await message.add_reaction('◀')
await message.add_reaction('▶')
await message.add_reaction('⏭')
while True:
reaction, user = await client.wait_for("reaction_add", timeout = 60, check = check)
if str(reaction.emoji) == '⏮':
i = 0
elif str(reaction.emoji) == '◀':
if i > 0:
i -= 1
elif str(reaction.emoji) == '▶':
if i < (len(clist)) - 1:
i += 1
elif str(reaction.emoji) == '⏭':
i = len(clist) - 1
message1 = await ctx.channel.fetch_message(message.id)
await message1.remove_reaction(reaction.emoji, user)
await message1.edit(embed = pages[i])
`
seems working for me , what emoji do you click on?
elif str(reaction.emoji) == '◀':
if i > 0:
i -= 1```
this may be the issue
since the value of i may not be greater than 1 at starting stage
so it does not do -1
Oh
I used ◀ and that worked but I think removing rections could be an issue
How do I make it when someone says the command the bot deletes it
I tried doing this
ctx.message.delete()
This is what I used too 🙂 perhaps you forgot to do ```python
await ctx.message.delete()
Happened to me many times
lmao
For future reference, if you get any errors saying "x" was never awaited, it's probably because you forgot to use await
I dont remember the error exactly
@client.command()
async def allscripts(ctx):
myfile = open("alltext.txt","r")
data = ""
lines = myfile.readlines()
for line in lines:
data = data + line.strip()
await ctx.send(lines)
it sends []
not
the content of the text file
Maybe you want to use your variable data sometimes
@bot.command()
async def myid(ctx,user):
await ctx.send(user.id)
o
whats wrong?
It's not type hinted
do member.id
wont it still work if it isnt typehinted
i cannot get the id of my user
A string does not have the id attribute
user : discord.User
how to get id of the person pinged
In the parameters
this
can you just edit it i am new to discord api
I just did it
^
Traceback (most recent call last):
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\bot.py", line 939,
in invoke
await ctx.command.invoke(ctx)
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\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: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message
@client.command()
async def allscripts(ctx):
myfile = open("allscripts.txt","r")
data = ""
lines = myfile.readlines()
for line in lines:
data = data + line.strip()
await ctx.send(data)
And it has nothing to do with discord.py, it's basic python
data is empty?
no it isn't
It is
Otherwise you wouldn't get that error :)
I want the content of the text file
So you're not reading it's content properly
o wit
You still need readlines
or just .read()
How to make an event so my bot sends a message every 2 hours?
And give that as output
Using tasks loop
in wrapped
ret = await coro(*args, **kwargs)
File "d:/code/RbxMods/RbxMods.py", line 21, in allscripts
with open (allscripts, 'r') as script:
TypeError: expected str, bytes or os.PathLike object, not Command
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\bot.py", line 939,
in invoke
await ctx.command.invoke(ctx)
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\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: TypeError: expected str, bytes or os.PathLike object, not Command
@client.command()
async def allscripts(ctx):
with open (allscripts, 'r') as script:
data = script.readlines()
await ctx.send(data)
I did this
what does the error mean
Pass the correct argument to the with open
Error says it all, it expects a string
You didn't give a string for the file name
And you can probably just use .read()
again
the bot says this []
@client.command()
async def allscripts(ctx):
with open ("allscripts.txt", 'r') as script:
data = script.readlines()
await ctx.send(data)
Where is the file you run located and the file you're trying to open
@tasks.loop(seconds=69)
async def hi():
await channel.send("Hi")
hi.start()```
i tried py print("hi") and that loop worked
Is this the app I need to download? >>>https://www.python.org/downloads/
To make a bot
what to pick?
Python 3
ok thank you
hlo are there any modules or libraries for storing data in discord.py
Database
modules??
what is the correct permission for this, because that seems to be incorrect? ```py
manage_channel=False
Use get_channel(id)
Depends on the database you use...
If you use MongoDB it will be a different library than if you use MariaDB
which id better Sql or pymongo
thx
manage_channels
Also next time you can look at the attributes of the Permissions object:
https://discordpy.readthedocs.io/en/stable/api.html#permissions
Make sure to type: pip3 install discord.py
To have the discord package installed
Learn Python before doing a bot though, it's not really made for very new beginners
aha thx, I was trying to find that list
!resources To learn Python 👇
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Now it works! Thx 😄
Not free 😐
need free
from PIL import Image, ImageDraw, ImageFont
level = 1
rank = 7
final_xp = 1000
xp = 400
user_name = "NinjaIsBack?"
discriminator = "#2007"
# C:\Users\admin\Downloads\rog.jpg
# C:\Users\admin\Downloads\trx_white_on_black-2.png
# background and logo
background = Image.open("C:/Users/admin/Downloads/rog.jpg")
logo = Image.open("C:/Users/admin/Downloads/trx_white_on_black-2.png").resize((550, 550))
bigsize = (logo.size[0] * 3, logo.size[1] * 3)
mask = Image.new("L", bigsize, 0)
draw = ImageDraw.Draw(mask)
draw.ellipse((0, 0) + bigsize, 255)
mask = mask.resize(logo.size, Image.ANTIALIAS)
logo.putalpha(mask)
background.paste(logo, (1275, 970), mask=logo)
# font styles
big_font = ImageFont.truetype("arial.ttf", 60)
medium_font = ImageFont.truetype("arial.ttf", 40)
small_font = ImageFont.truetype("arial.ttf", 30)
# Placing level number
text_size = draw.textsize(str(level), font=big_font)
offset_x = 1000 - 15 - text_size[0]
offset_y = 10
draw.text((offset_x, offset_y), str(level), font=big_font, fill="#11ebf2")
background.show()```
hy i was making a rank carrd for python but this wont display the text
no errors
Not discord bots related at all, ask in #python-discussion
rank card for discord bot ._.
how to download python?
how isnt tht discord bot related
You didn't specify that, also this channel is for help for libs for discord, you're using PIL, ain't seeing anything related to a python discord lib
if u can help please help tho
Don't ask in here, ask in #python-discussion https://python.org/download
I'm not very familiar with PIL
Heroku is the best free option
can anyone help me how do I use dropbox api and send files as an output when requested in my discord bot
Make 2 accounts and when one runs out of dynos, switch to the other
you can get 24x7
nice idea
how?
What does the API return, is it an image link?
they say "for anti-bot purposes you gotta link credit card details"
image
Is that image getting saved somewhere
i have a folder in which there are 200 images named by number wise e.g..
image 1
images 2
i want to use the api and send anyone of the image when requested
and they give more 500 hours per month to host your bot
you can also use rest of 250 hours to host other stuff
ya
yes in a folder
so total 500h no matter how many bots or all bots total 500h?
!d discord.File < then use this
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
you have 450 hours as a free membership per month once you link credit card details you get more 550 hours
No, 500 by default, 1000 once you give the credit card
total 1000 hours you can host any other projects wth the rest of 250
ok got it ty
ohh
anyways it gives 1k hours once you link card
and also
Anyways use this to get the file, fp is the file path
they took 25 cents when i linked my card
sad
gl
how can i host my bot 24/7 for free ?
Heroku
self hosting or heroku
scroll up discussion about it
from here
can u send a tuto video in private pls
start reading from here
you just have to go there and sign in
and use github repo so heroku can see the coding files
should i upload my project file there ? @slate swan
you use github?
upload to github
yea
ahah
upload the repo link
...
select py file
-_-
upload the github link
select py file
and start hosting
use there CLI to see the console
thanks bro
welcome
@slate swan self hosting or heroku
@pliant nacelle
but i watched a tutorial in which the person used avatar_url_as
Road To 300 subs
if you have any Problem contact me on Discord
Server = https://discord.gg/Yzt3aGh
here is the vdo
@client.command()
async def request(ctx,request1, *, message = None):
guild_owner = client.get_user(int(ctx.guild.owner))
message = f"{ctx.author} Has requested a script his request : {request1}"
await guild_owner.send(message)
this is the error
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\bot.py", line 939,
in invoke
await ctx.command.invoke(ctx)
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\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: TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
int of ctx.guild.owner?
what do u want to do?
get the owner id?
no
the username so I can dm them using the bot
like I'm doing a request for video
they'll request what kind of video
and it will get dmed to me
a string
cant be an integer
anyways
I didn't try
guild owner is none for some reason
so it was invoked in dms?
try doing get_member instead of get_user
I don't remember
using get_user
o
nvm
in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Bot' object has no attribute 'get_member'
@client.command()
async def request(ctx,request1, *, message = None):
guild_owner = client.get_member(int(ctx.guild.owner))
message = f"{ctx.author} Has requested a script his request : {request1}"
await guild_owner.send(message)
?
They'll
type in the channel
in the discord server
.request (their request)
it will get the request and send it to me
in dms
get_member only works on a guild pbject
so it's get user
So ctx.guild.get_member()
oh
Can directly do ctx.guild.owner.send(...)
in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\IT Solutions\AppData\Roaming\Python\Python37\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: TypeError: get_member() missing 1 required positional argument: 'user_id'
@client.command()
async def request(ctx,request1, *, message = None):
guild_owner = ctx.guild.get_member()
message = f"{ctx.author} Has requested a script his request : {request1}"
await guild_owner.send(message)
I have intents
maybe
Do you have intents
Just do ctx.guild.owner.send(...)
I did intents
this guy staright up ignored the solution
o alr
It's not an intent issue...
TypeError: get_member() missing 1 required positional argument: 'user_id'
In both the dev portal and your code?
Was saying from before
Look at what I replied to
yep
Smh
Alr, try what they told you and see if it works
It worked.
its optional so it can be None too
¯_(ツ)_/¯
@client.command()
async def request(ctx,request1, *, message = None):
message = f"{ctx.author} Has requested a script his request : {request1}"
await ctx.guild.owner.send(message)
¯\_(ツ)_/¯
read the docs carefully
Okay
Is is possible to rename the default help command
i mean
yes you can if you mean change the name of it
how
well I subclassed the help command > added a super init > changed it
well
i subclassed the default help command commands.HelpCommand and then changed it's attributes using super
super?
basically allows you to change things in other classes
how do you make the bot save data, like for example, if you have an xp system, how do you make it so that it remembers your xp, and only YOUR xp
a database
i have no idea how to use a database
¯_(ツ)_/¯
can u show me a little bit of code, say, if the user inputs data, the bot saves that data
like if the user says hello, the bot saves it for that user only
so if another user says hi, its stored as hi and not hello
oh ok np
ohk ty
hey can someone help me whenever i run my bot and do any command it wont send the message
this is kinda troublingm e
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
import asyncio
client = commands.Bot(command_prefix='.', intents=discord.Intents.all())
slash = SlashCommand(bot)
@slash.slash(name="test")
async def _test(ctx: SlashContext):
embed = discord.Embed(title="embed test")
await ctx.send(content="test", embeds=[embed])
Can anyone tell what did I do wrong?
Bot doesn't comes online
u didnt run it?
error?
bottom put client.run(“botToken”) you can get ur bots token at https://discord.com/developers/docs
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
do you have an on_message?
yeah that was the point
your on_message might be blocking your other comands from running
Put this at the bottom of your event.
await bot.process_commands(message)
here it is py @bot.event async def on_message(message): if message.author == bot.user: return message_split = message.content.split(" ") for message_word in message_split: for bad_word in bad_words: if(bad_word == message_word.lower()): await message.delete() await message.channel.send(">:( wtf bro why u gotta swear")
bad_words list exists tho
^
dont put it inside the loop
just put it inside the function
ok
Already did
My laptop died, it cannot be fixed
And also trying update few lines in GitHub from my tablet,
So can't check errors
hm
Ignoring exception in command gamble:
Traceback (most recent call last):
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\Pragith\AppData\Roaming\Python\Python310\site-packages\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
@bot.command()
async def gamble(self, ctx, money: int):
"""Gambles some money."""
economy = self.bot.get_cog('Economy')
await economy.withdraw_money(ctx.author)
class Economy(commands.Cog):
async def withdraw_money(self, ctx):
# implementation here
await ctx.send("money withdrawn")
async def deposit_money(self,ctx):
# implementation here
await ctx.send("money deposited")
last two are my codes first is my error help me
How can i change my bots name without going to dev portal
remove self
you cant
thzx
was quite obvious
how to use cogs??
!d discord.ext.commands.Cog read this first then come back
class discord.ext.commands.Cog(*args, **kwargs)```
The base class that all cogs must inherit from.
A cog is a collection of commands, listeners, and optional state to help group commands together. More information on them can be found on the [Cogs](https://discordpy.readthedocs.io/en/master/ext/commands/cogs.html#ext-commands-cogs) page.
When inheriting from this class, the options shown in [`CogMeta`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CogMeta "discord.ext.commands.CogMeta") are equally valid here.
AttributeError: 'MyClient' object has no attribute 'get_context'
`#chatbot
async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return
if message.content.lower() == 'hi':
await message.channel.send('hello')
if message.content.lower() == 'hii':
await message.channel.send('hii')
self.get_context(message)
context = await self.create_context(message)
if context.valid:
await self.invoke(context)
return
with open("/Users/bai/Documents/log.txt", 'a') as f:
f.write(message.content + '\n')`
Anyone know how to fix this? Please help me, im new to discord.py :/
how can I make the bot wait for both reactions? Example: I click on 🟥 and it does nothing but if I click on 🟩 the messages are deleted:
msg = await ctx.send(embed=embed)
confirm = await msg.add_reaction('🟩')
await msg.add_reaction('🟥')
await client.wait_for('reaction_add', check=confirmar)
await msg.delete()
await ctx.channel.purge(limit=amount + 1)
await client.wait_for('reaction_add', check=voltar)
await msg.delete()
How to make on error command?
global error handler?
are you following some old tutorial?
Ot mean if required value missing
on specific command?
missingrequiredargument i believe
yeah, how to fix this?
don't copy others code without knowing how it works
¯_(ツ)_/¯
Ok thanks
dont just copy code without knowing what it does, you wont get anything out of it

elaborate
?
be more specific what you actually mean
So basically when people send 'hi', it will reply hello.
If people send 'hii', it will reply 'hii.
I want to collect chat data.
If people send anything else, that is not 'hi' or 'hii', then copy message into /Users/bai/Documents/log.txt.
This is to help me improve my chat bot*
so you can check if message starts with x and send y as response ```py
if message.content.startswith('x'):
await message.channel.send('y')
I want it to auto write into the text file, all the messages, sent in all channels and guilds the bot is in.
that would be API abuse to send it to literally everywhere
But then how can I collect huge chat data?
you are listening it every guild the bot is in by default, but make it only respond to channel it was sent it
@commands.command()
async def withdraw_money(ctx):
# implementation here
await ctx.send("money withdrawn")
discord.errors.ClientException: Callback for withdraw_money command is missing "ctx" parameter.
i have ctx writen
I need tons of conversations, listed into a text file.
you need self there as well if you have class / use cogs
thx
convertion to what?
Is it possible to collect huge conversation data?
technically why not
use on message event
message event wont work for my bot
why not?
cuz then i will have to change so many things
no guilds/events commands/code lines
and then i will have to shut down my bot, which ppl will complain :/
Then I don't have time to explain any other methods, hunting the hunter might be able to explain
Please :/
but they are on dnd mode so I don't ping em here
on message is the easiest way I would use
how?
@commands.Cog.listener()
async def on_message(self, message):
That is only for cogs*
how do i stop a running discord bot?
via terminal?
needs to be automated
in what way
is there like a client.stop() method
ok
thanks for the infoo
this should work
thanks
np
anyone?
how do you make an embed with clickable text which leads to a link
(text)[link] I'd say
do we just use html <a href> or some other syntax
or other way around
o
try both
no its (text)[link] i remember now using discohook
ah, good
basically i have this embed description which shows a wikipedia guide of tictactoe
plus result
i didnt want it too be too long so i did a few lines of the wikipedia then did a ... read more for the link
hmm
actually try the last one
can anyone tell me how do I make the bot say which file has been given as a output in the console?
@bot.command()
async def test(ctx):
number = random.randint(0, 100)
wow = random.randint(100, 140)
f = discord.File("./vote_rewards/reward "+ str(number)+".jpeg", filename="vote_rewards.jpeg", spoiler=True)
g = discord.File("./vote_rewards2/reward "+ str(wow)+".jpeg", filename="vote_rewards2.jpeg", spoiler=True)
await ctx.send(file=f) or await ctx.send(file=g)
whos idea was it to put an or await
why not
great!
🤨
use a variable for the last line , and print the attachment's name
!d discord.Attachment.filename
The attachment’s filename.
!d discord.Message.attachments
A list of attachments given to a message.
i knew it who's idea was it to put an or await i knew it
whos idea was it
to have over 100 files
not saying you shouldn't
-_-
ohh
hey ,
i was trying to build a game in discord.py , so i have buttons and waiting for 2 users to click and at tha same time, i want to show the remaining time (from 10s).
iam waiting for both players input using a while loop also i wanted to edit embed after every second to update tha time, if i use time.sleep , it will stop the excecution of the program for 1 s rite, so is there any other way?
hmm okay so after doing that
its printing everything except the file name
the embeds bot sent
.
asyncio.sleep
!d asyncio.sleep this is non blocking
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
its a coro , so you gotta await it
oh ok
so were should i add it?
inside while loop?
just use it where u had time.sleep()
ok
@slate swan #discord-bots message
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
bro the prob is, inside the while loop , i am waiting for button click, so embed gets edited 1 time, then it keeps for waiting for the button click
you can use for or while loop to get multiple clicks
I made a repository that teaches how to make a Discord bot, I believe it can help. https://github.com/ScopesCodez/python-discord-bot
so when 1 while loop is there, after completing it only the next will be done rite
yes
Bro u have 2 kick commands
In mod.Py
yeah one of them does not include comment explanations , it was just drafted maybe
a = 0
while a<=2 :
# get interaction
a+=1```
@bot.command(name ='start')
@commands.cooldown(1, 1, commands.BucketType.user)
async def start(ctx: commands.Context):
userid = ctx.author.id
area = db[f'{userid}area']
if area > 0:
await ctx.channel.send(f'**{ctx.author.name}** feels like doing this all over again =.=')
else:
names = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender', 'cobble','coal', 'iron', 'diamond', 'gold', 'netherite_scraps', 'netherite_ingot', 'redstone', 'soul_sand', 'wood', 'bed', 'bedrock', 'bedrock_trophy', 'pog_champ']
for name in names:
db[f'{userid}{name}'] = 0
db[f'{userid}area'] = 1
db[f'{userid}areaDone'] = 1
area = db[f'{userid}area']
if area > 0:
```this part is wrong
cuz not everyone has the variable area
how do i make it works
i also did thasame but , since i didnt get interaction , time-=1(time =10) is not being done
i want to make a mute command but idk where to start
like how to convert the 1s to secs and 2h to hours and stuff
@bot.command(name ='start')
@commands.cooldown(1, 5, commands.BucketType.user)
async def start(ctx: commands.Context):
userid = str(ctx.author.id)
names = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender', 'cobble','coal', 'iron', 'diamond', 'gold', 'netherite_scraps', 'netherite_ingot', 'redstone', 'soul_sand', 'wood', 'bed', 'bedrock', 'bedrock_trophy', 'pog_champ']
for name in names:
db[f'{userid}{name}'] = 0
db[f'{userid}area'] = 1
db[f'{userid}areaDone'] = 1
await ctx.message.send(f'**{userid}** has reseted his account :D')
```why is this not working
Maybe indent last 3 lines..
also u don't need to mention commands.Context for ctx
Show code.
!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.
Basic math.. multiplication
sec => hour
/3600
sry
U only have error handler for cooldowns..
wdym
there is no error in my console
even i write the wrong command
normally there will be
error command None
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
?
!d discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
Idk why the error is not showing up
Try this and see
i also dun know the error
Idk how to use replit db
hmm
which function?
start
which start?
@bot.command(name ='start')
@commands.cooldown(1, 5, commands.BucketType.user)
async def start(ctx: commands.Context):
userid = str(ctx.author.id)
names = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender', 'cobble','coal', 'iron', 'diamond', 'gold', 'netherite_scraps', 'netherite_ingot', 'redstone', 'soul_sand', 'wood', 'bed', 'bedrock', 'bedrock_trophy', 'pog_champ']
for name in names:
db[f'{userid}{name}'] = 0
db[f'{userid}area'] = 1
db[f'{userid}areaDone'] = 1
await ctx.channel.send(f'**{userid}** has reseted his account :D')
u didn't mention what db
db is database
in the command
Whats the error?
not that
its working now
i made a mute command but idk how to convert time to secs like if a user inputs 1h how to get it out of the text and stuff
no problem
idk how my code works
did u want to dm the message?
]
i changed it to ctx.channel.send
Indexing
yes
okay lemme mention my prob
so, how do i make fields in an embed as a grid layout?
like it is killing me for a day
still I can't solve it
grid?
Anyone here?
i dont understand what u mean by that
like this
no
Let's say i have a folder which contains the code and a png file
How can i set the image of an embed to that png file
age?
Cus it says, that it has to be an http/https
Image
he meant image
!d discord.File
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
Yes sorry
Use that and attach it to the message
btw @boreal ravine this is prob
Ah
Then on the set_image()
thats just fields with no inlines?
Thx
i can't make it like this in my bot
i type that "attachement"?
Yeah
pls help
Ook
you didnt see my message
this, the embed just has fields with no inlines in them
yeah oh shit sorry nvm
👍
I store that ina variable right? Then call it in set image (variable.png)
Just read the example I gave you. It’s everything you need to do.
The second argument you pass into the the constructor is the name of the file you want it to be.
"Pass in the pass" cool
And in the set_image() put the file attachment://name.ext
why cant i get error
something blocking it maybe
do you have an error handler?
ok then
on_command_error event
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.CommandOnCooldown):
await ctx.send(f'This command is on cooldown, you can use it in **{round(error.retry_after, 2)}** seconds')
thats blocking it
how do i make it work
add an py else : raise error and you'll be fine
Whats the 2 there for?
Hey guys, I'm trying to make a queue system, where players can do a command to queue up, once the command hits 6 players an action happens... Any ideas? I want to be able to have multiple q's in the same channel.
your own code but you dont know what it does
i copy from stackoverflow
bruh
and some tutorial
Round to 2 decimal points
the 2 is used for rounding off till x decimals iirc
I mean I get what your trying to do
yes
yes
Or hundedth place whatever you wanna call it
!e
a=5
print(f"{a: .2f}")
@boreal ravine :white_check_mark: Your eval job has completed with return code 0.
5.00
^
imagine using disnake and importing commands from discord.ext to make commands
a list maybe you could check if the list hit 6 or more values
discord?
!e
a=5
print(f"{a: .100f}")
@loud junco :white_check_mark: Your eval job has completed with return code 0.
5.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
There’s also a thing called readability too you know…
it is readable
yeah i mean 😂i just did that and was wondering why the command does not get registered ```py
from discord.ext.commands import command
from . import Cog # imported disnake.ext.commands.Cog
class Thecog(Cog):
@command()``` i had something like this
I mean it can be. But calling round is cleaner.
from disnake
🤨
ikk , that should have been disnake but i did discord
lmao
Ok so
yes
Nvm, forgot that I ain't making a discord bot. Gonna say it in #python-discussion
lmfao
use a cog handler tbh
async def cog_command_error(self, ctx, error):
return await ctx.send(embed=discord.Embed(title='oh no an error occured',description=error,color=0x992d22))
``` heres my hanlder for around 10 commands
!e
import math as pi
print(f"{pi.pi:.100f}")```
@slate swan :white_check_mark: Your eval job has completed with return code 0.
3.1415926535897931159979634685441851615905761718750000000000000000000000000000000000000000000000000000
lol
oh sucks
disappointment
indeed
@commands.command()
async def gay(self,ctx, member : discord.Member) -> str:
lst = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
embed = discord.Embed(title='',description=f'{member.mention} is {random.choice(lst)}% gay :rainbow_flag:')
await ctx.send(embed=embed)
await asyncio.sleep(4)
await ctx.message.delete()``` i want it either to work on the user thats using it or the mentioned i forgot how to do that , should i pass the default argument as if member is None member = ctx.author or
member = member or ctx.author ?
:(
😔
im trying to show u
set the default value of member to None
and yes , the last part you sent
but i'd need to change the embed
theres another way
why tho?
!e py def func(thing= None): thing = thing or 'other' print(thing) func() func('supplied')
@slate swan :white_check_mark: Your eval job has completed with return code 0.
001 | other
002 | supplied
@slate swan :white_check_mark: Your eval job has completed with return code 0.
something
best way 🙏
read the error , you cannot use return outside a def
who all here are developing discord bots or learning to make pls dm me
Hey guys I'm trying to make a queue system here, anyone know whats going wrong:
inProgress = False
qsize = 6
teamsize = 3
busy = False
@bot.command()
async def q(ctx):
player = ctx.message.author
queue = []
game = []
if player in q:
await ctx.send("{} is already in queue.".format(player.display_name))
if busy == True and player in game:
await ctx.send ("{} is already in a game.".format(player.display_name))
return
await ctx.send("{} added to queue. ({:d}/{:d})".format(player.display_name, qsize, teamsize))
if len(queue) == qsize:
ctx.send ("Queue is now full! Type {prefix}captains or {prefix}random to create a game.".format(
prefix=bot))```
error pls
Ignoring exception in command q:
Traceback (most recent call last):
File "~", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "~", line 27, in q
if player in q:
TypeError: argument of type 'Command' is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\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: TypeError: argument of type 'Command' is not iterable
if player in q:
try for player in q
maybe you meant if player in queue
I did indeed, ty
for player in queue
Can anyone give me a example of a select menu/drop down menu
(using dislash.py)
WHy would that help?
A Python wrapper for discord slash-commands and buttons, designed to extend discord.py. - GitHub - EQUENOS/dislash.py: A Python wrapper for discord slash-commands and buttons, designed to extend di...
There is an example on the GitHub page of the project...
Whats the code to grab the message authors name
message.author.name
oh 
or just message.author if you want the discriminator
Yeah but I originally had message.author
and it gave it as an object
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.
I'm trying to append the username to the queue list
The messages sent by the bot are fine
And you can just use str(message.author) to get the username and discriminator
But yeah, if you just need the username it doesn't matter
so would py queue.append(ctx.message.author.name) work?
if queue is a list then yes
ah yep, cheers
can any1 send message to specific channel example?
Use get_channel(id) save it in a variable and then use .send() on that variable
thx
¯_(ツ)_/¯
Well you know, searching on your own is complicated
like it says in readthedocs would inter = await msg.on_dropdown() work?
Try it and see
as i want to permanently track the options so i can edit the output
k
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'MessageWithComponents' object has no attribute 'on_dropdown'
i copied the code from the example given and replaced it with on_dropdown
@slate swan is there any other way i can do it?
Literally no where it's written to use on_dropdown
Click on the exact link I sent, you will get to the section of the example
go to readthedocs
Literally just click on the link I gave........
If you want I can copy the code here if it's too complicated
no
from discord.ext import commands
from dislash import InteractionClient, SelectMenu, SelectOption
bot = commands.Bot(command_prefix="!")
inter_client = InteractionClient(bot)
@bot.command()
async def test(ctx):
msg = await ctx.send(
"This message has a select menu!",
components=[
SelectMenu(
custom_id="test",
placeholder="Choose up to 2 options",
max_values=2,
options=[
SelectOption("Option 1", "value 1"),
SelectOption("Option 2", "value 2"),
SelectOption("Option 3", "value 3")
]
)
]
)
# Wait for someone to click on it
inter = await msg.wait_for_dropdown()
# Send what you received
labels = [option.label for option in inter.select_menu.selected_options]
await inter.reply(f"Options: {', '.join(labels)}")
bot.run("BOT_TOKEN")
As you can see, there is no on_dropdown
Is that the link I've sent though?
If you don't do what we say, why should we help you...
it is there docs page
does a deleted channel have a mention attr
its just a normal channel objext so yes
dude it works with wait_for_dropdown but it does not track options forever
but the client wont render it
hello pppl
i got a error which i dont understand :(
heres the code
ah ok
Well, what's the error, and also show the code at the far right
You're probably missing a ) or similar
?
okay one sec
Nvm ignore it, by mistake, sorry
Cya
Hey @slate swan!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
U mean code?
!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.
use a pasting service (see below)
here my code :)
Indentation is not correct
See the mainhelp line
oo
its 4 spaces itselff
oh yeah got it now
THANKS A LOT :D
@bot.command()
@commands.is_owner()
async def test(ctx):
await ctx.send(
"This is a button",
components = [
Button(style=ButtonStyle.blue, label = 'Click Me!')
]
)
interaction = await slef.bot.wait_for("button_click", check=lambda i: i.components.label.startswith("Click"))
await interaction.respond(Content="Button Clicked!")```why my button doesnt work?
traceback: 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: TypeError: Object of type Button is not JSON serializable
Why do you even use self.bot if you're not in a cog
Just don't blindly copy paste
didnt copy paste
Doubt, have seen this code multiple times already
ik but i heard what he was saying
Is there a way to fetch an invite?
!d discord.ext.commands.Bot.fetch_invite
await fetch_invite(url, *, with_counts=True, with_expiration=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gets an [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") from a discord.gg URL or ID.
Note
If the invite is for a guild you have not joined, the guild and channel attributes of the returned [`Invite`](https://discordpy.readthedocs.io/en/master/api.html#discord.Invite "discord.Invite") will be [`PartialInviteGuild`](https://discordpy.readthedocs.io/en/master/api.html#discord.PartialInviteGuild "discord.PartialInviteGuild") and [`PartialInviteChannel`](https://discordpy.readthedocs.io/en/master/api.html#discord.PartialInviteChannel "discord.PartialInviteChannel") respectively.
