#discord-bots
1 messages · Page 1089 of 1
Dear, Why doesn't it find the file?
@commands.command( name = '123', aliases = ["321"])
async def command_123(self, ctx,):
img = Image.new('RGBA', (8000,4800), '#232934' )
embed = discord.Embed(
title="Был забанен МЕМБЕР",
color= 0xff0000
)
embed.set_footer(
text="| Правительство SK",
icon_url= ctx.guild.icon_url,
)
file1 = discord.File("./ImageO/ban/clear1.png")
embed.set_image( file = file1)
embed.add_field(name="Бан выдан:", value="China", inline=True)
embed.add_field(name="Срок бана:", value="2 дня", inline=True) # по очереди потомучто в конце True
embed.add_field(name='\u200b', value='\u200b', inline=False)
embed.add_field(name="Причина Бана:", value="Причина", inline=True)
embed.add_field(name="Дата выдачи:", value="Дата", inline=True)
await ctx.send(embed=embed)
Did you mean member: discord.Member=None?
yes
Try ```py
embed.set_image(url='clear1.png')
await ctx.send(file=file1, embed=embed)
@slate swan
@commands.command( name = '123', aliases = ["321"])
async def command_123(self, ctx,):
img = Image.new('RGBA', (8000,4800), '#232934' )
embed = discord.Embed(
title="Был забанен МЕМБЕР",
color= 0xff0000
)
embed.set_footer(
text="| Правительство SK",
icon_url= ctx.guild.icon_url,
)
file1 = discord.File("./ImageO/ban/clear1.png")
embed.set_image(url='clear1.png')
embed.add_field(name="Бан выдан:", value="China", inline=True)
embed.add_field(name="Срок бана:", value="2 дня", inline=True) # по очереди потомучто в конце True
embed.add_field(name='\u200b', value='\u200b', inline=False)
embed.add_field(name="Причина Бана:", value="Причина", inline=True)
embed.add_field(name="Дата выдачи:", value="Дата", inline=True)
await ctx.send(file=file1, embed=embed)
🥺
You don't paste it, you integrate it into your code
url='attachment://clear1.png'*
Hooray. Works great. you are the best. Marry me❤️
Use a library that has slash commands, implement them into your bot
Use discord.py/a fork instead of that lol
how?
What do you mean "how"?
how to use forks
🤔 What are you not getting? How to import them? How to download them?
which one
Adding stickers through bot?
Just pip install them using there github clone link
Read that once
!d discord.ext.commands.CommandOnCooldown
Looks like you have a command called commands
exception discord.ext.commands.CommandOnCooldown(cooldown, retry_after, type)```
Exception raised when the command being invoked is on cooldown.
This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
Dear, why does he give out a picture in the upper left corner, although it looks different?
@commands.command( name = '123', aliases = ["321"])
async def command_123(self, ctx, member: discord.Member = None):
img = Image.open("./ImageO/ban/фон.png")
img1 = Image.open("./ImageO/ban/Рамка1.png")
url = str(ctx.author.avatar_url)[:-10] # переменная юрл где юрл нашу аву -10 в конце символов
response = requests.get(url, stream = True)
response = Image.open(io.BytesIO(response.content))
response = response.convert('RGBA')
response = response.resize((1000, 1000), Image.ANTIALIAS)
img.paste(response, (0, 0)) #115 = 100 повыше + 15
img.paste(img1, (0,0))
img.save('./ImageS/user_card.png')
embed = discord.Embed(
title="Был забанен МЕМБЕР",
color= 0xff0000
)
embed.set_footer(
text="| Правительство SK",
icon_url= ctx.guild.icon_url,
)
file1 = discord.File("./ImageS/user_card.png")
embed.set_image(url='attachment://user_card.png')
embed.add_field(name="Бан выдан:", value="China", inline=True)
embed.add_field(name="Срок бана:", value="2 дня", inline=True) # по очереди потомучто в конце True
embed.add_field(name='\u200b', value='\u200b', inline=False)
embed.add_field(name="Причина Бана:", value="Причина", inline=True)
embed.add_field(name="Дата выдачи:", value="Дата", inline=True)
await ctx.send(file=file1, embed=embed)
os.remove("./ImageS/user_card.png")
‘RuntimeWarning: coroutine ‘Client.run.<locals>.runner’ was never awaited
How can I await client.run :-:
you have a command named commands, rename it
!d discord.ext.commands.cooldown
@discord.ext.commands.cooldown(rate, per, type=discord.ext.commands.BucketType.default)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")
A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").
If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.discord.ext.commands.on_command_error "discord.discord.ext.commands.on_command_error") and the local error handler.
A command can only have a single cooldown.
he doesn't have a command named commands .-.
He does
any help?
hey, anyone online wanting to help me on an issue ?
omg exenifix your online. ong ima dm you
Ok
Show me where you do client.run/bot.run
You have to use the full form of on_reaction_add
I have my token in there removed it to send ss
Try doing ```py
if name == "main":
client.run(...) # ... being your bot's token
instead of?
Instead of that utils.get construction
Read the message above that
Also open context menu and reformat your code
Get the users data -> get the users balance
No spaces at all besides between keywords 😔
Maybe
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Help me please🥺
you sure?
He's not going to help you, I'm gonna though.
Which part?
Errors?
balance isn't defined anywhere?
Do you have an error handler?
why are slash commands so annoying lol
nope
"all"*
yea
Yea
show me your error
Have you checked the json file?
I think the error is in the update_bank() function
async def on_reac_add(react,user):
if react.emoji=='🎫':
guild=tic
category=discord.utils.get(guild.categories,id=983345563590352976)
await guild.create_text_channel(name=f"user.name",category=category)```
so can someone fix it?
use get_channel instead of utils.get
Like I mentioned before it needs to be in its full form, on_reaction_add
^ and the event name
and thats it?
on_reaction_add
and it needs @bot.event/@bot.listen() decorator too
I used @bot.evet
but
it still not working
async def on_reac_add(react,user):
if react.emoji=='🎫':
guild=tic
category=discord.get_channel(guild.categories,id=983345563590352976)
await guild.create_text_channel(name=f"user.name",category=category)```
this what I did
@client.command()
async def send(ctx,member:discord.Member,amount = None):
await open_account(ctx.author)
await open_account(member)
if amount == "all" or amount == "max":
amount = balance[1]
if amount == None:
await ctx.send("Please enter the amount")
return
bal = await update_bank(ctx.author)
amount = int(amount)
if amount>bal[1]:
await ctx.send("You don't have that much money!")
return
if amount<0:
await ctx.send("Amount must be positive!")
return
await update_bank(ctx.author,-1*amount,"bank")
await update_bank(member,amount,"bank")
await ctx.send(f"You gave {amount} coins to {member}!")
pic of this
im the 3rd person telling that its on_reaction_add, not on_reac_add
and then you have tic, is it defined anywhere?
get_channel(id, /)```
Returns a channel or thread with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.
and this is the get_channel method
how does it matter?
its name of the fuc
6th line
await guild.create_text_channel(name = user.name, category = category)
whats that ?
still not working
async def on_reaction_add(react,user):
if react.emoji=='🎫':
guild=tic
category=discord.get_channel(guild.categories,id=983345563590352976)
await guild.create_text_channel(name = user.name, category = category)
@bot.command()
async def ticketm(ctx):
global tic
tic=ctx.guild
embed=discord.Embed(title="Ticket", description='open ticket', color=0xf00000)
embed.add_field(name="hi", value="have fun", inline=False)
emoji='🎫'
message=await ctx.send(embed=embed)
await message.add_reaction(emoji=emoji)
its the code
!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.
why this error ?
why.....are you setting tic to global
pass in intents, they are required now
shouldn't I?
because discord py uses the event name as the event name
https://github.com/Rapptz/discord.py/blob/462ba84809f43349296c44cbe6468f631a00edab/discord/client.py#L1017
and the process with calling that event name when event is dispatched
https://github.com/Rapptz/discord.py/blob/462ba84809f43349296c44cbe6468f631a00edab/discord/client.py#L391
discord/client.py line 1017
setattr(self, coro.__name__, coro)```
`discord/client.py` line 391
```py
coro = getattr(self, method)```
`discord/state.py` line 556
```py
self.dispatch('reaction_add', reaction, user)```
?
use discord.Intents, or from discord import Intents
you need to deposit first
How can I open new channel by command
!d discord.Guild.create_text_channel
await create_text_channel(name, *, reason=None, category=None, news=False, position=..., topic=..., slowmode_delay=..., nsfw=..., overwrites=..., default_auto_archive_duration=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a [`TextChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel "discord.TextChannel") for the guild.
Note that you need the [`manage_channels`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to create the channel.
The `overwrites` parameter can be used to create a ‘secret’ channel upon creation. This parameter expects a [`dict`](https://docs.python.org/3/library/stdtypes.html#dict "(in Python v3.10)") of overwrites with the target (either a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")) as the key and a [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/latest/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite") as the value.
Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to [`edit()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.edit "discord.TextChannel.edit") will be required to update the position of the channel in the channel list...
depends if you want a text channel
same goes for other channels, just replace text
okay, now try to send money to someone
try 1
so we have an error in the "all" part.
@client.command()
async def send(ctx,member:discord.Member,amount = None):
await open_account(ctx.author)
await open_account(member)
bal = await update_bank(ctx.author)
if amount == "all" or amount == "max":
amount = bal[0]
if amount == None:
await ctx.send("Please enter the amount")
return
amount = int(amount)
if amount>bal[1]:
await ctx.send("You don't have that much money!")
return
if amount<0:
await ctx.send("Amount must be positive!")
return
await update_bank(ctx.author,-1*amount,"bank")
await update_bank(member,amount,"bank")
await ctx.send(f"You gave {amount} coins to {member}!")
try it
no problem
async def on_reaction_add(react,user):
if react.emoji=='🎫':
guild=tic
category=discord.get_channel(guild.categories,id=983345563590352976)
await guild.create_text_channel(name = user.name, category = category)
@bot.command()
async def ticketm(ctx):
global tic
tic=ctx.guild
embed=discord.Embed(title="Ticket", description='open ticket', color=0xf00000)
embed.add_field(name="hi", value="have fun", inline=False)
emoji='🎫'
message=await ctx.send(embed=embed)
await message.add_reaction(emoji=emoji)```
this is my code and its not creating new channel
can someone help me?
show your code
how to add a role to someone using commands?
commands [bpnumber]```
Specify a list of commands for breakpoint number *bpnumber*. The commands themselves appear on the following lines. Type a line containing just `end` to terminate the commands. An example:
```py
(Pdb) commands 1
(com) p some_variable
(com) end
(Pdb)
``` To remove all commands from a breakpoint, type `commands` and follow it immediately with `end`; that is, give no commands.
With no *bpnumber* argument, `commands` refers to the last breakpoint set...
async def on_reaction_add(react,user):
if react.emoji=='🎫':
guild=tic
category=discord.get_channel(guild.categories,id=983345563590352976)
await guild.create_text_channel(name = user.name, category = category)
@bot.command()
async def ticketm(ctx):
global tic
tic=ctx.guild
embed=discord.Embed(title="Ticket", description='open ticket', color=0xf00000)
embed.add_field(name="hi", value="have fun", inline=False)
emoji='🎫'
message=await ctx.send(embed=embed)
await message.add_reaction(emoji=emoji)```
this is my code and its not creating new channel
can someone help me?
@client.command()
@commands.cooldown(1,5,commands.BucketType.user)
async def balance(ctx, member: discord.Member):
if member == None:
member = ctx.author
await open_account(member)
users = await get_bank_data()
wallet_amt = users[str(member.id)]["wallet"]
bank_amt = users[str(member.id)]["bank"]
em = discord.Embed(title = f"{member.name}'s balance",color = discord.Color.red())
em.add_field(name = "Wallet balance",value = wallet_amt)
em.add_field(name = "Bank balance",value = bank_amt)
await ctx.send(embed = em)
don't global tic. Instead, use react.message.channel
@bot.event
async def on_reaction_add(react,user):
if react.emoji=='🎫':
guild = react.message.channel
someone help pls?
use the aliases kwarg in the command decorator
@client.command(aliases=["bal", "more aliases if required"])
example:
@client.command()
@commands.has_role("Admin")
async def addrole(ctx):
user = ctx.message.author
role = discord.utils.get(user.server.roles, name="Test")
await client.add_roles(user, role)
thx
How to setup jishaku?
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
uh?
@client.command(aliases = ["bal"])
@commands.cooldown(1,5,commands.BucketType.user)
async def balance(ctx, member: discord.Member):
if member == None:
member = ctx.author
await open_account(member)
users = await get_bank_data()
wallet_amt = users[str(member.id)]["wallet"]
bank_amt = users[str(member.id)]["bank"]
em = discord.Embed(title = f"{member.name}'s balance",color = discord.Color.red())
em.add_field(name = "Wallet balance",value = wallet_amt)
em.add_field(name = "Bank balance",value = bank_amt)
await ctx.send(embed = em)
show the traceback @untold sigil a single line doesn't even help a bit
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.
A full traceback could look like:
Traceback (most recent call last):
File "my_file.py", line 5, in <module>
add_three("6")
File "my_file.py", line 2, in add_three
a = num + 3
TypeError: can only concatenate str (not "int") to str
If the traceback is long, use our pastebin.
I am here?
no?
which library?
because hes doing discord.get_channel
Py
I know
!d discord.Client.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
Changed in version 2.0: `id` parameter is now positional-only.

library library, not language
this the code @slate swan
category = bot.get_channel(channel_id)
an iterable isnt required
why you code discord.get_channel ?
Discord.py 1.7.3? I am not getting you
yea ♥️
oh well, jishaku has nice docs to make you setup
i seen that
if you want all features from jishaku, just do load_extension("jishaku")
That doesn't work
its should create channel
what is the sec parameter ?
did you set the owner_id in the bot constructor?
anyone got a sample on how i could fetch all username/user id that has reacted to a msg
does it send error about cmd?
@untold sigil why dont you just do category = react.message.guild.get_channel(YourCategoryID)
At this point, you just don't know python enough and I suggest you to learn abit more and read the doc to know what attributes an object has
you are on 2.0 😔
await client.load_extension
well, then the bot doesn't have perms
is your prefix is breh!
I used still not creating
he has administrator
wonderful, lemme, lemme see
add await at the start of the line
I am 1.7.3
await ctx.author.add_roles("Member")
bruh
thats what I did:
async def on_reaction_add(react,user):
if react.emoji=='🎫':
guild=react.message.channel
category = react.message.guild.get_channel(983345563590352976)
await guild.create_text_channel(name = user.name, category = category)
```
????
import discord
print(discord.__version__)
and see for yourself
@slate swan
trying to trigger the stupid token warning
add_roles take a Role argument, not a string
It isn't needed?
why is it not working
get_role(role_id, /)```
Returns a role with the given ID.
Changed in version 2.0: `role_id` parameter is now positional-only.
if str(react.emoji) == '🎫':
guild=react.message.guild
category = guild.get_channel(983345563590352976)
await category.create_text_channel(name = user.name)```
ok
THANK YOU!!!!!!!!!!
wdmy
role = client.get_role(983358774242861086)
?
better do it like this
@client.event
async def on_command(ctx: commands.Context):
if ctx.guild.id != 1234567890:
return
role = ctx.guild.get_role(1234567890)
if role
await ctx.author.add_roles(role)
just an example
thx
Ohk
Like this is 2.0

example:
you in channel 123 and want send message to channel 1234 ?
get/fetch your server channel and use the send method on it
what the-
?
idk, you don't await load_ext in 1.7.3, did you ever install 2.0?
I did in another vps
you need server id and channel id to send message
What i have to only add await?
<@bot/client/commands>.command()
async def foo(<self>, ctx: commands.Context, *, message: str):
channel = <bot/client/commands/self.bot/self.client>.get_channel(channel_id) or await <bot/client/commands/self.bot/self.client>.fetch_channel(channel_id)
await channel.send(message)
yes.
It isn't getting on now and no errors are showing
Noice idea to prevent copy pasting.
discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
do anyone know what is the issue?, pycord
lamo thanks
You didn't on the intents in developer portal
i think i do, rechecking
no comments
Tf*
i do
Ashley
Message content
What about enabling them in your code
by?
I think you have enabled all in your code
ye
can you show balance command?
I'm clueless or I'm just too unfocused to help rn, sorry
Ok sorry
Golu, you have dpy 1.7.3 installed on the py version your starting your bot with
maybe you write @client.command
?
but @client.command() is true
okie, gonna restart the server
workin, thx
What are you trying to do
these 2 commands work
I wanted jishaku for debugging
This command can only check your money
Yeah and whats the problem?
I swear I have seen this piece of code like 6k times already
hmm how to not use a embed value?, retried value = " " thrown an error
can you hide the Token of bot and submit your Python file?
It isn't possible i think it is required
!d discord.Embed
class discord.Embed(*, colour=None, color=None, title=None, type='rich', url=None, description=None, timestamp=None)```
Represents a Discord embed.
len(x) Returns the total size of the embed. Useful for checking if it’s within the 6000 character limit.
bool(b) Returns whether the embed has any data set.
New in version 2.0.
For ease of use, all parameters that expect a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") are implicitly casted to [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") for you.
Changed in version 2.0: `Embed.Empty` has been removed in favour of `None`.
You want dpy2.0 to be installed also your bot setup must be a bit different than you did in 1.7.3
yea
you can't use await outside a function
U can use \u200b
not it cant
They suggested me bro i wasn't
it is easier wait ill check
Hey everyone 👋

Hi
asyncio.run('jishaku')?
no
Then?
no asyncio.run(client.load_extension(...))
ew
Ah k
you call th coroutine inside asyncio run right?
yreah
but its better to load it somewhere else
why even use dpy anymore-
It is recommended to load cog in setup_hook on startup for dpy2
:thumbsup_tone5:
Just subclass commands.Bot and load in that method
imagine outplaying discord
another one is doing it in the
async def _():
async with bot:
await bot.load_...
but still setup_hook might be better
_()

wait await
** ** this works the same as that
is it worth updating to dpy2? im so used to the old practice i feel pretty lazy to do it
you will have to
lmao thanks
<3

holy _____
can't you do
Ashley need rest
that's the question
no, it isnt, it has to be inside an async func
Oh god 
Lol

I swear I didn't even read it (or read it wrong tbh)
Damn
Now you can code in brainfuck language
@slate swan no dms
hell na
okö
mutual feelings
Thats a brainfuck code
bot = left = right = first = last = None
async def paginate(embeds, msg):
with type('',{'__enter__':lambda _:0,'__exit__':lambda*a:bot.loop.create_task(msg.delete())})():[(embed:=embeds[(index:=locals().get('index',0))+(min(index, len(embeds))-index if r.emoji == right else max(index-1,0) if r.emoji==left else len(embeds)-1-index if r.emoji==last else -index)])and await msg.edit(embed=embed) for r in iter(lambda: await bot.wait_for('reaction_add',check=lambda _r:_r.emoji in(left,right,first,last)and _r.message==msg),...)]```
I will write a whole discord bot like this
bye
lmao
no that's python
Okay, so my problem is I always get an error when using slash commands. Error is AttributeError: aenter I dont even know what that is
Can I send pictures in here or do I have no rights?
what are you subclassing?
I cleared it before I sent
its a magic method, semantically identical to __enter__() but is used for asynchronous programming, __aenter__() magic method is called when starting an async with block
Then Ashley was right
!d asyncio.run
asyncio.run(coro, *, debug=False)```
Execute the [coroutine](https://docs.python.org/3/glossary.html#term-coroutine) *coro* and return the result.
This function runs the passed coroutine, taking care of managing the asyncio event loop, *finalizing asynchronous generators*, and closing the threadpool.
This function cannot be called when another asyncio event loop is running in the same thread.
If *debug* is `True`, the event loop will be run in debug mode.
This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once.
Example...
click on it
correct me if I was wrong, cz idk what I wrote tbh
Oh man, I dont understand a single thing :( Im new to discord.py
that's OOP and is related to python not discord.py
but its okay
it doesn't help you at all with discord.py
i got this option for a command
@lightbulb.option(
'channel',
'...',
TextableGuildChannel,
default=None,
required=False
)
but when i access it using ctx.options.channel i get 'hikari.interactions.command_interactions.InteractionChannel' whereas i want 'hikari.channels.GuildTextChannel'
i get GuildTextChannel when i invoke the command as a prefix command. i want the same for app commands.
hm, check if the channel is an instance of InteractionChannel else, get/fetch the channel using the id
now I doubt it's same as await
"channel is an instance of InteractionChannel" wdym?
run_coroutine_threadsafe!!!
if isinstance(channel, InteractionChannel)
if not isinstance(ctx.options.channel, hikari.TextableGuildChannel):
get/fetch the message
hikari
yeah...

that's what I said 😭 set the owner_id in the bot constructor to your discord id
!d asyncio.run_coroutine_threadsafe
asyncio.run_coroutine_threadsafe(coro, loop)```
Submit a coroutine to the given event loop. Thread-safe.
Return a [`concurrent.futures.Future`](https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Future "concurrent.futures.Future") to wait for the result from another OS thread.
This function is meant to be called from a different OS thread than the one where the event loop is running. Example...
Already
might replace await
is it an integer?
ah, extra work, thanks 👍
Yeah
could I see?
I should replace it?
you just forgot await
But that works fine?
the issue is that jishaku can only be used by the owner of the bot...
no you forgot await
can someone help me with my purge command and editing the embed? I get this error
can't change dev portal won't change dev portal
you edit the message not the embed
ahhh
so i cant edit my embed message?
i did as embed = discord.Embed
message = await ctx.send(embed=embed)
hi! i have a discord bot, but i wanna make a dashboard too, any sggestions on where to start?
did you do this
I swear I was on the phone for 2 minutes, and I get 3 pings and you solve the error by yourself 😔
cant read

So i make mistakes and give you errors you fix that
that's no problem
use asyncio.sleep and assign send a var and use that var to edit
my wifi
late b
it didnt even upload the image for 15 seconds
your error is because
it didnt even upload the image for 15 seconds
you did await ctx.message.delete()
but you already deleted that message
so you can't delete it again
brain="huge"
why the heck are my message getting sent twice
lmao

!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
@slate swan
Yes?

.
How can I import discord_slash? I already used: pip install -U discord-py-slash-command
.
did you reset vsc
ye
then I don't know
U see that question mark there?!!!?
x2
what's your python interpreter and pip version
pip version as in the pip that's set on path
pip version 22.0.4
Yes?
like when you click on the play button in vsc
there's a long yellow text that has the python version in it
Ok
or on bottom left
ah I see, I normally press on execute without debugging
that's your python interpreter
C:/Users/FynnLuca/AppData/Local/Programs/Python/Python310/python.exe this?
Jishaku is sending the traceback in dm why
like this right?
I don't think you need -U
hm okay
ye I just saw it on the internet to install it like this
prolly doesn't matter
already satisfied btw
ye thats my problem
normally its underlined yellow but when I restart my vsc its gone but now it isnt
@commands.command( name = '123', aliases = ["321"])
async def command_123(self, ctx, member: discord.Member = None):
img = Image.open("./ImageO/ban/фон.png")
img1 = Image.open("./ImageO/ban/Рамка1.png")
url = str(ctx.author.avatar_url)[:-10] # переменная юрл где юрл нашу аву -10 в конце символов
response = requests.get(url, stream = True)
response = Image.open(io.BytesIO(response.content))
response = response.convert('RGBA')
response = response.resize((1000, 1000), Image.ANTIALIAS)
img.paste(response, (0, 0)) #115 = 100 повыше + 15
img.paste(img1, (0,0))
img.save('./ImageS/user_card.png')
embed = discord.Embed(
title="Был забанен МЕМБЕР",
color= 0xff0000
)
embed.set_footer(
text="| Правительство SK",
icon_url= ctx.guild.icon_url,
)
file1 = discord.File("./ImageS/user_card.png")
embed.set_image(url='attachment://user_card.png')
embed.add_field(name="Бан выдан:", value="China", inline=True)
embed.add_field(name="Срок бана:", value="2 дня", inline=True) # по очереди потомучто в конце True
embed.add_field(name='\u200b', value='\u200b', inline=False)
embed.add_field(name="Причина Бана:", value="Причина", inline=True)
embed.add_field(name="Дата выдачи:", value="Дата", inline=True)
await ctx.send(file=file1, embed=embed)
os.remove("./ImageS/user_card.png")
Please tell me why the picture in the corner is distorted🥺
It has a transparent background. I think because of this but how to fix it
Can someone give me an example of how to use disnake.Option?
this is so blocking
image processing is blocking the event loop while being slow and intensive
consider running in an executor
same with requests
but there is aiohttp as an alternative
additionally you should be saving to an in memory buffer bytesio and not saving to disk and then removing for the processed images
also can you send the image you are having trouvle with attempting to paste here
@slate swan
you can set jishaku.Flags.NO_DM_TRACEBACK to true if you want
it defaults to dm tracebacks
Bytes? what about bytes?
wot
How to store an image in bytes?
additionally if you use dpy as your main lib consider updating to 2.0 and using the built in slash stuff
@bot.listen
async def on_message(message):
if message.author.id != 983391481589031002:
await message.delete()
```why wont my messages get deleted? i dont understand why it wont work
try await message.message.delete()
😆
what no
bcs im bored and trying to make it so that i can only send messages using the bots message command(thats the id)
message is already a message what is message.message doing except for raising attributeerror
Could you help me with that?
just update to 2.0 via git
What the 
it's working for me breh
py -m pip install git+https://github.com/Rapptz/discord.py like this right?
yepz
did that but what is the built in slash stuff?
and the stuff is under app_commands
Just use disnake lol
then this happens:
With commands extension
from discord import app_commands
from discord.ext import commands
class Bot(commands.Bot):
def __init__(self):
super().__init__(command_prefix="uwu", ...)
async def setup_hook(self):
await self.tree.sync(guild=discord.Object(guild_id)) #passing in the guild is optional and will be globalized instead
bot = Bot()
@bot.tree.command()
async def ping(inter: discord.Interaction):
await inter.response.send_message("Pong!")
is that all your code
in embed=discord.Embed(title="", description=content, color=???) how do i get the main color of the users pfp and set that to the embed color
main colour of user's pfp?
or the color of their banner idc
thanks, I should replace guild_id with id= and then my id right?
!d discord.Member.colour
property colour```
A property that returns a colour denoting the rendered colour for the member. If the default colour is the one rendered then an instance of [`Colour.default()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Colour.default "discord.Colour.default") is returned.
There is an alias for this named [`color`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member.color "discord.Member.color").
i think its accent_color idk about that
its the same thing iirc
accent colour returns the colour of the banner ig
!d discord.User.accent_colour
property accent_colour```
Returns the user’s accent colour, if applicable.
A user’s accent colour is only shown if they do not have a banner. This will only be available if the user explicitly sets a colour.
There is an alias for this named [`accent_color`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User.accent_color "discord.User.accent_color").
New in version 2.0.
Note
This information is only available via [`Client.fetch_user()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.fetch_user "discord.Client.fetch_user").
it doesnt say its an alias of the latter so
yeah, colour for the banner
so what if the user has a custom banner
.banner ?
if member.banner
exists, it will return an Asset object
else, it'll return None
Hi, anyone have any idea how I can add interactive buttons to a message?
!d discord.Button
class discord.Button```
Represents a button from the Discord Bot UI Kit.
This inherits from [`Component`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Component "discord.Component").
Note
The user constructible and usable type to create a button is [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") not this one.
New in version 2.0.
why did u import app_commands
habit ig
Prolly
Nice, tho the preferred path is ui.Button
@client.command()
async self.recover(ctx):
if ctx.author.guild_permissions.administrator:
for channel in ctx.guild.channels:
if channel.name in ('rules', 'moderator-only'):
try:
await channel.delete()
except:
pass
``` this is correct?
no
I was gonna use Client first, then I forgot about using Client in the next line
so?
yeah whichever one u need u could either subclass or make a button in ur command
@maiden fable tell
what's async self.recover
change self.recover to def recover and u r fine
why guild_channel_update is not working?
member.display_avatar.url
where are the docs for what can go inside this?
yup
how to check if a channel is a dm or not
avamember.display_avatar.url
!d discord.Permissions all the attrs of this class
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.update "discord.Permissions.update").
isinstance(channel, discord.DMChannel)
userAvatarUrl = avamember.display_avatar.url
could I do ```py
@commands.has_permissions(mute_members = True)
that isn't a permission name
U can do moderate_members=True
how cani see all the permission names
!d discord.Permissions.moderate_members
Returns True if a user can time out other members.
New in version 2.0.
!d discord.Permissions
class discord.Permissions(permissions=0, **kwargs)```
Wraps up the Discord permission value.
The properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit permissions.
Changed in version 1.3: You can now use keyword arguments to initialize [`Permissions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions "discord.Permissions") similar to [`update()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.update "discord.Permissions.update").
thank u how could i make a kick user command?
like how can i do something like !kick @echo breach and return the mentioned users id?
Nice ping
ddint mean to do that lol
@commands.has_permisisons(kick_members=True)
@bot.command()
async def kick(ctx, member: discord.Member, *, reason):
await member.kick(reason=reason)
ok thank you
oh ok
remove the =None
thats not gonna work just wanna say
Nice now I don't even remember what I was even working on
its on_guild_channel_update
All cool
i know
im gonna play now bai
but not working
bruh
show code
try:
!avatar @user1#7092, @User#50002 (assuming ur prefix is !)
its not gonna work...
Nice, another two pings
wait what
@commands.Cog.listener()
async def on_guild_update(self, after: discord.Guild,
before: discord.Guild) -> None:
await self.client.wait_until_ready()
guild = after
if not guild:
return
if not guild.me.guild_permissions.view_audit_log:
return
async for entry in guild.audit_logs(
limit=1,
after=datetime.datetime.now() - datetime.timedelta(minutes=2),
action=discord.AuditLogAction.guild_update):
if entry.user.id in IGNORE or entry.user.id == guild.owner.id:
return
else:
await after.edit(name=f"{before.name}",
reason=f"venox | Recovery")
if guild.me.guild_permissions.manage_webhooks:
await guild.ban(entry.user,
reason="venox | Anti Guild Update")
@maiden fable
woops didnt mean to
what u even tryna do...
self recover
send a screenshot of you excuting my command
this command is not gonna work
it cant
is the bot public?
@maiden fable see this
I am confused
why my bot is not recover all these channels?
I don't even understand what u tryna do
-__-
yea
@shrewd apex do u mind coming here?
mhm
hey asher
hello
join my test server and check the audit logs
ok well send me that invite link
Can u help Piyush pls?
ok
wat happen
what's ur issue?
@shrewd apex
so what are u trying to do exactly?
show code
@commands.Cog.listener()
async def on_guild_update(self, after: discord.Guild,
before: discord.Guild) -> None:
await self.client.wait_until_ready()
guild = after
if not guild:
return
if not guild.me.guild_permissions.view_audit_log:
return
async for entry in guild.audit_logs(
limit=1,
after=datetime.datetime.now() - datetime.timedelta(minutes=2),
action=discord.AuditLogAction.guild_update):
if entry.user.id in IGNORE or entry.user.id == guild.owner.id:
return
else:
await after.edit(name=f"{before.name}",
reason=f"venox | Recovery")
if guild.me.guild_permissions.manage_webhooks:
await guild.ban(entry.user,
reason="venox | Anti Guild Update")
what's ignore here?
users
there is many stuff wrong here
@bot.command()
async def test(ctx):
button = Button(label="Click", style=discord.ButtonStyle.green, emoji="🥞")
view = View
view.add_item(button)
await ctx.send("testing", view=view)
```why am i getting an error saying that in `view.add_item(button)` theres no item given?
view = View()
so u want to ban people if they change the guilds name?
like wht?
no
join my test server check your dm
ez advertise lmao
did that, and replaced guild_id with id=and my id. But I get an error that the required keyword-only argument: intents is missing. When I add intents=discord.Intents.all(), I get an error that the event loop is closed
You know why?
u prolly don't have those intents enabled in ur own dev acc bot section
is there a better way to count in an infinite loop that doing
count = 0
while True:
if count = something:
do something
count = 0
await asyncio.sleep(1)
count += 1```
hi guys, how can i add a simple mute informations to database? (To 1 server only)
and warn etc..
similar to Dyno modlog
what do you mean simplify it
just add checks for "1 server only" and then just add the information
so if i write !modlog xyz the bot write every mod history (mutes,warns, etc)
are you asking how to do the entire thing or just how to write it to a database
how to write it to a database
https://sqlbolt.com/lesson/introduction this is a good tutorial for databases
SQLBolt provides a set of interactive lessons and exercises to help you learn SQL
ty
Oh hey
Haven’t seen you in a bit
is there a way to get a bot to move a channel specifically somewhere
for example, it moves general right above bot commands
Hey @sick birch do u have any idea how to prevent the logging module from writing to sys.stderr and sys.stdout? I have made it so that its writing to a file but now its writing to both stderr/stdout and the log file
@bot.event
async def on_mentions(bot,ctx,guild):
if ctx.mentions.bot.user:
conn = await aiosqlite.connect('./sql/ghostbot.db')
c = await conn.cursor()
await c.execute('SELECT prefix FROM server_settings WHERE gid = ?', (guild.id,))
result = await c.fetchone()
if result:
embed = discord.Embed(titlle='The current prefix for this server is: ', description=f'{result}', color=0x000000)
await ctx.reply(embed=embed)
return
else:
return
So erm bot doesn't reply with prefix and it doesnt give any errors any ideas?
cz that isn't an event
on_mentions
No sorry, haven't used the logging module much
That's sad
choose folder name
Gonna open a help channel
cogs, modules, extensions, plugins
?
^
people tend to use "cogs" which isnt suitable at all
since the files are just extensions, in context of discord.py
hey, good afternoon! i just want to start with a huge thanks to everyone who took the time to talk with me yesterday and made my bot happen.. this is huge for me as a 1st project.
i have a slight issue. i tried to set the default icon for my bot.. it ended up being square, which i didnt like. so i figured, id open 3d paint (cause it's easy to setup alpha background) BUT doing so, changed the default software that windows uses for the .ico files... now i cant preview the .ico files .. it just shows an icon of 3d paint.
sorry btw, this might be a bit out of context for the channel, i just realised
Just answered u in #ot2-never-nester’s-nightmare
you mean thumbnails?
How make a code to check user status
yeah, like the preview from the folder, sorry wasnt sure how to describe this. thumbnail would be a good one
!d discord.Member.add_roles
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.
Go to your search bar, look up "default apps", scroll down and click on "choose default apps by file type" and change it back
ohh, lemme try that. how are you btw, hows your monday
!d discord.Member.status (you need the preseneces intent for this task)
!d discord.Member.status
property status```
The member’s overall status. If the value is unknown, then it will be a [`str`](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.10)") instead.
the hell
I'm great, you?
Please tell me what to write in {} to get the date and time
bit tired, went to bed at 3:30 am. but my bot works now lol
thankfully i had the day off today
so its a chill day
what date and time
today
datetime.utcnow()?
Good to hear 😄
The bot working, that is, not going to bed at 3 in the morning. Lol
discord.errors.NotFound: 404 Not Found (error code: 0): Interaction is unknown (you have already responded to the interaction or responding took too long) Are the solutions for this error?
(you have already responded to the interaction or responding took too long)
From this I can deduce 2 things:
- You have already responded more than once, so check in your code for any loops or just multiple responses
- Response took too long. Obviously we know what this is, I believe the timeout is ~15 minutes so I don't think that's the issue
i'm pretty sure if you defer the interaction it is 15 minutes otherwise it is 3 seconds
Ah my bad, got them mixed around
Please use #bot-commands
no the timeiout is 3 seconds
you have 3 seconds to respond tp an interaction
otherwise it fails (for the user) and you will get NotFound as you try to respond after
You have already responded more than once, so check in your code for any loops or just multiple responses
this would result in a different error saying "This interaction has already be responded to before"
so its that you took too long
oh someone already said it my bad.
but yea to solve just defer() first (do stuff that takes a while) and then interactio.followup.send.... and other respective methods @slate swan
better use Interaction.edit_original_message, follow-ups can be "floody"
is there a way to get a bot to move a channel specifically somewhere
for example, it moves general right above bot commands
My bot needs to search a Json array an example has been attached for a specific word and if it contains the word it needs to grab the appropriate grouping
[{'text': "This is just a regular little gummy bear,\xa0\nand I've decided to destroy it. To do this\xa0\xa0", 'start': 0.24, 'duration': 5.68}, {'text': "I just have to get a vial, and I'll add a small\xa0\namount of something called potassium chlorate.\xa0\xa0", 'start': 5.92, 'duration': 5.68}, {'text': 'After that I just have to heat it up,\xa0\nuntil it all melts into a nice goop.', 'start': 12.32, 'duration': 4.24}, {'text': 'At this point it should be pretty good, and I\xa0\ncan carefully drop in the poor little gummy bear.', 'start': 19.52, 'duration': 5.36}, {'text': 'Almost immediately the potassium chlorate started\xa0\nripping it apart, and oxidizing it into water,\xa0\xa0', 'start': 28.64, 'duration': 6.32}, {'text': "and CO2 gas. Within just several seconds\xa0\nthough the reaction's already done,\xa0\xa0", 'start': 34.96, 'duration': 5.12}, {'text': 'and my little gummy bear, no longer exists.', 'start': 40.88, 'duration': 2.96}]```
anyone?
!d discord.GuildChannel.position
No documentation found for the requested symbol.
!d discord.abc.GuildChannel.position
The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.
That applies to the TextChannel and etc
Then you can call .edit(position=newposition) on the channel object
thanks
Code
await message.channel.send( 'it worked ' + (message.author.mention))```
**Error**
SyntaxError: 'await' outside function
you can only await within a coro
oO where are you calling that from
huh
can you show the code around it
when you make the function instead of def (ctx): put async def(ctx):
i found a fix
whats the basic underage emoji ID / name?
if payload.emoji.name==("🔞"):
ok, but how can i use this
one second
ok
how would I refrence to guild.channels?
do u have client?
bot.get_channel(ID)
Examlpe
channel=bot.get_channel(123456789101)
np
Noob question: My bot already has the code
bot = discord.Client()```
and I want to add this to the same code:
```py
bot = commands.Bot(command_prefix="$")```
Do I need to (or should I?) join the commands under one `bot` somehow?
Or is it OK to just have those two things on two separate lines?
what
you only need the latter
having both just overwrites anyways so the top like os absolutely useless
All righty, thanks
@commands.command()
@commands.is_owner()
async def mediaperm(self, ctx, member: discord.Member = None):
role = discord.utils.get(commands.server.roles, name="Media Perms")
await commands.add_roles(member, role)
await ctx.send(f"Sucsesfully given {member} Media Perms!")``` What should I put in replacement of commands?
because commands.add_roles nor commands.server.roles work
I tried bot / client
await member.add_roles(role)
read the docs
yeah I just did that
lol
oof it don't work discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'server'
!d discord.Member.guild
The guild that the member belongs to.
guild is equal to server
3am here and i still havent sleep
@commands.command()
@commands.is_owner()
async def mediaperm(self, ctx, user: discord.Member = None):
if user is None:
print("Choose someone to give Media Perms")
role = discord.utils.get(user.server.roles, name="Media Perms")
await user.add_roles(role)
await ctx.send(f"Sucsesfully given {user} Media Perms!")``` ```discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Member' object has no attribute 'server'```
Can someone help?
Change user.server.roles to user.guild.roles
Its called guild not server
@scarlet aurora
thanks
Thats what ashley told u =.=
oh
Sad ashley noises
Goodbye
Maybe time to sleep it's now 337am and i have tuition at 9am
what....what did i do.....sorry
Is it possible to Greedy user id's?
Guys, the commands not work but the log is working, why?
hey, how do i do pip install -U git+https://github.com/Rapptz/discord.py in pycharm
U do that in cmd
yes
if i install 2.0 from here, will 1,7.3 be replaced?
@maiden fable^^
yes, also remove discord
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?
removed discord and installed 2.0 in git bash
but in pycharm it still shows discord.py 1.7
Huh weird
the same cmd
in git bash?
its a different application though
how do i ren that cmd from within pycharm
whats that thing that makes it so only the bot owner can use a command
!d discord.Member
class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").
This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User").
x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/latest/api.html#discord.User "discord.User") instances too.
hash(x) Returns the member’s hash.
str(x) Returns the member’s name with the discriminator.
uhh
Look on the bottom panel of pycharm, there usually is a Terminal tab
Have you installed git?
yeah i did
do git --version
then try installing git again
from where

installing what
git

this is it right
I'm not sure what it is I'm looking at
Just try running the installer again. Sometimes things might not get configured properly when installing, so if something dosen't work like it's supposed to after being installed, it's a good idea to try that installation again
Has anyone worked with slash commands in disnake
I want to know if it's possible to have an option that can take an array of a type, for example tagging multiple members and getting all of them in a single array
Something like this : users:List[Member]=None
if i have a command that does a bunch of stuff with the inputted arguments, can i use them during button interaction?
class View(discord.ui.View):
@discord.ui.button(label="Approve", style=discord.ButtonStyle.green)
async def button_callback(self, button, interaction):
guild = bot.get_guild(ID)
role = guild.get_member(interaction.user.id).get_role(ROLEID)
if role is None:
await interaction.response.send_message("No perms to interact")
else:
discordID = player.id
robloxuser = bloxlink(discordID)
embed = discord.Embed(title = f'{player.name}', description = f'<@{discordID}> : {robloxuser} added to {team}', color = discord.Color.blue())
sheets(robloxuser, team, tmz)
await interaction.response.edit_message(content = None, embed=embed , view=None)
Sure, give me 30 secs to explain this
https://discordpy.readthedocs.io/en/stable/faq.html#why-do-my-arguments-require-quotes
read through this and ask question accordingly
I cannot figure out how to get my discord bot to accept commands while a task is looping
Shouldn't have to be something you have to figure out. What code do you have?
I have a bot that follows artists on spotify and notifies for new releases
The bot is constantly looping to check for new releases
But during that loop, it wont accept slash commands
how are you looping?
@tasks.loop(minutes=1)
async def do_something():
while True:
continue
This is just an example, I'm using tasks.loop
Are you using that while True: loop?
Nah of course not
But even still if I was I need the bot to accept commands during it
😮💨
im kidding haha
But no while true, can send the whole method if you like
tasks shouldn't be blocking the command portion of the bot from running
Yeah, can you send the task?
@tasks.loop(minutes=1)
async def send_new_releases():
artists = db.get_all_artists()
for artist in artists:
channel_id = db.get_music_channel_id_for_guild_id(artist.id)
channel = client.get_guild(int(artist.id)).get_channel(int(channel_id))
# update channel hasn't been set yet
if channel is None:
continue
artist_role = channel.guild.get_role(int(artist.role_id))
# server has manually deleted this artist from their roles
if artist_role is None:
db.remove_artist(artist)
continue
newest_release = get_newest_release_by_artist_id(artist.id)
if newest_release is None:
continue
newest_release_id = newest_release['id']
# If we haven't already notified the channel of this release
if artist.latest_release_id != newest_release_id:
db.set_latest_notified_release_for_artist_in_guild(artist_id=artist.id, new_release_id=newest_release_id)
release_url = newest_release['external_urls']['spotify']
message = await channel.send("<@&%s> New Release!\n:white_check_mark:: Assign Role."
":x:: Remove Role.\n%s" % (artist.role_id, release_url))
await add_role_reactions_to_message(message)
what are you using for db and get_newest_release_by_artist_id?
db is my utility class db=MusicDatabase()
The latter is a method in my spotify api utility file
Should the bot still accept commands during the While True version though?
Because that's what I'm using for testing
while true loops are blocking, which is why you shouldn't use them in asyncronous programs
Gotcha, so wont work for my testing
What's the difference with the bot executing different code though?
It's still preoccupied right
I dont understand, does it have to do with "*"?
But I need it to accept the command regardless of being occupied
Just like a while true loop, make sure that your DB methods and API call methods aren't blocking as well. As long as they "finish fast enough" or are asyncronous, you should be good
Hmmph
for API calls, I would suggest using aiohttp, which discord.py uses, and calling api methods using the bot's ClientSession
correct
Since the task loops every single minute though, there is no speed that could solve this issue no?
What I need is to make the slash command have an option that is basically an array or a collection of the same type like discord emoji or anything
There will always be moments in which the bot cannot accept the command
*members: discord.Member
That simple ?
it sure is
I love slash commands
I would switch over to asyncronous libraries or implementations of what you have now, they would work better and possibly solve your issue
I've only used this in "normal" commands so far, so let's say I do
!shit Vanni Sniper
members will be
members = (vanni_discord_member_object, sniper_discord_member_object)
the difference between
*, members and *members is also explained in that link iirc
wrong ping
it's not, well fuck me
copy paste time
kk let me do some research
ty
@smoky cedar you can take a look at a few other spotify API libraries, like this one, that support async
https://pypi.org/project/spotify/
hey i got a red list of errors when i tried to install python levenshtein
what do i do
I dont think so? it all depends on what is in the loop
Hey, I did like you said but I dont see the users option in slash command, I cant tag anyone
I also have an option wich choices, could it be the one causing the issue
I have no idea how these "suggested arguments" work with slash commands, chances are, you'll have to do it another way
I'm only telling you how I'm doing it in regular commands
not all while loops. But most while True: loops are made to run either forever or for an extended period of time.
yes but its only running whatever is in the loop though so it depends on what is in the loop no?
Do you have an idea of another way
While still using slash commands
I've never used slash commands or anything v2 related unfortunately
#help-chestnut pls
anyone?
what would you say is the best API wrapper for discord.py? disnake, pycord, etc.
im thinking of switching from discord.py to smth that wont be discontinued
discord.py isn't discontinued?
it isnt?
no, it isn't discontinued. It previously was, yes, but now it's being developed again
about a month?
2
I use nextcord
ok
Disnake is great as well
They're really forks tbh they're gonna be extremely similar
Any ideas on how?
Sounds like a #python thing idea
K what yr asking or what that has to do with the library
ok another thing, how would yall suggest making a database for my bot? idk what exactly would be in it but whats simple and not json?
Oo
you're not even asking any questions? you're just stating something
JSON is NOT a database
i know, but some people dont know that :|
sqlite if you want a simple, file-system database (I think that's correct, haven't really worked with db)
ok thx
Yes if you know just don't do it please lmao
lee do you know what should i be doing now?
Make sure it's async sqlite for your bot
ok sry
Naw your fine man :)
:)
how's that related to discord bots?
i use fuzzywuzzy to match my command args
fuzzywuzzy requires levenshtein
also in pycharm, how do i hide my bots token
that's not related to discord bots though. Just because you're trying to use a library with a discord bot doesn't mean it's an issue that belongs in this channel
okay okay i get it
what about this though ^^
import from config, that's what I do
any tutorial vids? this is me first time using pycharm
used to replit until 30 mins ago
there were venvs there, right?
alright, I hope you know what that is
i wish i did 😭