#discord-bots
1 messages ยท Page 1061 of 1
why does this return "None"?
bot_name = str(bot.user).split("#")[0]
print(bot_name)
You know that u can just use bot.user.name
now I do
what is the problem?
discord.ext.commands.errors.BadArgument: Converting to "int" failed for parameter "time".
what inputs did you give
whatever you gave, it can't be converted to an integer
@full lily That's how I wrote
1) mute @nick 1m lol
2) mute @nick 60 lol```
!e
int("1m")
@full lily :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ValueError: invalid literal for int() with base 10: '1m'
^
what ?
interesting:
#discord-bots message
That'd do you good @brave forge ^^
I'm saying that 1m cannot be converted to an integer
use the converter that was linked above
All that's left for you then is to typehint the arg to the class name
and then how do I do the mute command for a while!?
a while?
await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Applies a time out to a member until the specified date time or for the
given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").
You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to
use this...
where the until arg is equal to the converted arg you passed in the command
Unless you're talking about a voice_channel mute
@potent spear no no no no. Here with links to this documentation right away I will not pay attention to your messages
you'll have to learn how to use the docs one way or the other
@potent spear in order to use this documentation, you need to be a professional
I know it looks daunting, but it's really the only way to know what kind of classes and methods are offered in the library
you've been linked to the method that you should use
all that you need to look at is this discord.Member.timeout, to know where to import from
@potent spear she is stupid and created not for newcomers but for those who already know how to do everything without her. And it is used purely to look and remember.
and the function signature await timeout(until, /, *, reason=None), to know what arguments to provide
and obviously the description of what the method does
still remains the same, I'd rather spend a day looking at how the docs work than guessing and googling
bot = commands.Bot(command_prefix='*')
@bot.event
async def on_ready():
print(f'{bot.user} has booted up succesfully!')
class EmbedModal(nextcord.ui.Modal):
def __init__(self):
super().__init__(
"Embed Maker",
)
self.emTitle = nextcord.ui.TextInput(Label = "Embed Title", min_Length = 2, max_Length = 124, required = True, placeholder = "Enter Embed Title")
self.add_item(self.emTitle)
self.emDescription = nextcord.ui.TextInput(Label = "Embed Description", min_Length = 5, max_Length = 4000, required = True, placeholder = "Enter Embed Description", style = nextcord.TextInputStyle.paragraph)
self.add_item(self.emDescription)
async def callback(self, interaction: nextcord.Interaction) -> None:
title = self.emTitle.value
desc = self.emDesc.value
em = nextcord.embed(title=title, description=desc)
return await interaction.response.send_message(embed=em)
@bot.slash_command(name="embed", description="Create a custom Embed!", guild_ids=[id])
async def embed(interaction: nextcord.Interaction):
await interaction.response.send_modal(EmbedModal())
why doesnt this add a slash command to my server?
@potent spear no. I don't want to touch this shit
what are your sources? how do you know what methods a class has without looking at the docs?
because you don't want to use timeouts, or because you don't want to read the docs?
- in my region, this documentation is not loaded well
- the meaning of a long wait if the documentation does not help
- to deal with this piece of shit, you need to take those who wrote this shit as slaves
did u enable the application.commands option in ur bot dashboard?
because I don't want to see this documentation at all
@full lily and why I don't want to see I described above
what do you mean
no, im checking rn
3. to deal with this piece of shit, you need to take those who wrote this shit as slaves??
enable that and bot, then re-invite your bot
@full lily
the fact that the documentation you give me is stupid. The method described in it probably works. But in order for it to work, it needs to be described normally, and in this documentation he described it in a bastard way, well, in other things, like all this documentation
*i dont want the documentation, give me the code
I have described how it can be understood. Under what conditions
I do agree that the way the documentation is written is pretty esoteric, but learning to read it is an essential skill
I've shown you what parts you need to look at, and hopefully that will make it more readable for you
You won't always have a discord server to go to, to ask for help. The docs will be your help
time typehint is incorrect
str(int) is not a valid type hint
worked
did you see the time converter that was linked above?
yes
i mean, you want to timeout a member ๐ถโโ๏ธ
go to docs, look for Member, click on timeout under member
and you have the docs, there's nothing too hard about it.
at least what?
it's nothing difficult for you because when you can do everything without it, of course everything is easy for you
me? am just a basic person who learned python before making a bot.
@slate swan if I know how blender 3d works, then for me any lesson, even with a deaf-mute, will be clear
everyone looks at docs. It's impossible to memorize every class of every library that you work with
learning python WHILE writing a bot is a steep learning curve
especially when you refuse to learn with docs ^
No, I just said the Bot responded with:
Application did not respond
well, the point if u learnt blender-3d b4 that, u didn't magically know it...
I also studied python, but alas, I don't understand such documentation
@paper sluice (sorry for ping)
ah k, lemme see
are you aware of these concepts
- classes
- arguments, positional arguments & keyword arguments
- typehinting
- data types
- and basic built in functions ?
knowing the language to understand such shit will not help
yes
this says otherwise~
it does
the fact that you tried str(int) while the argument contained characters....
try interaction.send instead of inserteraction.response.send_message in the callback
also, in your command function ```py
async def command(self, ctx, member: discord.Member = None, *, time: str(int), reason = 'ะััััััะฒัะตั')
Well, I have other things to do. I'm not like you jerking off to this python
you're clearly not passionate about programming, you're more frustrated ๐
if u dont like python, why bothering making a bot in python ๐คทโโ๏ธ
apparently, someone else's being a jerk.
@blissful lagoon Hey, you. let's give out mute @slate swan for insults!!
why im getting the ImportErro:r: cannot import name 'commands' from 'discord.ext' (unknown location)
i have python installed and python installed from Microsoft too
I'm using vsc
make sure no file is called discord.py by accident
is it not a big C?
@blissful lagoon or are you only enough to be blacklisted after the muta!?
i don't think so
hahah you guys don't have that?
think? you're writing the code...
or a folder named discord...
give me the perm, I won't tell anyone ๐ค
than is a no
did u restart ide after installing?
can you print discord.__version__ ?
how can I do that?
ok
close vsc and start up again
that glitch happens only with the VSC UI, doesnt affect in runtime
mm community of Russophobes. When you say you are not even an insult immediately mute and when you are everything is fine
only thing is that i uninstall it and install it again
think before you speak.
Python 3.10.4
๐
oh that's not it
you unfortunately read that wrong
anyways, restarting vsc should fix it
!mute 419481276765175808 
:incoming_envelope: :ok_hand: applied mute to @brave forge until <t:1653348806:f> (59 minutes and 59 seconds).
please submit a separate report to @novel apex @potent spear
you should actually check the link lol, it has nothing to do with reports
i wonder why other topical channels, but not this channel has reaction perms
I suggest of enabling this, it can save lots of simple "yes and no" replies
^ this, and this replies too
reaction perms are disabled both here and in #python-discussion due to the moderation burden it created; people abused it
moderating reactions is nearly impossible due to lack of logs
using the actual emoji in messages is more feasible from a moderation standpoint
oh, with both of them being fairly active channels, that makes sense/
abusing reactions? 
damn, you'd have to be creative with that
didnt do anything
probably didnt even reach taht point
this is the error btw
nextcord.errors.ApplicationInvokeError: Command raised an exception: TypeError: TextInput.init() got an unexpected keyword argument 'min_Length'
huh? show code
This is EVERYTHING
import nextcord
from nextcord.ext import commands
TOKEN = "token"
bot = commands.Bot(command_prefix='*')
@bot.event
async def on_ready():
print(f'{bot.user} has booted up succesfully!')
class EmbedModal(nextcord.ui.Modal):
def __init__(self):
super().__init__(
"Embed Maker",
)
self.emTitle = nextcord.ui.TextInput(label = "Embed Title", min_Length = 2, max_Length = 124, required = True, placeholder = "Enter Embed Title")
self.add_item(self.emTitle)
self.emDescription = nextcord.ui.TextInput(label = "Embed Description", min_Length = 5, max_Length = 4000, required = True, placeholder = "Enter Embed Description", style = nextcord.TextInputStyle.paragraph)
self.add_item(self.emDescription)
async def callback(self, interaction: nextcord.Interaction) -> None:
title = self.emTitle.value
desc = self.emDesc.value
em = nextcord.embed(title=title, description=desc)
return await interaction.send(embed=em)
@bot.slash_command(name="embed", description="Create a custom Embed!", guild_ids=[976133314610069514])
async def embed(interaction: nextcord.Interaction):
await interaction.response.send_modal(EmbedModal())
bot.run(TOKEN)
I also tried interaction.send_message in the callback but nothing changed
class nextcord.ui.TextInput(label, *, style=<TextInputStyle.short: 1>, custom_id=..., row=None, min_length=0, max_length=4000, required=None, default_value=None, placeholder=None)```
Represent a UI text input.
New in version 2.0.
ya its min_length not Length
testing
@paper sluice
Atleast the Modal popped up this time and I was able to enter text etc.
But now theres a other error
File "c:\Users\user\Documents\Python\exm.py", line 26, in callback
desc = self.emDesc.value
AttributeError: 'EmbedModal' object has no attribute 'emDesc'
I think I got it
I GOT IT
thankfully somewhen
@commands.slash_command(name="removereaction", guild_ids=config)
async def rmreaction(self, ctx, reaction: Option('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both'],required=True ), amount: Option('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0, required=False)):
eroror:
disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: TypeError: unhashable type: 'Option'
You probably have to set the Option as a default value not a type hint
That : probs needs to be an =
(I think)
ight ill trythat
anyone really familiar with the discord api?
if it's readable to you you don't need to force it
well, if you're planning to open source this, do so
You can use a dictionary which maps a tuple of role IDs to strings e.g. ```py
messages = {
(1234, 4567): "You are an Genearl Manager, you cannot release the franchise owner!"
}
for (role_a, role_b), message in messages.items():
if ...: # check the users have the roles
return await ctx.reply(message)
The dictionary is still gonna need a separate entry for each message but at least you aren't repeating as much code
Actually, it can be further improved. I realised the messages are just combinations of smaller parts
Does anyone have a fun api I can use?
Something like ```py
messages = {
1234: "General Manager",
4567: "franchise owner"
}
...
await ctx.reply(f"You are a {messages[role_id]}, you cannot release the {messages[other_role_id]}!")
But it may not be so simple if a user can have more than one of those roles simultaneously.
or maybe assigning internal level to a role, and if your level is lower than a person you act at, it informs about it
Yeah, that's a good idea too. Also realised I haven't looked at this too carefully. The string used is the same as the role name, so using a dictionary isn't even needed for the names.
can someone help me, the question is in this channel. #๐คกhelp-banana message
Making that look good is gonna be a tuff one
i'm making discord bots, for my university, for get information like getting schedule and etc.
yeah i can't find anywhere in google
Well you can iterate over the dictionary and add stuff individual using add_field
Although it will still look bad as you have nested lists and stuff in their
i'm making this bot just need 1-2 hours but... making the data looks good need more than a day 
i'm really stuck dude.
๐ฅฒ
could you paste the json somewhere in a text form, not a screenshot?
of course.
http://47.254.238.244/jadkul/3ka05
{"status":true,"data":{"3KA05":{"Senin":["Analisis&Peranc. Sistem Inf. *\/**","4\/5\/6","E313","L"],"Jum'at":["Terapan Teori Graf","","UGTV",""]},"FENNI AGUSTINA":{"3KA05":["Senin","Pengantar Sains Data","8\/9","E313"]},"L":{"MOHAMMAD IQBAL":["3KA05","Selasa","Sistem Penunjang Keputusan *","5\/6\/7"]},"E313":{"L":["NURWENDO HARICAHYADI","3KA05","Rabu","Disain & Manaj.Jaringan Komputer*"]},"1\/2\/3":{"E228":["","MOCHAMMAD AKBAR MARWAN","3KA05","Rabu"]},"Sistem Basis Data 2 *\/**":{"5\/6\/7":["E514","","YULI KARYANTI","3KA05"]},"Rabu":{"Sistem Berbasis Pengetahuan **":["8\/9","E514","","TRISTYANTI YUSNITASARI"]},"TEAM TEACHING":{"3KA05":["Sabtu","Konsep Data Mining","1\/2","E318"]},"":{"INDAH WAHYUNI":["3KA05","Sabtu","Pemodelan & Visualisasi Data #","3\/4"],"EKA FITRI RAHAYU":["3KA05B","Sabtu","Tatap Muka Penulisan Ilmiah","8\/9"]},"E318":{"":["RISKY WIJAYA","3KA05","Sabtu","Praktikum Terapan Teori Graf"]},"6\/7":{"":["","TIM DOSEN","3KA05C","Sabtu"]},"Tatap Muka Penulisan Ilmiah":{"8\/9":["E433","","AINI SURI TALITA","3KA05D"]},"Sabtu":{"Tatap Muka Penulisan Ilmiah":["8\/9","E433","","ANNA FITRIA"]},"3KA05A":{"Sabtu":["Tatap Muka Penulisan Ilmiah","8\/9","E433",""]},"DIANA IKASARI":{"3KA05E":["Sabtu","Tatap Muka Penulisan Ilmiah","8\/9","E433"]},"E433":{"":["LELI SAFITRI"]}}}
the problem is it's not english so i'm not sure how to interpret it
The Actual Data:
Kelas = Class, Hari = Day, Mata Kuliah = Courses, Waktu = Time, Ruang = Room, Status = Status, Dosen = Lecturer.
oh that helps
If you can get that json into a nice csv
It will be very easy for your eyes and easier to convert to an embed for ya
In terms of readability
!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.
you sure there's no other query to represent the data plain way?
i'm trying to wrap my head around how the json represents this table and i'm failing ๐ฆ
I tried and got lost even after pretifying it cuz non english
ahh yeah this better but...
it seems messed up
no ๐
like once day of week appears as key, the other as an item, then a lecture is a key
looks like it should be csv that was somehow forced to be json
it seems to be corrupted data to me
hmm.... damn
what about source of this table screenshot, couldn't you scrap it?
That's what I planned after this was over, while I using this api first. http://47.254.238.244/jadkul/3ka05
because making scraping will be need more time.
but the data...

are u sure ? 
yes
okay, add friends ๐
Guys I need help @heavy shard YO
you shouldnt ping people like that for help
Lmao wassup
Tbf Iโm still stuck on how to create the tables and stuff in a cog . Since I create my tables mainly in main.py
uh sure, whats the issue for being stuck?
creating invites with the api takes in channel id correct?
channel obj
its a method of the channel obj iirc
yeah so the channel Id would work
Like I do ye setup db in main.py and cursor executes and create tables . Idk if I can make the tables in a cog because I already made a db idk itโs just so confusing
idk why discord didn't allow invites to be made for the guild in general
!d discord.TextChannel.create_invite i agree, but anyways
await create_invite(*, reason=None, max_age=0, max_uses=0, temporary=False, unique=True, target_type=None, target_user=None, target_application_id=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates an instant invite from a text or voice channel.
You must have the [`create_instant_invite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.create_instant_invite "discord.Permissions.create_instant_invite") permission to
do this.
yeah it is kinda weird
okay.....so, how many commads do you currently have for your bot?
you can probably help me. do you know how id get the first Channel (not category) of a guild? @slate swan
cz i would recommend restarting the project if there arent a great numbe of commands
channels = [channel for channel in guild.channels if not isinstance(channel, discord.CategoryChannel)]
first_non_category_channel = channels[0]```
also, I want it to find the first channel that is viewable for the @ everyone role
guild.text_channels[0] exists...
yeah
Hm
lol
Why would u want to generate a VC invite tho? It's for making ppl join VC directly instead of guild
it doesn't really matter I guess, vc or text channel invite
Your wish
I'd rather recommend you to view this -> https://github.com/Dark-Light007/Darker (not self-advertising) and see the project structure, I havent pushed the updates yet pfftt, but it'll be fine
Well before anything lemme say something
I have 1 on message event , level command , lb command , disable / enable the level system , ban , mute , unmute , kick , a server command and user command thatโs all I have. I could restart but I need someone to full one help me with the changes
hunter will, he helps everybody and thats why we love hunter ๐
@maiden fable ๐
With?
this
hm dont restart then, i showed you a basic example of cogs yesterday, didnt I?
Ash told u tho
ah itโs so hard to explain
Not about this part though, "I want it to find the first channel that is viewable for the @ everyone role"
So in main.py I have the level system and all the executes and that stuff . Making more systems in my main.py will make it a huge mess so I wanna make a cog : warning.py and make more tables there while still having main.py tables work and stuff
If it all makes sense
Ngl the best thing is to use bot.dispatch
That's what many ppl do since that results in clean code @warped mirage
hm
And Iโm coding this bot which will be public one day uknow , so it must be fully multi guild
channel = discord.utils.find(ctx.guild.channel, lambda cnl: cnl.permissions_for(guild.default_role).view_channel and not isinstance(cnl, discord.CategoryChannel)

Someone else here sent that code yesterday
then Id just add the first_non_category_channel = channels[0]
nooo
it will return a TextChannel object or None itself
Directly
it could return None
if there is not a single channel in which messages can be sent
textchannel object as in the id or what part of the object?
or viewed*
Imagine not having even a single viewable channel
the whole object
!d discord.TextChannel
class discord.TextChannel```
Represents a Discord guild text channel...
to get the channel ID I can just do channelid = channel.id ?
sigh I just told you to refer to the repo I sent, that would make things easier to understand
Yea
alright
Iโll try ok
if amount.endswith('k'):
withdrawamount = (amount[:-1])
withamount = withdrawamount * 1000
wallet = result['Wallet']
bank = result['Bank']
print(f'{withamount}')
if withamount > bank:
await ctx.reply("You don't even have that much lmao")``` so basically amount is smth in the cmd, for example 3.3k i just dont really know what im doing and its returning stuff like this
Cause it is a string make it an float first
Or make a converter
@slate swan this is what I mean obvs different style but how many can I make
@maiden fable If I already have the guild would I just remove the .guild ?
oh you mean how you're gonna run the setup function on startup?
yes you can but but but, still you have a less number of commands so I recommend upgrading to discord.py 2.0 which offers a lot more functuonality and has bug fixes, and its setup_hook function is what you'd need in order to run the setup functions of your db, like im using hikari and its got a Startup event too
As I said before Iโll do anything but I need help fixing the code after
yeah id rather restart at this point tbh, even though I know that levelling system takes time to make, its a bad one
Is there a lot of changes in 2.0 ?
Like ban commands / permissions do they change a lot
Or events
Page does not exist yet
imo the method should be named db_connection or something along the lines and you should return the connection so the method is literal to a connection
oooof forgot that they changed the url yesterday
you can ofc have a separate setup for other tasks but imo my method of connecting to a db is quite straightforward
its all personal preference
There arenโt to many changes tbf but it looks cleaner
Iโm used to v 1 tho lol so it will take time now to learn v 2 damn
@slate swan Hm i got a, AttributeError: 'Guild' object has no attribute 'channel'
there arent many changes
channels not channel
Ok
ohh
Well Ashley do u think u could help me update my code when I update or nah
@slate swan your issue with relative for pyk got fixed?
yup
imports*
everything is all fixed with imports and docs
ofc everybody is to help here
Ok as a guess can u tell me how many errors I will get from my current code ๐
eh reading the docs is a huge mess when you can viee the source code within the ide and sesrch for the methods
๐ณ
totally not something you would like doing with dpy
as I said, i recommend starting over, plus you said your bot is gonna be public one day, so that levlling system is a really huge mess
small libraries*
Idk how to restart tbf
๐ agreed agreed
Unless u change my code into something better I have no other ideas
i mostly only use docs because its like a shortcut tbh
I'll help you, first make the basic bot structure
And you see the source from the docs itself most of the time, most sphinx themes provide that option
Wdym like client.run and stuff
yes
and a cogs folder, with a .env file with your token and stuff
or a json file
me who uses a py file๐ง
I did the same, but well
it gets the job done!
takes up more space
- imports
was gonna say that
a simple .env file is easier to setup
^
Just write all the Python code in an env file and use dotenv module to get that ezzz
Hunter, dont be silly
Entire bot stored as a string in an env file
On my bucket list
๐ณ
now imagine you are hosting the bot somewhere which doesn't allow you to edit files manually ( railway.app for instance )
envs are the only choice there
just dont host the bot honey๐ฅฐ
It ain't gonna work since Python requires indent blocks. But any other lang which requires brackets can work @stone beacon @slate swan
But u gotta use an eval or smth lol
I mean I can probs parse it
then write a bot in javascript easeee
nah probably exec
i realised yesterday that you can use web development options like console and inspect on discord canary app...
lol
Hm, prolly smth with the textindent lib
hey guys
textwrap*
^
why take on more pain ๐
good news i joined a tech course for next year in my school and theyre gonna teach us basic engineering like basic electricity and programming with cpp java and py๐ณ
Electricity?
electrician?
yeah with capacitors etc
Conngratulations! don't die
Why u rejecting Python on smth as silly as indentation
i use it to ๐ณ
and you're the future of the world, okimii
Because I LOVE javascript
im trying๐
sarthak ๐
okimii the builder, change your name to Bob okimii ๐
why would i?
bob the builder....
sarthak
change your name to builder so were matching
๐ฅฐ
๐ฉ alrighty
๐
can we script it? yes, we can!
yuppp
your name as builder reminds me of coc for some reason ๐ญ
coc๐ง
who plays coc now ๐
not me
hunter about to !ot
Is there smth like eval in js?
exactly the same iirc
Off-topic channel: #ot2-never-nesterโs-nightmare
Please read our off-topic etiquette before participating in conversations.
You're welcome
Oh okay
here you go though ๐
the bot file
thats the .py file right?
A learning guide for the discord.py bot framework written by members of our community.
Can't go wrong here
Now realizing those links are practically invisible to the avg newcomer
I just config.py so Iโll stick with that
fine
pip install -U git+https://github.com/Rapptz/discord.py (you need python 3.8 or later)
Just realized
code?
Why github
channel = discord.utils.find(lambda cnl: cnl.permissions_for(guild.default_role).view_channel and not isinstance(cnl, discord.CategoryChannel), ctx.guild.channels)
channelid = channel.id
because its in the alpha state right now
And itโs some random git, shouldnโt it normally be verified by discord.py
ping hunter, he's the one who gave you the code ps, I dont understand lambda anyways
....?
@maiden fable
Ok makes more sense
!d discord.TextChannel.permissions_for
permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member")
or [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role").
This function takes into consideration the following cases...
Uh @unkempt canyon
Huh?
what happend
Nvm my discord was lagging
Oh
property default_role```
Gets the @everyone role that all members have by default.
would it be ctx.default_role ?
how do I check?
Pip show discord.py
pip show discord.py
it says version 1.7.3
Try updating to 2.0
how?
pip install git+https://github.com/Rapptz/discord.py.git
will it automatically delete my old discord.py version?
Yea
can I do it a different way?
I don't have git installed
I have an idea
o0
yes
Manually download the zip file from github.com and unpack it then open a command prompt in that folder then do pip install .
how do I install git, it'll probably be easier
And istg rud0lf your pfp reminds me of an old friend haha
which do I check?
Next
?
Next
Next
Next
?
Next
i can see a pattern in here ๐
Lmao there's a page where u dont gotta do next
i just want to make sure I check the right things
When u select a coding IDE
?
sorry didn't want to sound sarcastic
By default it's choclatey or smth
it's Vim
Next
Ouh, u should have changed to yr IDE if it's listed
I use thonny so its not listed
If u have selected the IDE, then just click next at everything
Oh cool, just click Next
Ok im doing pip install git+https://github.com/Rapptz/discord.py.git
Sure
oh, now you git it
did you guys git the joke
No I didn't git the joke
it's a pip dry
Name: discord.py
Version: 2.0.0a4296+g78a026aa
Yea
do I need to adjust somethng in thonny too?
No
so I have 2.0 now
๐
I still get the AttributeError: 'Role' object has no attribute '_roles' ๐ญ
yes the same thing
Attribute doesn't have red lines or yellow
Hm
It will just be white
Idrk dude I gotta study for tomorrow's exam
Sorry, but can I help you later?? @slate swan
Best of luck ๐
Man this code wont work https://paste.pythondiscord.com/ocirorunoq Man whats wrong with this
sure I suppose there is some red though
Can u show
Screenshot
Me
No
Error?
No error it just wont give the role to the user and show the channel with that wrole
role'
Wait guys how do I download latest version of dpy again
It'll be helpful if you show the full error/traceback.
So?
pip install -U git+https://github.com/Rapptz/discord.py (you need python 3.8 or later)
Wdym
i use vs code
Does that work ?
yes
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
install git
pip install git?
??
you have to download git to use pip with git urls
i will need help tho
its fine
yeah, am a really cruel person who would feed your device viruses for no effing reason
just because it's longer than 10 seconds?
I been waiting for 7 mins xd on this screen
malware takes time to corrupt your device sometimes
She's kidding
idc lol ill download it later , cuz rn its in alpha stage
Man this code wont work https://paste.pythondiscord.com/ocirorunoq Man whats wrong with this
someone please
.....but but....the master branch is stable...
please tell how it doesn't work... any errors? something does not show up?
Nope well it doesnt work as in it wont sorry wrong code
i mean this one
https://paste.pythondiscord.com/uhubofezel it wont add the role to the user
Idk Iโll try later
do you have 2 on member join events in the same cog?
you need proper intent in main file, you're doing something with intents in the cog, which won't work
fine
nope i only have 2 member joins events
Wdym?
Have you set the intents correctly? You should enable it in both your code and developer portal.
!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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
!e ```py
class A:
def m(self): return 'first function'
def m(self): return 'second function'
print(A().m())
@slate swan :white_check_mark: Your eval job has completed with return code 0.
second function
and yes, intents can be issue too
learn how to use classes first.....
xd
it would be self.client in the class, as you defined in the init dunder
and you miss "self" which is the first argument for a class method
Class instance
When calling a method from a class instance (ie. instance.method()), the instance itself will automatically be passed as the first argument implicitly. By convention, we call this self, but it could technically be called any valid variable name.
class Foo:
def bar(self):
print('bar')
def spam(self, eggs):
print(eggs)
foo = Foo()
If we call foo.bar(), it is equivalent to doing Foo.bar(foo). Our instance foo is passed for us to the bar function, so while we initially gave zero arguments, it is actually called with one.
Similarly if we call foo.spam('ham'), it is equivalent to
doing Foo.spam(foo, 'ham').
Why is this useful?
Methods do not inherently have access to attributes defined in the class. In order for any one method to be able to access other methods or variables defined in the class, it must have access to the instance.
Consider if outside the class, we tried to do this: spam(foo, 'ham'). This would give an error, because we don't have access to the spam method directly, we have to call it by doing foo.spam('ham'). This is also the case inside of the class. If we wanted to call the bar method inside the spam method, we'd have to do self.bar(), just doing bar() would give an error.
Will this work?
No, ids should always be an integer, but in your list, it's a string.
No , it's a string
also your list is not declared inside the function so you need to put global variableName
But I put that in my other bot and works so how wonโt it work on this bot
Oh oops
No I never
As long as he isn't editing the variable, it's fine
!self
Class instance
When calling a method from a class instance (ie. instance.method()), the instance itself will automatically be passed as the first argument implicitly. By convention, we call this self, but it could technically be called any valid variable name.
class Foo:
def bar(self):
print('bar')
def spam(self, eggs):
print(eggs)
foo = Foo()
If we call foo.bar(), it is equivalent to doing Foo.bar(foo). Our instance foo is passed for us to the bar function, so while we initially gave zero arguments, it is actually called with one.
Similarly if we call foo.spam('ham'), it is equivalent to
doing Foo.spam(foo, 'ham').
Why is this useful?
Methods do not inherently have access to attributes defined in the class. In order for any one method to be able to access other methods or variables defined in the class, it must have access to the instance.
Consider if outside the class, we tried to do this: spam(foo, 'ham'). This would give an error, because we don't have access to the spam method directly, we have to call it by doing foo.spam('ham'). This is also the case inside of the class. If we wanted to call the bar method inside the spam method, we'd have to do self.bar(), just doing bar() would give an error.
How can I create a channel in a different server?
My Code:
guild = bot.get_guild(STAFF_SERVER)
await guild.create_text_channel(f'inquiry')
gives me this:
AttributeError: 'NoneType' object has no attribute 'create_text_channel'```
either the bot isnt in the guild or get_guild is returning None
Bro
I just realised the bot isn't in the guild ๐
Good morning everyone
So the main problem are the intents?
morning
guys guys, I was creating a leaderboard command for ranks, and what would be the best way to arrange tuples according to the level values inside them
for example, my tuple looks like this -> (user_id, guild_id, xp, level)
Guys i am getting this error
But i saw the tutorial on GitHub but that have no error
Can anyone help me?
Do it manually ๐
you probably have discord.py v1.7.3, you need 2.0
uhm?
I also need this
wdym
sort by levels?
Need this for my bot
yep
Kinda
sorted(tuple, key=lambda x: x[-1])
wait, I got a list of tuples...
so...
I have 2.0.0
I did with pip install (thatgitlink)
!e
a = [
(4, 3, 2, 7),
(1, 2, 7, 6)
]
print(sorted(a, key=lambda x: x[-1]))
@paper sluice :white_check_mark: Your eval job has completed with return code 0.
[(1, 2, 7, 6), (4, 3, 2, 7)]
!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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
key kwarg works on all elements of the iterable
not the iterable, when u do key=lambda x: x[-1] on a = [(4, 3, 2, 7),(1, 2, 7, 6)] it looks for the last elements of the tuple inside the list, so it sorts by the last 7 and 6
2.0 doesn't work on replit
Iirc
Just don't use replit
why is stated here: #discord-bots message
Why tho ๐ฉ
the main issue here is replit, not the version of dpy
Indeed
ah ic, thanks
how send message
Ctx.send()
def custom_cooldown(message):
if message.author.permissions.manage_messages:
return None # no cooldown
elif utils.get(message.author.roles, name="Nitro Booster"):
return commands.Cooldown(2, 60) # 2 per minute
return commands.Cooldown(1, 60) # 1 per minute
@bot.command()
@commands.dynamic_cooldown(custom_cooldown, commands.BucketType.user)
async def ping(ctx):
await ctx.send("pong")
This was a example for custom cooldown in discord.py server however i'd like to ask is there anyway to make a cooldown condition if the second argument for the command was something specified?
ay I found a pretty good explanation, dude's a legend
find your device -> start it -> let it load -> open discord -> select a server -> select a channel -> click on the text box -> write some shit -> press the sent button/enter button -> the message is now sent -> summing the above steps, use common sense
oh thanks
does this work on replit too?
replit is not discord
...
puberty syndrome
I'm all wrong, nothing's wrong with me
so you can't send a message on replit?
Do u mean discord bot
you can, just contact their customer service
oh
๐
what do I say there
write: "fuck you"
oh ok
๐๐๐
wait, replit has a complete different branch related to hosting, didnt know that'
wow. you can host any file? any time?
With a rip hosting
And get rate limited anytime
toll free
guess so
no never mind, they just say hostingbut in a cooler way
๐๐
Do you guys have a mute cmd for yours guys bot?
Muting others?
nope, discord has an in-built timeout app command, so its better
yes cuz tbh i have a mute cmd but tbh when the member is muted they can still type in the text channels and i dont want them to do that
so thats why i was asking
example?
even when they have the muted roles, they must be having other roles or the text channel permissions aren't done properly
using timeouts is actually better with less api calls and easier
library?
here ill show you my code
Guys how can we download discord.py 2.0.0
@commands.has_permissions(manage_messages=True)
@commands.cooldown(1, 5, commands.BucketType.guild)
async def mute(self, ctx, member: discord.Member, *, reason=None):
guild = ctx.guild
mutedRole = discord.utils.get(guild.roles, name="Muted")
if not mutedRole:
mutedRole = await guild.create_role(name="Muted")
for channel in guild.channels:
await channel.set_permissions(mutedRole, speak=False, send_messages=False, read_message_history=True, read_messages=True)
embed = discord.Embed(title="Muted", description=f"{member.mention} was muted ", colour=discord.Colour.blue(
), timestamp=datetime.datetime.utcnow())
embed.add_field(name="Reason:", value=reason, inline=False)
await ctx.reply(embed=embed)
await member.add_roles(mutedRole, reason=reason)
Reason: {reason}")```
pip install -U git+https://github.com/Rapptz/discord.py (you need python 3.8 or later)
Ok
this is my mute cmd code
thats for disnake iirc, dpy accepts a datetime object
mm add_roles has a reason?
yeah
and what's that last line there?
but it accepts a datetime.datetime/datetime.timedelta....
Ur duty is not over
weird
!d discord.Member.timeout
await timeout(until, /, *, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Applies a time out to a member until the specified date time or for the
given [`datetime.timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta "(in Python v3.10)").
You must have the [`moderate_members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.moderate_members "discord.Permissions.moderate_members") permission to
use this...
hm
It adds roles to user... :/
Being able to pass timedelta actually is pretty gut.
get Englished
you don't say until 10 minutes
or until 4 days
it's positional only
datetime.timedelta(seconds=...)
all you need
or if you don't want to do maths, you have other kwargs in that constructor
yeah but it has to make sense yk
that depends on what library you use
So
really?
I dont even have a timeout command ;-;
!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 Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, 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.
You are asking the question 
Ash is not aggressive so she doesn't timeout her members 
#bot-commands <-
You can write a check but you can't make them invisible.
Ok

I think you're not grasping the context of complexity this involves.
bruh what do you think group commands does? lol
It's not like they're not visible to everyone, but not everyone can use them 
You can't.
theres no user specific commands
It's either global or guild.

group commands are nothing but a command with subcommands
Discord counts "groups subcommands" as valid commands towards max commands.
nothing to do with user/server accessibility
discord's bad
No? Who needs 100+ slash commands?
no
I think they we're pretty generous as well with 100.
No one needs 100+ slash commands.
^ people should really stop making commands that are never needed or have very basic functionality with the slash ui
Your mom
client = commands.Bot(command_prefix="%")
Guys is it correct for prefix
(Me using client not Bot)
@command
async def hello(inter, subcommand, *args):
await inter.idk_but_send("Yeah you used a subcommand too Ig, just solved everything in one command")
๐wtf no
Sad :(
Suggest more topics here!
I'm sorry for ur loss
leave
Not having slash commands
client = commands.Bot(command_prefix="%")
Guys is it correct for prefix
(Me using client not Bot)
๐ซ
yeah
how sad
How would Discord know that you disallowed it in your code?
what is it though
Sorry no error me mad lmao
but I know there was something so somebody wouldn't see a command
Doesn't slash v2 already do it
hidden=True in the command deco?
your "has_permissions" isnt passed to the discord
so stop dreaming about that
That's ephemeral, it doesn't hide the slash command in the context.
I know what I'm talking about panda
๐
that just hides the prefix commands in the help command lol
But those are handled locally by generating a message. Slash doesn't work like that.
How can we know about version of discord.py using pip?
nvm uhhh
pip show discord.py
Ok
Discord is busy with slashDM right now.
Or discord.version If you have the terminal
__import__("discord").__version__
seems like something you'd need visibility permissions for
Well there aren't any permissions inside a DM.
I downloaded latest version with pip 2.0.0 but it showing 1.7
pip on replit is useless
bruh atleast who you sync it to
replit uses poetry
Hmmm
Most likely.
How can I add latest version then
you gotta install discord.py git branch using poetry
git+https://github.com/Rapptz/discord.py
I too forked disnake๐ฉ nd made my own
https://github.com/Client13/runzcord hehe anybody interested u cn trynd rate
tf is your bio link even
๐
is it possible to add cooldowns on on_message ?
huh?
can u elaborate?
well your bot doesn't have any attribute called muted_users.
so define it first
ohh ok
what would be the logic behind this?
Guys my replit keeps adding aiohttp again and again even it's already installed
thats how replit works..
.
ohhh that's replit... with funny link names... i used it before
didn't know you can use it for bots
bro it needs aiohttp to install stuff
?
aiohttp is for streaing downloads asynchrounously
same for a bunch of other forks
!d aiohttp
isn't it part of the stdlib?
i used to think requests is part of the stdlib too, but it ain't
@commands.slash_command(name="removereaction", guild_ids=config)
async def rmreaction(self, ctx,reaction: Option('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both'],required=True ), amount: Option('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0, required=False)):
disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: TypeError: unhashable type: 'Option'
you're still stuck on that same error?
have you looked at examples of the Option by now?
are you coding on your phone ๐จ
coding on phone is cumbersome
Ye
like for a levelling, i want to add cooldown
which examples are you talking about? i probially lost them
thats not related to the library, yeah, discord allows it
I just wanna make sure cause I haven't seen a bot coded in Python use a local GIF file
!local-file
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
Yeah, I already did that with PNG files, but never a GIF until now
a gif works just like a normal image
@potent spear could you help me find them?
Ctrl f in this channel Iโd suggest
how to put variable in if statement?
colourtypes = ['blue',
'cyan',
'orange']
if colourtypes in message.content.lower():
await message.channel.send()
other way around, if message.content.lower() in colourtypes
but you need to send something
thxs for the help
send() shouldn't be just empty ()
i know, im just testing
ah okay ^_^
if any( color in message.content.lower() for color in colortypes)
^ you don't see if a list is in a string
lol i couldnt find what you were talking about.
i found a doc and now im just getting the issue of required is an unexpected keyword argument
also the link to the doc https://docs.disnake.dev/en/latest/ext/commands/slash_commands.html
In 4.options.0.choices.0.value: Choice values must be of type "integer"
In 4.options.0.choices.1.value: Choice values must be of type "integer"
In 4.options.0.choices.2.value: Choice values must be of type "integer"
warnings.warn(
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-3' coro=<startup() done, defined at C:\Users\Andy\PycharmProjects\WhiskeyBotMain\wb.py:111> exception=AttributeError("'NoneType' object has no attribute 'get_channel'")>
Traceback (most recent call last):
File "C:\Users\Andy\PycharmProjects\WhiskeyBotMain\wb.py", line 131, in startup
location = bot.get_guild(GUILD_ID).get_channel(CHANNEL_ID)
AttributeError: 'NoneType' object has no attribute 'get_channel'```
```py
@commands.slash_command(name="removereaction", guild_ids=config)
async def rmreaction(self, ctx,reaction: int = commands.Param('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both']), amount: int = commands.Param('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0)):
msgs = [message async for message in ctx.channel.history(limit=amount)]
Have you read the error?
i understand the bottom one
Fix that one first
but idk what part of the options arent int
You typehinted reaction to int, but on your choices, it's not a list of ints.
wait how does a list of ints look?
oh lol i had it as strings. now i understand
!rule 1
1. Follow the Python Discord Code of Conduct.
oh it works
I keep getting this error when I try to make a command for Banning:
Traceback (most recent call last):
File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "main.py", line 111, in ban
await discord.Guild.ban(member, reason)
File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/guild.py", line 2026, in ban
await self._state.http.ban(user.id, self.id, delete_message_days, reason=reason)
AttributeError: 'str' object has no attribute 'id'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 145, in on_command_error
raise error
File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/runner/Rolands-Final-Project/venv/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/runner/Rolands-Final-Project/venv/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: 'str' object has no attribute 'id' ```
this is the code
```py
@bot.command()
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, *, reason):
await member.send(
f"You've been banned from **{member.guild.name}** for reason: **{reason}**"
)
await discord.Guild.ban(member, reason)```
Have you read the error?
yes
discord.Guild has to be ctx.guild
Thereโs a difference between a class and an object
then how do i make it int lol
integers are 1, 2, 3......
How are you using choices in your code
reaction: int = commands.Param('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both'])```
How are you using it in your code?
ill just copy the command since idk what part you mean lol
@commands.slash_command(name="removereaction", guild_ids=config)
async def rmreaction(self, ctx, reaction: int = commands.Param('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both']), amount: int = commands.Param('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0)):
msgs = [message async for message in ctx.channel.history(limit=amount)]
count = 0
for amount in msgs:
if reaction == 'checkmark':
await amount.clear_reaction('โ
')
await amount.ctx_reply(f'cleared (checkmark) reaction^ (number {count} out of {amount} messages')
count = count + 1
return
elif reaction == 'furheart':
await amount.clear_reaction('<furheart:802746458088013864>')
await amount.ctx_reply(f'cleared (furheart) reaction^ (number {count} out of {amount} messages)')
count = count + 1
return
elif reaction == 'both':
await amount.clear_reaction('โ
')
await amount.clear_reaction('<furheart:802746458088013864>')
await amount.ctx_reply(f'cleared (furheart and checkmark) reactions^ (number {count} out of {amount} messages')
return
else:
ctx.respond('{option -> reaction must be checkmark, furheart, or both.')
return
It seems that the objects in the list there need to be from discord, not simply strings
It's outside of my field of knowledge about the library though
(disnake)
!d disnake.ext.commands.Param
disnake.ext.commands.Param(default=Ellipsis, *, name=None, description=None, choices=None, converter=None, convert_defaults=False, autocomplete=None, channel_types=None, lt=None, ...)```
A special function that creates an instance of [`ParamInfo`](https://docs.disnake.dev/en/latest/ext/commands/api.html#disnake.ext.commands.ParamInfo "disnake.ext.commands.ParamInfo") that contains some information about a
slash command option. This instance should be assigned to a parameter of a function representing your slash command.
See [Parameters](https://docs.disnake.dev/en/latest/ext/commands/slash_commands.html#param-syntax) for more info.
Incorrect, it accepts List[OptionChoice], List[str | int], Dict[str, str | int]], they just need to change the list of strings to list of ints.
await ctx.guild.ban(member, reason)
TypeError: ban() takes 2 positional arguments but 3 were given```
I do ?ban (my alts username) test
and it gives this reason after changing it to ctx.guild.ban
Why does it say something about an ID though
you need to use an instance of discord.Member, not the class
ints don't have an id attribute either
reason=reason
Traceback (most recent call last):
File "main.py", line 3, in <module>
import music
File "/home/runner/musicot/music.py", line 20
async def disconnect(self,ctx):
^
IndentationError: unexpected indent
does anyone know what does this mean
the error is not coming from this code,you have something wrong in your ,startup function
Hmm? I don't see any ID thing on their error/code. The error containing .id attribute error is another person's issue.
!indent
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
I think he is using the class instance, just that it is member.ban instead of ctx.guild.ban
Oh
My bad then
ctx.guild.ban works too ... I just needed reason = reason
and you typehinted "reactions" to int , and have strings in the choices.
Anyone know how can we make a code run comamnd like @unkempt canyon have?
an eval?
Do you mean eval command? It's quite complicated as it uses a sandbox called "snekbox". But you could make your own simple eval command, https://github.com/Rapptz/RoboDanny/blob/rewrite/cogs/admin.py#L214-L259 (this is quite simple, but really unsafe and you shouldn't make it public).
Has anyone had an issue where your trying to shut down the bot inside terminal via CTRL + C
and the bot stops but terminal get's freezed?
do it twice
just spam the ctrl+c I'd say
you don't have an exception handler for a keyboardinterrupt right?
a typical except Exception
Not sure If that says something but ctrl c works for other py scripts
Hey guys, is there a way to send end embed to more then 1 webhook at once?
Thats my code:
#create the embed
webhook = DiscordWebhook(url=hookurl_sale, username=username_sale)
embed = DiscordEmbed(title=name, description="๐ฅ SOLD", color=0x0099ff)
embed.set_title(name)
embed.set_url(buyNow)
embed.set_image(url=str(pic))
embed.add_embed_field(name="Rank", value=str(rank), inline=True)
embed.add_embed_field(name="Buyer", value=f"[{wov_name}]({profile})", inline=True)
embed.add_embed_field(name="Blocknumber", value=f"[{blockNumber}]({tx_link})", inline=False)
embed.add_embed_field(name="Attributes:\n", value=metadata, inline=False)
webhook.add_embed(embed)
#send the embed to webhook
webhook.execute()
print("send webhook")
print("------------------------------------------------------")```
Odd my start up function hasn't changed and had worked for days
have you read the error?
read the second ping
Hmm how can I fix that... idk how to have the choices entered in there. Any reccomendations on how to format it
Yeah but i dont know how to fix it?
you HAVE entered choices there/
well, tell me what's wrong according to you
learning how to read the error is one step in the right direction
Wait is it like mute.role = []
Traceback (most recent call last):
File "main.py", line 3, in <module>
import music
File "/home/runner/musicot/music.py", line 48
def setup(client):
^
IndentationError: unindent does not match any outer indentation level
how do i fix this
this has already been answered, don't repost
ok
Please show me how to fix it please since I haz broken brain
either remove the int typehint from the reactions argument, or remove the choices kwarg from commands.Param
Well i dont know
what line in your error do you think tells the most about your issue?
Ok. I'll remove the type hint any try it.
yes, and by doing that you are allowing the reactions argument to be a normal string
hmm i got
disnake.ext.commands.errors.ExtensionFailed: Extension 'cogs.events' raised an error: TypeError: ParamInfo(name='', name_localizations=<disnake.i18n.LocalizationValue object at 0x0000027A5E692380>, description='Your choice depicts what reaction will be removed', description_localizations=<disnake.i18n.LocalizationValue object at 0x0000027A5E6923B0>, default='reaction_name', param_name='', converter=None, convert_default=False, autocomplete=None, choices=['checkmark', 'furheart', 'both'], type=<class 'str'>, channel_types=[], max_value=None, min_value=None, large=False) is not a valid parameter annotation
so you removed the = too.
yes
i have ```py
async def rmreaction(self, ctx, reaction: commands.Param('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both']), amount: commands.Param('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0)):
now
๐ถโโ๏ธ ```py
async def command(inter, param = commands.Param(*args)):
...
ah
its not an annotation, you are providing a value for that arg
i have an error in the ide that says unresolved refrence 'param'
its a guild emoji
@commands.slash_command(name="removereaction", guild_ids=config)
async def rmreaction(self, ctx, reaction: param = commands.Param('reaction_name', description='Your choice depicts what reaction will be removed', choices=['checkmark','furheart','both']), amount: param = commands.Param('how_many_messages', description="Your input depicts the number of messages who's reactions get removed.", min_value=0)):
msgs = [message async for message in ctx.channel.history(limit=amount)]
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'param' is not defined
this is what u r doing
let arg be typehinted param and be equal commands.Param( ... )
i tried replacing the int typehing with str and didnt get an error
but something in my code is still broken
wait which of these are supposed to be selected
wrong permissions would give you error 403
