#discord-bots
1 messages · Page 75 of 1
@bot.listen()
async def on_message(message):
channel = str(message.channel.name)
user_message = str(message.content)
guild = message.guild
id1 = 1012461675624013947
id2 = 1015374433604616242
if message.channel.id == id1:
await bot.get_channel(id2).send(user_message)
You would do
channel = bot.get_channel(id2)
Then await channel.send
Separately
So altogether
channel = bot.get_channel(id2)
await channel.send(whatever you want)
That won't change anything
id2 is either invalid or your bot can't see it, or doesn't have it cached
what
didnt work
True
Maybe re check the id you entered
this works for me
hm
from server to server?
like a broadcast command ?
Are you 100% sure your bot has permissions to see the channel from the other server?
Ye because for me now that code looks fine
what are the perms needed
I don't know the exact name off the top of my head, but if you go into that channel in the other server can you see your bot in the member list?
ye
The bot has perms to view those channels
Also the error message does not say missing perms
It says the channel is none type
what
Which means it wasn't cached
Ye
You don't get an error for missing perms with get_channel you get it with fetch channel
what does cached mean
No it’s says none type has no attribute send
Meaning it’s not able to find the channel
doe sit have to be the smae channel in both servers?
Wdym
I'm not sure when I said that it did anything other than that? I'm just saying that "Also the error message does not say missing perms
" doesn't make sense in the case of get_channel
yo so how can I store the id of a message which i send as this does not work and returns
AttributeError: 'NoneType' object has no attribute 'id'
message = await interaction.response.send_message(embed=embed, view=view)
print(message.id)
i know what i was doing
i am dumb
i was getting the server id
not the channel id
InteractionResponse.send_message doesnt return any message object so you have to use Interaction.original_message() afterwards
await interaction.response.send_message(embed=embed, view=view)
message = interaction.original_message()
like this?
with await as per docs
o ye shit
message = await interaction.original_message()
is it like this as it still is returning
AttributeError: 'NoneType' object has no attribute 'id'
can you show the entire traceback?
sure
Ignoring exception in command embed create:
Traceback (most recent call last):
File "C:\Users\Medwi\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 1053, in _call_with_hooks
await callback(*args)
File "C:\Users\Medwi\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 1135, in call_invoke_slash
await self.invoke_slash(interaction, **kwargs)
File "C:\Users\Medwi\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 1226, in invoke_slash
await self.callback(self._self_argument, interaction, **kwargs)
File "c:\Users\Medwi\OneDrive\Desktop\Coding\modules\Embed\cog.py", line 167, in create
print(message.id)
AttributeError: 'coroutine' object has no attribute 'id'
The above exception was the direct cause of the following exception:
nextcord.errors.ApplicationInvokeError: Command raised an exception: AttributeError: 'coroutine' object has no attribute 'id'
Ignoring exception in on_application_command_error
Traceback (most recent call last):
File "C:\Users\Medwi\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\client.py", line 417, in _run_event
await coro(*args, **kwargs)
File "c:\Users\Medwi\OneDrive\Desktop\Coding\modules\Moderation\cog.py", line 599, in on_application_command_error
raise error
File "C:\Users\Medwi\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 1053, in _call_with_hooks
await callback(*args)
File "C:\Users\Medwi\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 1135, in call_invoke_slash
await self.invoke_slash(interaction, **kwargs)
File "C:\Users\Medwi\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\application_command.py", line 1226, in invoke_slash
await self.callback(self._self_argument, interaction, **kwargs)
File "c:\Users\Medwi\OneDrive\Desktop\Coding\modules\Embed\cog.py", line 167, in create
print(message.id)
AttributeError: 'coroutine' object has no attribute 'id'
AttributeError: 'coroutine' object has no attribute 'id' is the actual error
it means message was a coroutine, and if you unintentionally have one of those, it just needs to be awaited
I don't think .send_message() returns anything
o wait im an idiot just figured out what i was doing wrong
Code:
import discord
from discord.ext import commands
class Buttons(discord.ui.View):
def init(self, *, timeout=180):
super().init(timeout=timeout)
@discord.ui.button(label="Button",style=discord.ButtonStyle.green)
async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
await interaction.response.edit_message(content=f"This is an edited button response!")
@bot.command()
async def button(ctx):
await ctx.send("This message has buttons!",view=Buttons())
Error:
2022-09-04 21:21:33 ERROR discord.ui.view Ignoring exception in view <Buttons timeout=180 children=1> for item <Button style=<ButtonStyle.success: 3> url=None disabled=False label='Button' emoji=None row=None>
Traceback (most recent call last):
File "C:\Users\Jim\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ui\view.py", line 425, in _scheduled_task
await item.callback(interaction)
File "J:\coding\Vs projects\bot\Merlyn.py", line 2266, in gray_button
await interaction.response.edit_message(content=f"This is an edited button response!")
AttributeError: 'Button' object has no attribute 'response'
How do i solve this ?
!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.
?
But it should be async def gray_button(self, interaction: discord.Interaction, button: discord.ui.Button):
This is how you format code to make it look like code and not like a blob of text
ok
if ctx.channel.id == 69420:
print('hello')``` for example the colors
this is the same just flipped
Yes, it must be flipped.
Whatever tutorial you watched has it wrong
this makes life easier
https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f will probably be a big help with your slash commands
discord.py 2.0a slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
i dont really understand what they say but ok thanks
btw
can i use slash command and text commands in 1 bot ?
i wanted to ask something related to the bot code
ok
Don't ask to ask, just ask
yes
so much ask in 1 sentence
ok ty
idk why this thing is letting the code work properly for some reason
How do i get the text of my embed if I store it in a variable?
I have something like client = PersistentViewBot() and py @client.command() async def test(ctx): ctx.send('test') and also py @client.tree.command(description="Idk") async def idk(interaction: discord.Interaction): await interaction.response.send_message('idk')
Can you explain further?
Show us what you're doing
Okay
i try to change but it doesn't work and it gives this
self.instance = await self.ctx.send(embed=discord.Embed(
title = f'{self.ctx.author.name}\'s snake game.',
description = generateSnakeBoard(self.COLUMNS, self.ROWS, self.head, self.body, self.apple)
))
I store it in self.instance
but how do i get the description of that embed
Put intents = discord.Intents.all() above it and do client = discord.Client(intents=intents) and try that
Probably just self.instance.title?
Not 100% sure though, just a guess
I tried self.instance.description
doesnt work\
Hmmm, not entirely sure then
How to write colorful like this?
.
that worked but now my prefix line is giving an error
Send the code and the error
is ther like a limited prefixes or somethin?
sorry because im bad at coding and stuff
It's commands.Bot
discord.py is not beginner friendly, it's strongly recommended to at least have an understanding of Python before using it.
& also you shouldn't be using repl as your host. It's not a host and bots get banned very often. @toxic hornet
so what should i use?
An actual host or VPS.
vsc?
You could self host it if you want, but just use python3 main.py to run it
got it
Hosts are really quite cheap, $1/month for a bot host or maybe $2/month for a VPS that you can do whatever you want with it
...just don't get carried away with a lot of hosts 😂
How to make it so that such commands were displayed after you clicked on the bot's profile?
Is that not just their about me?
Those show up on verified bots
ah
And ok thanks
By the way, what is the difference between nextcord and discord.py, since I make bots on both libraries, I didn’t notice the difference
You can try, but the problem is that I would like the bot to put on the github for this is not an option
Since nextcord is a fork of discord.py, it's very similar in structure, with a few minor changes to how you actually write your bot, but under the hood there are some other changes
nextcord is a fork of discord.py- I recommend using discord.py though, it's more supported.
From what I've heard, nextcord is less performant than nextcord
i usually use nextcord like discord.py ui issues
damn I didn't catch that one
noway, is that even possible?
I wanna mimick irl in a discord bot as a project for me to keep learning python
Shoukd I make a map for the bot with cities?
I dont think I fully understand what u are trying to do
how can i make it so duo points and trio points are next to eachother
when i set trio points to inline=True
doesnt work
not rly possible, if the field is inline=False, itt will be only one in a row
you could do it by using an "empty" inline field after solo points, though it would show as a big gap on mobile where inline has no effect
thats annoying
heyo, for nested Select views, would I have to create a new class for each level?
How would you nest select views?
Do you mean like, multiple select menus per message?
I just mean like once a select option is chosen, a new select menu would appear
Ah. That's not nested, are you nesting your classes inside of one another?
Should I just have lists of options and swap out which options are in the menu?
No, my apologies for bad vocab
basically, yeah. You'll have to edit the message with a completely new select menu
Would I have to write new classes for that?
Probably not, though you could
I see. I'll mess around with the options and see what I can come up with
You can just edit the current select menu and re-send that instead
Sounds good
Make the 4th line in line true
So in trio points field make in-line true
I believe that should fix it unless I’m dumb
But make duo points in line false
i tried that but didnt work
takes some to appear for me
Can someone help me make a discord bot
I can help a bit
pingme if yo ureply
Why not learn how to make one? https://tutorial.vcokltfre.dev/
A tutorial to help you make better Discord bots.
Yeah I tried but there’s always a error
I’ve been trying since last night
Please do
how can i have like a listener that sees if someone does something which then gives them something after
ive got this rn but it doesnt work
You can always asks for help?
Well listeners listen for API events not custom events
You can just call the function yourself as and when
not exactly
You can dispatch an event manually but that's discouraged
By the way listeners are abstracted it lets you register namespaces to you bot e.g setup_hook so not always
Sure. Doesn't apply here though
Thank you
That’s what I was saying can someone help me
I’m outside rn tho
Well listeners listen for API events not custom events
I was correcting your statement as its not true
API events arent even a thing lol
Gateway events are dispatched from the gateway to the client through a bidirectional TCP connection, a websocket
i appreciate theres a bit of a disagreement here so sorry to but in but what can i do to solve this?
Well your function is a callback of your own design
From the name i'm assuming you're wanting it fired when a user ranks up
yep
So, when a user ranks up, call the function yourself
That would depend on your implementation
like how can i always be waiting/ready for someone to rank up
What causes someone to rank up?
so people get points from winning games. these points are saved into a database using sqlite3. to rank up there total number of points across all gamemodes theyve played must pass a certain threshold. for example once they reach 180 points they will recieve the role Bronze 2
Ok so these games are commands?
When they get their points from the games and you add to the database, check if the returned updated value is >= 180
yes there is a addpoints command that the host of the game gives to someone when they win
So that's where you check and call the function if need be
lmao yes i have that
but how can i listen for that
i dont think im explaining this well
what decorator do i need is what im asking
So in your else clause, call the rank_up function. You don't really need a decorator but if you use command.Listener it gets registered to your bot class as an attr anyway
Id just do self.bot.rank_up = self.rank_up in the Cog init
Then in the else clause await self.bot.rank_up(...)
i might have to redesign this
because currently i have this ```py
@commands.Cog.listener()
async def rank_up(self, interaction: discord.Interaction, user: discord.Member):
cur.execute(f"SELECT * FROM StrucidDatabase WHERE User = '{user}'")
for row in cur.fetchall():
if row[2] + row[3] + row[4] +[5] >= 90:
if user.has_role(1016072372224270438):
pass
else:
await user.add_roles(discord.Object(id=1016072372224270438)) # Role ID of the role you want to give
await interaction.response.send_message(f"{user.mention} has ranked up to Bronze 3")
elif row[2] + row[3] + row[4] +[5] >= 180:
if user.has_role(1016072383502745701):
pass
else:
await user.add_roles(discord.Object(id=1016072383502745701))
await interaction.response.send_message(f"{user.mention} has ranked up to Bronze 2")
elif row[2] + row[3] + row[4] +[5] >= 270:
if user.has_role(1016072395179708436):
pass
else:
await user.add_roles(discord.Object(id=1016072395179708436))
await interaction.response.send_message(f"{user.mention} has ranked up to Bronze 1")
pain
pain
Heyo, I'm trying to pass final_character here to the command below. How should I do it?
class CharacterModal(discord.ui.Modal, title="Character Used"):
character = discord.ui.TextInput(label="Character", placeholder="Waluigi", required=True)
async def on_submit(self, interaction: discord.Interaction):
final_character = self.character
Here is the command:
@mk_commands.command(name="upload", description="Upload your fastest time for each course.")
async def upload(self, interaction: discord.Interaction):
await interaction.response.send_message("Which **cup** is your course in?", view=MarioKart.CupView())
character = final_character
ok first thing is to make a function that can send message and add role
it's just cleaner and you have less copy paste
it will cause much less pain later on
then I would use discord.utils to get a role instead of calling an object
but that's optional
could u possibly paste this into dms because ngl i’ve been working on this all day and night
and it’s killing me
gonna get some sleep
and next make a calculate level function to return a role and a messsage
oksleep is important
thanks
done
thanks gn
np
you would use the instance created to use the instance variable
the final_character variable doesn't come from one place however. It can come from either a Select view or a Modal.
For example:
class CharacterSelector(discord.ui.Select):
def __init__(self):
options = []
super().__init__(placeholder="Choose the character you used", min_values=1, max_values=1, options=options)
async def callback(self, interaction: discord.Interaction):
if self.values[0] == "other":
await interaction.response.send_modal(MarioKart.CharacterModal())
else:
character = self.values[0]
await interaction.response.edit_message(content="What vehicle did you use?", view=MarioKart.VehicleView())
but final_character is declared to an instance variable?
final_character = self.character here its set to the current instance of CharacterModal so you would access its value with the instance created?
The instance is dependent on the user input though. It doesn't always get created. I basically need to have an output from either the Modal or the Select view that I can pass to the command
i cant really help much as im not sure, how its done, why its done or how its abstracted
Basically I have a slash command, and I need to get the output from the different select options that it gives the user. But I don't know how to access those options from the classes they're in.
so each option has its own class with something like a modal i suppose?
So when the command is used, a view gets sent with a bunch of options to pick a course. I want to be able to access that course variable and use it as a variable in the command.
Here is the command
@mk_commands.command(name="upload", description="Upload your fastest time for each course.")
async def upload(self, interaction: discord.Interaction):
await interaction.response.send_message("Which **cup** is your course in?", view=MarioKart.CourseView())
And here is the select menu that gets sent when the command is used
class CourseSelector(discord.ui.Select):
def __init__(self, course_options):
self.course_options = course_options
super().__init__(placeholder="Which **course** is the time for?", min_values=1, max_values=1, options=self.course_options)
async def callback(self, interaction: discord.Interaction):
course = self.values[0]
And youre trying to access which value?
If I wanted to take the course variable in the bottom line and add it as the next line in the command, how would I do that?
well you can always set it as a instance variable or just use the literal value
here's a basic example of taking a value from the view
Its just instance variables?
yeah
Okay, so if I place the variable in the view, how would I update it from the Select Menu class?
class CourseView(discord.ui.View):
def __init__(self, options):
self.options = options
self.course = None
super().__init__()
self.add_item(MarioKart.CourseSelector(options))
class CourseSelector(discord.ui.Select):
def __init__(self, course_options):
self.course_options = course_options
super().__init__(placeholder="Which **course** is the time for?", min_values=1, max_values=1, options=self.course_options)
async def callback(self, interaction: discord.Interaction):
course = self.values[0]
youd save your instance of CourseSelector as an instance variable
so you can access CourseSelector.value
!e
from dataclasses import dataclass
@dataclass
class Foo:
bar: str
def monty() -> None:
foo = Foo("bar")
return foo.bar
print(monty())
@primal token :white_check_mark: Your 3.11 eval job has completed with return code 0.
bar
@abstract kindle ^
class CourseView(discord.ui.View):
def __init__(self, options):
self.course = None
super().__init__()
view = MarioKart.CourseSelector(options)
self.add_item(view)
So this instead?
I made it as easiest to understand so it should be understandable to anyone
since you declare an instance in the function and want to use a variable thats value is declared inside of it you would access the variable from the instance, no?
Actually, in the example @upbeat gust sent, he handles the outcomes of the view in the command. I've been handling them in the classes of the Select Menus themselves as callbacks
Yeah but the example is quite horrible for its usage, over using something like callbacks but it all depends on abstractions which in the example given its not needed in this case since you want to use a variable thats value is declared inside of the instance you would use instance variables as told
Where do I create the instance?
You declared one and sent it, no?
view=MarioKart.CourseView()
you would just use a variable and declare the instance for later references
Let me try something
It's getting out of hand. I'm having to track the variable I want over several classes. I send this view after the command is used:
class CupView(discord.ui.View):
def __init__(self):
super().__init__()
view = MarioKart.CupSelector()
self.cup = view.cup
self.add_item(view)
Then, to get THIS classes self.cup I have to have the CupSelector() be sent and then the user will give a response, and then I need to backtrack that response all the way to the command
class CupSelector(discord.ui.Select):
def __init__(self):
options = [
"""options here"""
]
self.cup = None
super().__init__(placeholder='Choose the cup', min_values=1, max_values=1, options=options)
async def callback(self, interaction: discord.Interaction):
self.cup = self.values[0]
``` here is the selector
How can I make this work? (The expected result is the bot sending the message that was defined into the function)
def checkUser(message,user2check):
if user2check.id in registered_users:
await message.channel.send("Sorry, you are not registered in the database!")
@client.event
async def on_message(msg):
if msg.content.startswith('?check'):
checkUser(msg,msg.author)
I would use a command instead of an event for that. It will get hard to track if you run your commands based on message events
Wdym 'hard to track'?
Like all your 'commands' would have to be under async def on_message(msg): if you keep doing it that way
I got used to making my commands that way
And they just work so to me is okay that way
I would avoid that if you want to continue developing
@client.command(name="Check")
async def check(ctx):
# code here
That's a proper command I think. Also I would use bot instead of client
What's wrong with client? I've been using that for about 2 years now and had no problems
Theres no issue, its just variable naming? Its just not suggested as its not accurate, its like doing
apple = Banana()
@Arcade.command(name = 'Test', description = 'Testing', guild = discord.Object(id = 1009249121590312980))
async def self(ctx) -> None:
await ctx.send('hi')
``` Why doesn't a slash command show
You seem to be using a normal command (text based).
How can I change it?
So I have to make a class instance of the bot?
Other people said that this method was frowned upon
I'll do it.
Most people subclass it, if that's what you're referring to. Its the most elegant way of adding custom attributes and methods, and allows you to override built-in methods like get_context and setup_hook. If you don't need those features, you could simply use client = discord.Client(...)
how to make so that when ONLY a moderator clicks a button, a response comes?
❤️
You have a few ways of doing this, a whitelist of IDs, check permissions, check roles, etc.
but the button is in a class
yup
The button callback exposes interaction which is all the data you need
OH
IM SUCH AN IDIOT
@quaint scaffold a guild is my serverId, right?
?
def __init__(self, ctx):
super().__init__(timeout=10)
self.ctx = ctx
``` this and
```py
async def interaction_check(self, interaction) -> bool:
if interaction.user != self.ctx.author:
await interaction.response.send_message("bro, as the Green Goblin says, To each his own. If you want to have a look, type ?help!", ephemeral= True)
return False
else:
return True
```right?
Guilds are just what a normal user calls a server, this prevents confusion between a proper server and a Discord server
so.... if I right click my server, and click Copy Id, that is it's guild id?
I'm sorry if im no tunderstanding correctly
Sure
thank u
Fyi that else is redundant
Correct
Okay.
I'm getting this error: 'int' object has no attribute 'id'
async def setup_hook(self) -> None:
self.tree.copy_global_to(guild = 1009249121590312980)
await self.tree.sync(guild = 1009249121590312980)
Not sure what is wrong
Full traceback please
!d discord.Client.latency
property latency```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
Sure but what would that achieve
hey guys
im coding a very basic bot but for some reason it doesnt seem to work
import discord
import discord.guild
from discord.ext import commands, tasks
client = commands.Bot(command_prefix='&')
@client.command('reset')
@commands.has_permissions(change_nickname=True)
async def reset(ctx):
for member in ctx.guild.members:
await member.edit(nick=None)
client.run('token')
its supposed to change the nickname of everyone in the server to nothing
i'll be grateful 4 ur help
!or
When checking if something is equal to one thing or another, you might think that this is possible:
# Incorrect...
if favorite_fruit == 'grapefruit' or 'lemon':
print("That's a weird favorite fruit to have.")
While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.
So, if you want to check if something is equal to one thing or another, there are two common ways:
# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
print("That's a weird favorite fruit to have.")
# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
print("That's a weird favorite fruit to have.")
what are you trying to do?
!d random.choice
random.choice(seq)```
Return a random element from the non-empty sequence *seq*. If *seq* is empty, raises [`IndexError`](https://docs.python.org/3/library/exceptions.html#IndexError "IndexError").
yes?
i dont understand why theyre f strings tho, its unnecessary as the string is static
what is this error?
ur bot probably has been rate limited. u can read more abt it here: https://discord.com/developers/docs/topics/rate-limits#rate-limits
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Are AppCommandGroup a way to add options to a slash command
Basically, here's some examples: https://gist.github.com/AbstractUmbra/a9c188797ae194e592efe05fa129c57f
discord.py 2.0a slash command info and examples. GitHub Gist: instantly share code, notes, and snippets.
second message in the pins has an explanation on groups
Ohh, ashley made a thing
given the user id of someone, how do i get their corresponding member obj?
!d discord.Guild.get_member
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
there are other ways too, this is the most common one
btw is user id when you do this?
this is the id as the bot sees it, but the id is only the integer part of it
ah
when you mention something the bot will see <@<digits>> or <#<digits>> based if it is a user or a channel/other discord object
Thanks!
?
.
get_member(user_id, /)```
Returns a member with the given ID.
Changed in version 2.0: `user_id` parameter is now positional-only.
how is this noneType
member_obj = server.get_member(690708403504414730)
yes ive defined server lol
what is server
@bot.listen()
async def on_message(payload):
global server, member, callnresponse, reactionnrole
channel, server, author, member, message, ID = h.get_msg_info(payload)```
Wtf
bruh 
!d discord.on_message
discord.on_message(message)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") is created and sent.
This requires [`Intents.messages`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.messages "discord.Intents.messages") to be enabled.
Warning
Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that [`Bot`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot "discord.ext.commands.Bot") does not have this problem.
def get_msg_info(payload):
return payload.channel, payload.guild, str(payload.author), payload.author, str(payload.content), int(payload.id)
Well, now i've saw everything 
No you haven't
One sec
!e py import base64;[print(chr(int(base64.urlsafe_b64decode(s+"="))>>69),end="") for s in 'NDYwNDMwNzMyMDc5NzkwNDA4MzM1MzY=NTk2MTk4NzY4NDYyMjkyNzA4MjI5MTI=Njk2NTQ5MDU2MjIzMjcyNjY5MDIwMTY=NTk2MTk4NzY4NDYyMjkyNzA4MjI5MTI=NjcyOTM3MjIzODA4OTI0NDQyOTUxNjg=MTg4ODk0NjU5MzE0Nzg1ODA4NTQ3ODQ=NjA4MDA0Njg0NjY5NDY2ODIxMjYzMzY=NjU1MjI4MzQ5NDk4MTYzMjczNDAwMzI=NjQ5MzI1MzkxMzk0NTc2MjE2ODgzMjA=NjQ5MzI1MzkxMzk0NTc2MjE2ODgzMjA=NTcyNTg2OTM2MDQ3OTQ0NDgyMTYwNjQ=MTg4ODk0NjU5MzE0Nzg1ODA4NTQ3ODQ=NjA4MDA0Njg0NjY5NDY2ODIxMjYzMzY=NjE5ODEwNjAwODc2NjQwOTM0Mjk3NjA=Njk2NTQ5MDU2MjIzMjcyNjY5MDIwMTY=NTk2MTk4NzY4NDYyMjkyNzA4MjI5MTI=MTg4ODk0NjU5MzE0Nzg1ODA4NTQ3ODQ=NzE0MjU3OTMwNTM0MDMzODM4NTcxNTI=NjU1MjI4MzQ5NDk4MTYzMjczNDAwMzI=NjkwNjQ2MDk4MTE5Njg1NjEyNTAzMDQ=MTg4ODk0NjU5MzE0Nzg1ODA4NTQ3ODQ=NjkwNjQ2MDk4MTE5Njg1NjEyNTAzMDQ=NjYxMTMxMzA3NjAxNzUwMzI5OTE3NDQ='.split("=") if len(s)>0]
@vale wing :white_check_mark: Your 3.11 eval job has completed with return code 0.
Never gonna give you up
lmao please bruh the company which i work for sends requests in base64 
What the fuck
Alert, #esoteric-python has overflowed again... Rebooting brain
Hunter funny af
How to check a txt file for a message and add that message if not there in asyncio
what do you mean in asyncio
asyncio....?
And is this related to discord bots
It is not related to discord bots btw as you normally do with a normal file except that you open it asynchronous:
async with open "file.txt": #yourstuff
gonna error out
well nvm lmao
import aiofiles
async with aiofiles.open(...) as f:
await f.read()
in an async context ofc
and inside an async function*
when i print out type() of the server variable it says<class discord.guild.Guild> but when i print out thetype of the server.get_member([id]) it gives me back <class NoneType>
get_member is returning None because the method accepts an integer
i have the integer
member_obj = server.get_member(690708403504414730)
it still not working
can we make an async + operator
pip install discord==1.3.7
Use replit shell, but it's temporary
what you mean
When u installed modules from replit shell, it will gone after a moment
Do u mean 1.7.3?
That seems about right lol
🐵
Because you are using replit
Because replit is awful
Well idk
Do u know how to use poetry?
SO SHOULD I CODE IN GITHUB?
What
Nvm
i hate dpy 2.0
dont use replit its so bad since you get api banned for a long itme
basically your bots constantly shut down after a while and come back later
code in Visual Studio Code, i find it good
code in github, but why
Poetry in vsc is inconvenient imho, it's a lot easier to use in pycharm
vsc stores your libraries in your pc
you can use command prompt and it will also load into vsc your libraries
not replit cause its cloud
Replit is cringe generally
yes
Guys py sleep(1) is blocking my code there are any other thing i can use to make same thing that sleep make
asyncio.sleep
that's if you're talking about async apps
Oh Yes i use async in my commands
Thank You! so how it work asyncio.sleep(1)?
Sorry But @rugged shadow
soooo sorrrrrrrrrrrrrry
await asyncio.sleep(1)
await asyncio.sleep(1) yes
it's ok lol, no need to say sorry
🙂 ok thank you guys!
GUYS WHAT IN THE WORLD???
I WAS TRY FIX SOMETHING IN MY CODE FOr 3 DAYS
AND I JUST CHANGE FROm sleep to await asyncio.sleep(1) AND IT WORK?
WHAT THE HECK lol
lol thank you again
because time.sleep is a blocking function but asyncio.sleep is asynchronous time.sleep
AAa
lol
It blocks the thread in which it is called
the error is clear, no?
No. I haven't coded in 5-6 months
Comeon. Help me. I've only got 1 command
Wanna get it over with
What? How?
What happen?
Thank You
Eyes
👀
What's wrong here?
why give riddles 🗿
if you get an error send it
if you do not say what goes wrong
c from different lang?
Excuse me?
idk? it says invalid syntax, so your smth is wrong with your async
try just rewriting it
Look at the lines above and below, they may be causing the syntax error
I don't see any pyflakes or anything
async
did u save ur code
what python version are you using?
All good.
Yes, I have auto save enabled.
I'm using sqlite3 to store names in a database, when I call them how can I call just the name, not the [('',)] around the variable
Are there methods discord.Client.logs_from and discord.Client.delete_messages ?
@commands.command()
async def name(self, ctx, name: discord.Member):
id = name.id
eq.execute("""SELECT name FROM names WHERE user = ?;""", (id,))
await ctx.send(eq.fetchall())```That's the code
I was doing python main.py (2.7) instead of python3 main.py (3.10).
Thanks everyone
Index eq.fetchall()
You're going to want to use an async driver for your db operations. But considering you only need one value, you could use fetchone() and then index it
I'm trying to delete multiple messages in a channel using bot command
What's the benefit to using an async driver for my db operations?
@Client.command(pass_context = True)
async def clear(ctx, number):
mgs = [] #Empty list to put all the messages in the log
number = int(number) #Converting the amount of messages to delete to an integer
async for x in Client.logs_from(ctx.message.channel, limit = number):
mgs.append(x)
await Client.delete_messages(mgs)
So it doesn't block the event loop and interfere with discord.py
Or do it the easier way? py @commands.command(aliases=['clear']) @commands.has_permissions(administrator=True) async def purge(self, ctx, ammount: int): await ctx.message.delete() await ctx.channel.purge(limit=ammount) await ctx.send(f"{ammount} messages cleared by {ctx.author.mention}")
I'm trying to use it in SlashClient class subinstance from discord.Client:
class SlashClient(discord.Client):
def __init__(self) -> None:
super().__init__(command_prefix="/", intents=intents)
self.tree = discord.app_commands.CommandTree(self)
async def setup_hook(self) -> None:
self.tree.copy_global_to(guild=discord.Object(id=someInt))
await self.tree.sync(guild=discord.Object(id=someInt))
Alright, thanks.
Considering the bot is async, you can end up blocking. This is highly unlikely to be an issue for something like a db query, but still, use async!
Ok.
I'm using discord.Interaction
interaction.channel?
exists ?
Don't delete messages individually, it counts as one request each time to the API, thus it'll count towards your global ratelimit
How do I fix an ssl error? I get it when I try to start my bot
That's most likely a poor network connection
Thanks
How would I index eq.fetchall() though, wouldn't it just return the position of it in the list?
it's not 'Interaction' object has no attribute 'chennel'
@quaint scaffold
ah sorry
it's channel not chennel
what discord.errors.NotFound: 404 Not Found (error code: 10062): Unknown interaction
This is the first time i see this error
at await interaction.response.send_message(embed=em)
i think because purging the channel messages
thanks
So how do I index this?
Which pops out another question, how can i send a message without discord.interaction ?
!resources You're getting far ahead of yourself making Discord bots if you don't know the basics of Python, I'd heavily recommend learning them first.
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
class abot(discord.Client):
def __init__(self):
super().__init__(intents=discord.Intents.default())
self.synced = False
async def on_ready(self):
await tree.sync(guild=discord.Object(id=886817641262637066))
self.synced = True
print("Bot is Online")
bot = abot()
tree = app_commands.CommandTree(bot)
# # # # # # # # # # # # # # # # # # # # # # # #
## Quote Command
@tree.command(name="quote", description="quotes an individual", guild = discord.Object(id=886817641262637066))
async def self(interaction: discord.Interaction, Here: str):
embed = discord.Embed(color = random.choice(colors))
embed.set_thumbnail(url="https://previews.123rf.com/images/enterline/enterline1612/enterline161200209/66655445-the-word-quotes-concept-and-theme-painted-in-watercolor-ink-on-a-white-paper-.jpg")
embed.add_field(name="**Quote: **", value=f"{Here}")
embed.timestamp = datetime.datetime.utcnow()
embed.set_author(name="Wallahi", icon_url="https://cdn.discordapp.com/icons/683171677185638542/279c659415dab4390087c91f7bc0a753.webp?size=160")
await interaction.response.send_message(embed=embed)
# # # # # # # # # # # # # # # # # # # # # # # #
bot.run(os.getenv('TOKEN'))
# # # # # # # # # # # # # # # # # # # # # # # #
me ?
How about you just tell me the syntax of index() so I can learn
Or send me the docs
Anyone?
I'm not good at discord.py but isn't function on_ready requires @self.event ?
I would rather not, its not even index() but has its own syntax.
Not for this. No
You haven't even asked a question, just posted code?
I sent the error
Then send me the docs if you're going to be unhelpful
And actually it is.
I think channel.send will do the trick thanks
I'm very confident that you don't index a list using index(); well you could, but its not very practical
So you're wrong.
There is no need to be rude.
How is that being rude?
He is not helping me, he hasn't even sent the docs I have asked for.
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
All he is doing is belittling me for not knowing one fucking method.
Its probably on the first few chapters of whichever guide you choose
Can you help?
Indexing is kinda a need to know if you're at the point of Discord bot coding.
Why would I belittle you over something so trivial? Everyone needs to start somewhere, and an asynchronous Discord bot is not that.
I've never needed it for any projects, that's why I don't know indexing
All I wanted is the docs, idk where to find it on that recourses link you sent.
!e py my_list = list(range(20)) print(my_list[4])
@quaint scaffold :white_check_mark: Your 3.11 eval job has completed with return code 0.
4
Oh that?
I know how to do that
But you don't need to index a fetchone.
Doesn't it return a tuple? I haven't used sqlite in ages
class abot(discord.Client):
def __init__(self):
super().__init__(intents=discord.Intents.default())
self.synced = False
async def on_ready(self):
await tree.sync(guild=discord.Object(id=886817641262637066))
self.synced = True
print("Bot is Online")
bot = abot()
tree = app_commands.CommandTree(bot)
# # # # # # # # # # # # # # # # # # # # # # # #
## Quote Command
@tree.command(name="quote", description="quotes an individual", guild = discord.Object(id=886817641262637066))
async def self(interaction: discord.Interaction, Here: str):
embed = discord.Embed(color = random.choice(colors))
embed.set_thumbnail(url="https://previews.123rf.com/images/enterline/enterline1612/enterline161200209/66655445-the-word-quotes-concept-and-theme-painted-in-watercolor-ink-on-a-white-paper-.jpg")
embed.add_field(name="**Quote: **", value=f"{Here}")
embed.timestamp = datetime.datetime.utcnow()
embed.set_author(name="Wallahi", icon_url="https://cdn.discordapp.com/icons/683171677185638542/279c659415dab4390087c91f7bc0a753.webp?size=160")
await interaction.response.send_message(embed=embed)
# # # # # # # # # # # # # # # # # # # # # # # #
bot.run(os.getenv('TOKEN'))
# # # # # # # # # # # # # # # # # # # # # # # #
The Error
tbf it depends on the driver
dont make command name self
ty
You haven't provided any info.
Any error? Did you debug it? If so where does it get stuck?
Still have the same error
prob error with here
Oh it says error in here
maybe change here to lower case
if lower case does not change it maybe change it to text
What join message?
Usually i dont have error with this but why cant i access the content of the message
this works perfectly in my otherbot
all my intents are enabled
The send message?
Also in the dev portal?
ye
You got intents .all on?
yep
Afaik you can't delete ephemeral messages.
ephemeral are deleted by user
when you click dismiss below
i dont think you can manually delete those types of messages in code
O are you talking about removing WElcome from aiosqlite table
Well if you are using aiosqlite then you need to commit on execute.
ok im assuming this is bug since everything is fine in code
problem is when i do print(message.content) it returns None
therefore meaning intents is not enabled but it is :/
is there an error message?
so i dont understrand what is not working?
is it not deleting it
also if i may ask why are you saving a welcome message
put commit also beneath saving
in aioqsqlite when you are inserting / removing data you have to commit it
?
why are you using %s
wait it might be a different option but idk
i use question marsk
O your not using aiosqlite?
i feel like this is a data base issue and i dont have any experience with aiomysql
so prob ask in #databases
o
wdym
like on_message_id
edit i mean
No
no
you can use the bot.listen decorator and have as many as you want
bot.event decorator will overwrite the bot's internal on_message event. So you can't have multiple of those
aiomysql 💀
That async driver hasn't updated in like what? A good solid 3 years now?
how can i get message content intents for my discord bot ?
i have to wait till 25 oct ?
yes
then what about now ?
use slash commands
discord.py have slash commands ?
yup
i used @bot.commands for making all commands
my bot has 100 commands
ig if i want to migrate to slash commands then i will need to convert all those commands to slash commands ?
migrating to slash commands is hard and will take time 😕
!d discord.Interaction
class discord.Interaction```
Represents a Discord interaction.
An interaction happens when a user does an action that needs to be notified. Current examples are slash commands and components.
New in version 2.0.
!d discord.app_commands.AppCommand
class discord.app_commands.AppCommand```
Represents an application command.
In common parlance this is referred to as a “Slash Command” or a “Context Menu Command”.
New in version 2.0...
you can use bot's mention as a prefix (but that doesn't look nice)
you can make hybrid_commands (both message and slash commands), it's way easier to switch to
oh yes ^^
What does discord.Interaction contain?
it's listed in docs
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
yes i am currently using it
yes
yep, for dpy it's !d discord.Interaction
!d discord.ui.button
@discord.ui.button(*, label=None, custom_id=None, disabled=False, style=<ButtonStyle.secondary: 2>, emoji=None, row=None)```
A decorator that attaches a button to a component.
The function being decorated should have three parameters, `self` representing the [`discord.ui.View`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.View "discord.ui.View"), the [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction") you receive and the [`discord.ui.Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") being pressed.
Note
Buttons with a URL cannot be created with this function. Consider creating a [`Button`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.ui.Button "discord.ui.Button") manually instead. This is because buttons with a URL do not have a callback associated with them since Discord does not do any processing with it.
my bot will need to rejoin all the current servers to apply the changes/migration?
Thank you 🙂
nop
For slash commands?
# MY class:
class Bot(discord.Client):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self.tree = app_commands.CommandTree(self)
# Arcade = Bot()
@Arcade.tree.command()
async def apple(interaction: discord.Interaction):
# Code
self.tree = app_commands.CommandTree(self)
dpy creates a tree by default for you 🗿
:/
Damn
async def setup_hook(self):
# This copies the global commands over to your guild.
self.tree.copy_global_to(guild=MY_GUILD)
await self.tree.sync(guild=MY_GUILD)
Well you will need this part
yes
Not if the bot is a Client, which in his case he is using.
oh bruh
HEEHEEHAW
hybrid commands
Wut are those?
Client > Bot
slash commands + prefix commands
Abominations
ok ty
disanke is better
Ah
ig migrating from dc.py to disnake will take time 😓
no you just have to change @bot.command to @bot.slash_command with descriptions and it will be done /s
not too much if you are not using slash commands
import discord as disnake
🗿 🗿 🗿
and other stuff will remain same ? like await ctx.send/reply ?
-__-
they may work but not recommended
by the way, doesn't disnake use ctx.respond?
Pretty efficient if you ask me.
true
response.send_message()
haha dpy has same
but in dpy with hybrid commands u dont have to do that
it will just be ctx.send or ctx.reply
seriously it will take time to change code of 100+ commands that's why i am asking fastest way to migrate
It would take less time to migrate from dpy to disnake on slash commands rather than updating to dpy's slash command
ohk
-__-
app_commands not found
but it will take much less time to switch to dpy's hybrid commands
did you update?
they just literally change nothing except the name
💀I always forget about them
no just update dpy
"just"
:/
it's already been half a month since a release happened
not just ?
!pip discord.py
i read it this week
oh im stupid
i thought it was august 18
but it is august 28
then it's just a week...
does ```py
bob = interaction.response.send_message('Apple')
not return the message instance?
!d discord.InteractionResponse.send_message
await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Responds to this interaction by sending a message.
So it doesnt return anything?
yep
what do you need it for?
I'm making a snake game on discord, and I am setting their message in a dictionary, so their id = message
hmmm
I did it last time with ctx
im using hybrid commands so ctx.send returns a message object
idk about app comands one
nop
Damn
app commands give interaction
Okay
however you can make an interaction-based ctx from it
i think that can be a solution btw
!d discord.ext.commands.Context.from_interaction @slate swan
classmethod await from_interaction(interaction, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Creates a context from a [`discord.Interaction`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction "discord.Interaction"). This only works on application command based interactions, such as slash commands or context menus.
On slash command based interactions this creates a synthetic [`Message`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Message "discord.Message") that points to an ephemeral message that the command invoker has executed. This means that [`Context.author`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.author "discord.ext.commands.Context.author") returns the member that invoked the command.
In a message context menu based interaction, the [`Context.message`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.message "discord.ext.commands.Context.message") attribute is the message that the command is being executed on. This means that [`Context.author`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.author "discord.ext.commands.Context.author") returns the author of the message being targetted. To get the member that invoked the command then [`discord.Interaction.user`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.Interaction.user "discord.Interaction.user") should be used instead.
New in version 2.0.
is there any gist about dpy's localization?
can you give me an example
wdym localization?
translations
@bot.tree.app_command()
async def my_cool_command(interaction):
ctx = await commands.Context.from_interaction(interaction)
my_msg = await ctx.send(...)
...```
localization in disnake is a bit ugly
idk what u talking about
there's examples
ok it's not really an example but you could look at https://github.com/DisnakeDev/disnake/tree/master/test_bot
thanks sir 🙂
I know this one, I want to know about dpy's
idk if dpy's have something as example
they don't mention where are locales stored
!d discord.Locale
class discord.Locale```
Supported locales by Discord. Mainly used for application command localisation.
New in version 2.0.
@silk fulcrum do you know abou threading
in channels?
like
threading.Thread(target=blah)
Does it automatically destroy the thread when its done?
!d threading
Source code: Lib/threading.py
This module constructs higher-level threading interfaces on top of the lower level _thread module.
Changed in version 3.7: This module used to be optional, it is now always available.
interesting
idk, but I think that's not related to this channel neither
why discord.utils
because rn im using user.add_roles(discord.Object(id=1016072383502745701))
and i was told i should use utils
instead of object
was told by who?
@Arcade.tree.command()
async def snake(interaction: discord.Interaction) -> None:
TypeError: Interaction client is not derived from commands.Bot or commands.AutoShardedBot
ctx = await commands.Context.from_interaction(interaction)
game = games.get(interaction.user.id, None)
if game is None:
games[interaction.user.id] = message = await ctx.send('test snake')
else:
message = await ctx.send('close')
threading.Thread(target = deleteMessage, args=(message, 5)).run()
Why isnt this working?
someone called unseenyou
because Object is absolutely possible and I don't see any problem with that
full traceback pls
Okay
raceback (most recent call last):
File "C:\Users\toplo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\app_commands\tree.py", line 1240, in _call
await command._invoke_with_namespace(interaction, namespace)
File "C:\Users\toplo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\app_commands\commands.py", line 876, in _invoke_with_namespace
return await self._do_call(interaction, transformed_values)
File "C:\Users\toplo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\discord\app_commands\commands.py", line 865, in _do_call
raise CommandInvokeError(self, e) from e
discord.app_commands.errors.CommandInvokeError: Command 'snake' raised an exception: TypeError: Interaction client is not derived from commands.Bot or commands.AutoShardedBot
@silk fulcrum
is it the ctx thing
but that's optional
ill stick with it then
but that code is actually pain
ctx = await commands.Context.from_interaction(interaction)
I think its this
how do you define your bot
I saw it was a subclass
can u send it
@silk fulcrum ```py
class Bot(discord.Client):
def init(self, *args, **kwargs) -> None:
super().init(*args, **kwargs)
self.tree = app_commands.CommandTree(self)
async def setup_hook(self) -> None:
self.tree.copy_global_to(guild = discord.Object(id = 1009249121590312980))
await self.tree.sync(guild = discord.Object(id = 1009249121590312980))
Arcade = Bot(intents = discord.Intents.all())
i guess that is cus it's a Client
yes it is
only commands.Bot can do from_interaction
is this related with hybrid commands
not discord.Client
Wait so what do I do?
i think so
switch to commands.Bot instead of discord.Client
but this is tricky for me
Ok lets see now
because when i started making my bot i was new to oop
discord.errors.ClientException: This client already has an associated command tree.
me at 10 yrs: what is OOP? yeah im making a discord bot yep
self.tree = app_commands.CommandTree(self)
``` do I remove this part?
yesh
async def setup_hook(self) -> None:
self.tree.copy_global_to(guild = discord.Object(id = 1009249121590312980))
await self.tree.sync(guild = discord.Object(id = 1009249121590312980))
``` Do i remove these? we didnt define tree unless i inherit it
what is this :/
!d discord.app_commands.CommandTree
class discord.app_commands.CommandTree(client, *, fallback_to_global=True)```
Represents a container that holds application command information.
yes
So confused
so I don't remove it?
Also just making sure, ```py
ctx = await commands.Context.from_interaction(interaction)
This is correct?
yes?
alr
im new to making discord bots, so im sorr.y
Okay it works, PROBLEM IS
threading.Thread(target = deleteMessage, args=(message, 5)).run()
ok wait
wat
yea, if u do time.sleep() it'll pause it for 5 seconds, right?
why not just use delete_after bruhhhh
YOU CAN DO THAT?
you can
master
@silk fulcrum it doesn't have the attribute, delete_after ```py
await message.delete_after(5)
can i pass multiple guild ids here and here
It's a kwarg in the send method
await message.send("hi", delete_after=5)
OH MY GOD, IM SO DUMB, UR SO SMART, and I wanna eat your poptart
message.send 🗿
i forgot those
for add_cog() you just add more guilds to the list, for sync() you need a for loop to sync each guild you want
i started using discord.py again only for migrating
It works, now I will be the best programmer in the world. You are all noobs, my plan for world domination is working
-_-
😦 Ok maybe not
glhf
You plan to dominate the world.. through a discord bot?
cheers bub
I will add as many waifu images I can. it will spam every channel with waifus
@slate swan what theme is that
async def add(ctx,member : discord.Member,*,reason) -> None :
is this code RIGHT ?
Biibebaabelikiikelikaakeli
hi is there anyone who knows something abouth python bots and can help me out
what help is you need
That’s what we’re here for
pip install yaml?
open cmd
ye
and type pip install yaml
pip install pyyaml
done sir
Try to start the bot now
np
?
i mean i download files to bot from web now i dont know why the files dont running with bot
Can you send source?
uh wait, so I'm confused rn
So, you want to download some files from google and send it with the bot?
Like with a command or
i mean i want to bot use this files
in this files i got casino source
i dont know how to get it work
i can give you files on pv
if u want to
Yea, lets do that
AttributeError: 'Intents' object has no attribute 'message_content'
how can i join a channel voice channel in which the author of command is in discord.py?
what to do !
quick questions can modals have drop down lists
which version of discord.py are you using?
self.callback is a method, why are you trying to subscript it?
Can someone send docs or a video on discord py buttons?
This is the Ultimate Python Guide on Buttons with Discord.py or Pycord. In this video, I talk about how to create buttons in discord.py or pycord and how to respond to button clicks along with everything about Views. After watching this you'll know everything about Buttons and Views in discord.py or pycord.
This video might also apply to other...
assuming that's mysql you could reuse your msg value in the conflicting key by using VALUES(msg) rather than passing your value twice
https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html
do you have a script named discord.py?
Yes
Rename it
^ that script name shadows (i.e. uses the same name as) the discord.py package
It’s thinking you want to import that file
the dpy github also shows various examples of buttons being used https://github.com/Rapptz/discord.py/tree/master/examples/views
docs: https://discordpy.readthedocs.io/en/stable/interactions/api.html#bot-ui-kit
you need 2.0 for buttons
i have to wonder why this tutorial shows setting button.callback before presenting the intended approaches of subclassing View/Button
if i wanted to look at a bot that's really well structured and written what open source ones would you recommend
I wonder if that’s why I see a lot of people preferring that method
Our @unkempt canyon bot
okay
I haven’t seen any other discord bots that have been laid out and planned that well
Very structured
Also, extensible and readable
!src
There’s the GitHub
thanks
see the example shown in the docs i linked: sql INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6) ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b); VALUES would remove your need for that self.callback[0].value parameter you're trying to pass to msg=%s;
wdym whats the right one
start with how its not working
Ryuga:
self.callbackis a method, why are you trying to subscript it?
self.callback[0]is incorrect since callback is a method, hence why you got the error'method' object is not subscriptable
you could either fix it by repeating what you wrote for your msg parameter, which is self.children[0].value, or by using mysql's features to avoid repeating the same parameter
discord.ext.commands.errors.HybridCommandError: Hybrid command raised an error: Command 'avatar' raised an exception: AttributeError: 'Member' object has no attribute 'avatar_url'
ok this also changed with the new discord.py release ?
avatar.url
@bot.listen('on_message')
async def on_message(message):
for line in gg:
if line in message.content:
await message.delete()
await message.channel.send("dont curse")
break
``` bot not deleting any messages and no error
display_avatar is better
you need to call self.callback bro
Lemme show u what u r doing
!e
def func():
return 1, 2
print(func[0])
@maiden fable :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | TypeError: 'function' object is not subscriptable
from discord import app_command
ImportError: cannot import name 'app_command' from 'discord' (/app/.heroku/python/lib/python3.10/site-packages/discord/__init__.py)
how to fix this?
you have to upgrade discord.py
Is that on Heroku or on your local machine?
heroku
Perhaps your project is using a different version than the global, maybe a venv?
how to repair it
app_commands is the name of the sub package, you however wrote it as app_command
Can you send the full error instead of an ss please
oops
also that requirements is weirdly written

