#discord-bots
1 messages · Page 634 of 1
it doesnt work
the button either doesnt shot, or it shows like ((function etc...
show*
Do view=self
ight
so basically
the message
that was sent by clicking on a button
to have a button too
O
but the second time its going to send an embed
Whats the code to add buttons on the bots status. I forgot lol
!d discord.Interaction.original_message
await original_message()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Fetches the original interaction response message associated with the interaction.
If the interaction response was [`InteractionResponse.send_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.InteractionResponse.send_message "discord.InteractionResponse.send_message") then this would return the message that was sent using that response. Otherwise, this would return the message that triggered the interaction.
Repeated calls to this will return a cached value.
You can't, discord limitations
so can you help me or not
Well, sorry bruv. I never used nextcord
class PersistentViewBot(slash_util.Bot):
def __init__(self):
super().__init__(command_prefix=commands.when_mentioned_or('.'), owner_id=503641822141349888, intents=intents)
self.persistent_views_added = False
async def on_ready(self):
if not self.persistent_views_added:
self.add_view(PersistentView())
self.persistent_views_added = True
activity = discord.Game(name="fc.coolmcgames.xyz", type=3)
await self.change_presence(status=discord.Status.online,
activity=activity)
print(f'Signed in as {self.user}')
bot = PersistentViewBot()
class SlashCog(slash_util.ApplicationCog):
def __init__(self, bot):
super().__init__(bot)
self.bot = bot
@slash_util.slash_command(guild_id=774501063557382155)
async def hello(self, ctx):
await ctx.send('hi')
bot.add_cog(SlashCog(bot))``` Anyone know why the slash command doesn't appear?
Traceback (most recent call last):
File "C:\Users\Windows\AppData\Local\Programs\Python\Python39\lib\site-packages\nextcord\ui\view.py", line 359, in _scheduled_task
await item.callback(interaction)
File "c:\Users\Windows\OneDrive\Desktop\Bot\cogs\mainhelp.py", line 35, in helpb
view = Sbdrugs()
TypeError: Sbdrugs() missing 1 required positional argument: 'ctx'
its the forked version of discord.py
basically the same tbh
There is no code.
You go to the dev portal and add it.
You have to go to discord dev portal, oauth and general
@maiden fable
oAuth
and where after
Well different forks have edited those things, do I don't really know, sorry
OAuth2
its alright
General
Yea
where do I press
None
is there any way the bot can somehow save the transcript of the dms and send it? or is that not possible?
At the bottom
custom url?
Nope, the other one
!d discord.DMChannel.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
in app authorization?
set it to the in app auth so that people can invite the bot without leaving discord
Yea
they can do this in dms with someone?
The bot needs a DMChannel object for doing this
ahh, might be a little lost here lol, let me still give it a try thanks brother
!d discord.User.dm_channel
property dm_channel: Optional[DMChannel]```
Returns the channel associated with this user if it exists.
If this returns `None`, you can create a DM channel by calling the [`create_dm()`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.create_dm "discord.User.create_dm") coroutine function.
So this
umhmm
so how does this work? Does it send back a transcript of the conversation it had w the person?
U can do,
async for msg in user.dm_channel.history(...):
print(msg)
Now it's a for loop and the list it's looping is the list of messages in the DM
oh, so the entire thing will have to go in the for loop?
Wym
I'll show you my code
I edited the above code, @slate swan try running that once. It will print every messages in that channel
pretty long lol
in short, its basically a help bot that dms you if your message anywhere includes 'help' or 'staff'
like automated bestbuy or amazon customer service bot
@maiden fable im still typing the elif statements if the user replies with 'yes'
bump hehe
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
im sorry, let me do that
no problem
Can someone tell me how i can possibly get the transcript of the dms the bot has with people?
?rtfm channel.history
!d discord.User.dm_channel
property dm_channel: Optional[DMChannel]```
Returns the channel associated with this user if it exists.
If this returns `None`, you can create a DM channel by calling the [`create_dm()`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.create_dm "discord.User.create_dm") coroutine function.
wouldn't this just give the bot's messages?
or would it give both bot and the user in the dms?
both
perfect, I'll read it thanks
just remove this check ya? if message.author == client.user:
get rid of it?
Is it possible to get the banner of the user??
Eyyo help me
if ctx.reference is not None:
print()
When someone replied to anyone's msgs it prints but I only want someone to reply to my bot,then it will print
Depends on what library ur using. If ur still using discord.py u can’t get it
U have to use a fork that has implemented it
Name one
I haven't
Oh
A lot ppl are using pycord now
Wow what a cool name
Does it have that feature
And pycord still have bugs in their Slash branch
I am using disnake rn
Yes. discord.Member.banner
And double check disnake docs, they might have it
Yeah I will
And they lived happily ever after.
if ctx.reference is not None:
print()
When someone replied to anyone's msgs it prints but I only want someone to reply to my bot,then it will print
How do I do it?
thats so cool
Would the if statements inside the yes if statement work?
why is :
not working?
what's the dm variable?
alright
uh why?
bot = commands.Bot(command_prefix = ';')
from discord.ext import commands
@bot.command()
async def clear(ctx, amount):
await ctx.channel.purge(limit=int(amount)+1)
Can anybody tell me if somethinge's wrong with this code cuz my bot aint deleting a message..
did you Add a Bot from the bot option?
lucas code hm , did you run the bot?
yes
it aint deleting the message idk why
not that , go to the bot section and click add bot
any errors?
if you have any error handler for the command try commenting out that and try the command again
import discord
import random
from keep_alive import keep_alive
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
mention = f'<@!{client.user.id}>'
if mention in message.content:
await message.channel.send("Hey There! I am made by BeeJar. If you need support please contact BeeJar")
bot = commands.Bot(command_prefix = ';')
from discord.ext import commands
@bot.command()
async def clear(ctx, amount):
await ctx.channel.purge(limit=int(amount)+1)
keep_alive()
client.run(TOKEN)
then check the console
ok
add await bot.process_commands(message) at the end of your on_message event
thanks fixed it!
ok thx
await bot.process_commands(message)
how to make a discord bot 24/7 ?
host it on a vps or webserver
you run the script 24/7
or selfhost it yourself
from where did you copy this horrible code
how? I made it on replit
im new to this ... this is my first time making a bot so i saw a yt video
yt tutorials are horrible
https://vcokltfre.dev/
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.
try using uptime robot
follow this tutorial
ok thx m8
ok.
looks like a mix of lucas and codecamp lol
and you dont run the bot variable , which means the command does not get added
so should I use client cuz my other ping fuction was not working while using client?
remove the client = discord.Client
move your on_message event below bot=.....
and replace client.event with bot.event
and at last , replace client.run with bot.run
okk
freecodecamp and lucas and any other yt tutorials are extremely horrible or outdated
it's better if you don't follow them
especially ones using .Client 😶
hey @slate swan

counter = 0
async for message in dm.history():
if message.author == client.user:
counter += 1
messages = await dm.history().flatten()
#send history in channel?
Im a little confused by the docs tbh lol
i tried to understand but there wasn't enough info
And there isn't enough info on the internet either surprisingly
what do you want to do exactly?
and what is the error?
Can anyone tell me the docs?
I haven't even tried yet, I'm still trying to understand how this works
So does this make a for loop and goes through every message?
not sure about discord, i know about nextcord, see if this will be helpful:
https://github.com/nextcord/nextcord/tree/master/examples/views
have a look at dropdown.py
A maintained fork of Danny's discord.py. Contribute to nextcord/nextcord development by creating an account on GitHub.
Tq
why not try it and find out?
lemme try

if ctx.reference is not None:
print()
When someone replied to anyone's msgs it prints but I only want someone to reply to my bot,then it will print
How do I do it?
why is this 😭
That doesn't make any sense? "When someone replied to anyone's msgs it prints but I only want someone to reply to my bot,then it will print"
you check if the referenced message author is your bot
Like it must only print out if someone replies to the bot's msgs not someone's msgs
Oh ok
are you sure its passing the token?
try printing os.getenv(secret token)
nope
nope?
it didnt work
and hence you have your problem
wha-
try putting your token directly in bot.run
ahh, message.author == client.user basically makes the bot the author
got it
yes
i think i got it
how do i make my bot ping the user who interacted with a button?
or alteast show the user who interacted with it in a footer
yep
interaction.user
embed.set_author
im sorry i cant link to the documentation for it, i dont know how the rtfm works here
alr
!d discord.Embed.set_footer
set_footer(*, text=Embed.Empty, icon_url=Embed.Empty)```
Sets the footer for the embed content.
This function returns the class instance to allow for fluent-style chaining.
set_author*
?
!d discord.Embed.set_author
set_author(*, name, url=Embed.Empty, icon_url=Embed.Empty)```
Sets the author for the embed content.
This function returns the class instance to allow for fluent-style chaining.
hello
now 4 prob del comma
?
that in the settings what is meant
embed=discord.Embed(title="Blah",description="Lorem Ipsum")
embed.set_author(name="blah")
?
Hello
that looks like a set_footer()
can you do a set_author()? sweet
😭
how do i make the bot like count how many times this user has pressed the button each time the button gets sent??
like if the button has been sent 5 times and this user has pressed it 3 times and the other use has pressed it 2 times, do how i make that?
errr
Show us your code
Unindent that line
Means
Remove the extra 4 spaces before that line
screenshot the error again
Unindent again
Means?
.
Already did
Again
Line 64
You didn't indent line 64
How to do that?
Put 4 spaces before line 64
what the fuck
atp just invite me to your repl
Dm
ok
?
At line:1 char:6
+ c:; cd 'c:\Users\user\OneDrive\πολογιστής\Bots'; & 'C:\Users\user\Ap ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\user\OneDrive\πολογιστής\Bots:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\user\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
cli.main()
File "c:\Users\user\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 444, in main
run()
File "c:\Users\user\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 285, in run_file
runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 268, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 237, in _get_code_from_file
with io.open_code(decoded_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Users\\user\\OneDrive\\πολογιστής\\Bots\\main.py'
PS C:\Users\user\OneDrive\Υπολογιστής\Bots> ``` error
How to make buttons help menu in py ?? Source code ??
so, I currently have code to get all pins in a channel and repost + pin in another location for a coming server move
discord.py grabs pins from NEWEST to OLDEST, can i make it oldest to newest?
code here:
@client.command()
async def pins(ctx):
pins = await ctx.channel.pins()
await ctx.channel.purge(limit=1)
print(pins)
channel = client.get_channel(876290314036461569)
y = 0
for rePin in pins:
y +=1
if y == 5:
break
mat = rePin.attachments
if len(mat) == 0:
message = await channel.send(rePin.content)
await message.pin()
else:
message = await channel.send(mat[0].url)
await message.pin()
I thought to make it all into a list and reverse it, but im not sure how to do that.
Why client.get_guild returning none??
So, I have a cog folder with a file named slash.py and outside of that folder I have two files. One named main.py that handles most of my stuff and slash_utils.py that is for slash commands. How would I import the slash_utils.py folder to my slash.py cog file?
Because that guild isn’t in cache.
oh should I use for loop once?
You seriously asking how to import things?
What? 
Guys, is there a way to read messages in a text channel and get their authors?
👀
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
Why did u use purge for one message lol
cause im cool
😬
Once you iterate over that you’ll get message objects. Which you can of course use the .author attr.
Probably doesn’t know you can use ctx.message.delete()
Or they can use discord.utils.get
Yeah 😂
I use purge so some snipe commannds can't get the message content thing
Normally when you delete message and someone wants to find out what you deleted, purge somehow works so they can't view it
Have you read docs at all?
Message.pins() returns a list of message objects
and reverse it with pythons reverse function.
Function 👀
o ok
you want to get the purged message's contents?
Nope
some snipe commands purging still makes on_bulk_message_delete() dispatch. Some snipe commands actually use that event. Why they do is beyond me.
Hi @sage otter @tawdry perch @slate swan
Hello 👋
Gotta remember that ,thx
How you doing?
Using json as a database 👍😫
There’s a error but I’m too busy
Json 😮💨
Well, you have channel with that id only in one guild
@slate swan
hey , sup
You must be trying to trigger my dpy support server ptsd.

Too many people use json for things it’s not meant to be used for.
Sadly
channel = client.get_channel(914409887948222494)
messages = await dm.history().flatten()
with open(f'{channel}_messages.txt', 'a+', encoding='utf-8') as f:
print(f"\nTranscript Saved.\n\n", file=f)
for message in messages:
embed = ""
if len(message.embeds) != 0:
embed = message.embeds[0].description
print(f"{message.author.name} - {embed}", file=f)
print(f"{message.author.name} - {message.content}", file=f)
await channel.send(f"{message.author.mention}, Transcript saved.")
history = discord.File(fp=f'{channel}_messages.txt', filename=None)
await channel.send(file=history)
does anyone know why this saves a copy of the transcript on my computer as well?
No
Goddammit tylerr
I can exploit json however I like
Hey, can you help?
What
channel = client.get_channel(914409887948222494)
messages = await dm.history().flatten()
with open(f'{channel}_messages.txt', 'a+', encoding='utf-8') as f:
print(f"\nTranscript Saved.\n\n", file=f)
for message in messages:
embed = ""
if len(message.embeds) != 0:
embed = message.embeds[0].description
print(f"{message.author.name} - {embed}", file=f)
print(f"{message.author.name} - {message.content}", file=f)
await channel.send(f"{message.author.mention}, Transcript saved.")
history = discord.File(fp=f'{channel}_messages.txt', filename=None)
await channel.send(file=history)
What are you even trying to do?
This basically saves a file on my compuyer first and then exports it from there onto the specific channel. Is there no way to avoid saving it onto my computer?
I think something is saved
Discord while I'm middle of lesson is best thing ever
saves a computer on my file
Yes
file on computer, sorry!
Saves a computer on my file?
Sweet
So you don’t want the file to be saved
on my computer no, its basically like the ticket bot, saves the transcript of the chat and sends it
I dont want it to save on my computer, however
Just want to directly send it to the channel
Find a way to format all of those messages into a string.
Use io.BytesIO() on the string and make sure the encoding is utf-8
This is kinda confusing so I’ll give an example
yes?
i figured it out, but it saves file computer first and then prints it in chat
file is text or image?
text
channel = client.get_channel(914409887948222494)
messages = await dm.history().flatten()
with open(f'{channel}_messages.txt', 'a+', encoding='utf-8') as f:
print(f"\nTranscript Saved.\n\n", file=f)
for message in messages:
embed = ""
if len(message.embeds) != 0:
embed = message.embeds[0].description
print(f"{message.author.name} - {embed}", file=f)
print(f"{message.author.name} - {message.content}", file=f)
await channel.send(f"{message.author.mention}, Transcript saved.")
history = discord.File(fp=f'{channel}_messages.txt', filename=None)
await channel.send(file=history)

discord.File(io.BytesIO(transcriptstring.encode("utf-8")), "transcript.txt")
is it needed?
they can just append it to a list (store it in memory) in whatever format they want and send that
Pass this into TextChannel.send()'s file kwarg
nvm its not working lmaoo, it's all messed up lol
users[str(user)]["economy"]["money"] -= amount users[str(member1)]["economy"]["money"] += amount doesent work
Can usend ss of whole function
It’ s hard to read codeblocks on mobile
@client.command()
@commands.cooldown(1,30,commands.BucketType.user)
async def give(ctx,member:nextcord.Member,amount:str,what:str="money"):
user = await check_account(ctx,ctx.author)
member1 = await check_account(ctx,member)
with open("users.json","r") as f:
users = json.load(f)
try:
amount = int(amount)
insideuserbank = users[str(user)]["economy"]["money"]
if amount >= insideuserbank:
amount = insideuserbank
if what == "money":
users[str(user)]["economy"]["money"] -= amount
users[str(member1)]["economy"]["money"] += amount
await ctx.send(f"Gave {member1} {amount} {what}")
except:
pass```
Screen shot
no error
ton use json as db
Take a screen shot of the function in ide and send it here
How do I access only the text written by a user? I want to save all messages in a text file but this won't save the message itself:
@bot.event
async def on_message(message):
f = open("d.txt", "w+")
f.write(str(message))
f.close()
await bot.process_commands(message)
async def check_user(ctx,user):
with open("logins.json","r") as f:
logins = json.load(f)
if not str(user.id) in logins:
msg = f"{user.mention} Make an account or log in."
await ctx.send(msg)
return 0
else:
User = logins[str(user.id)]
return User
async def check_account(ctx,user):
with open("logins.json","r") as f:
logins = json.load(f)
user = await check_user(ctx,user)
if user == 0:
return
else:
return user```
Do you know what a screen shot is?
Print screen
Idk how u call it
why should I?
Cus It’ s easier for me to read on mobile
there is no error
Ty
i can understand the pain
Could someone help me? I think it's a very basic problem
Can you ss the json file
which file 
Dont ask if someone can help u, just send the question
Where u store users
i dont have that mate
otter needs help, i just snapped the code block for you
I already asked
Ohhhhh
you check if message.author is the user
@twin moon is ur json a list of dicts?
This will save a message object as string
i meant the content of the message, by I found out I need message.content
},
"IDK": {
"username": "IDK",
"password": "IDK",
"creator": "770210759359070209",
"level": {
"experience": 0,
"level": 0
},
"economy": {
"money": 0,
"bank": 0,
"inventory": {}
}
}```
U need to do message.content
You should have a different structure
It should be a list of dicts
Someone help to fix a code??
If u rly insist on using json
@slate swan
one more {} before it
It should be [] before not {}
It should be [] full of {}
Actually i am sending the replit link i cant rectify my error
Just send ss of the code
I’ m on mobile and It’ s easier that way
To big code
Is it multi page?
Yes
Unfortunately my code still doesn't work, I don'get why. with !newdate [date] a textfile should be created and every message written in a specific channel should be saved in that text file. It creates the text file but it doesn't save the messages:
bot = Bot("!")
bot.remove_command('help')
global f
global enabled
enabled = 0
@bot.command()
async def newdate(ctx, text):
global f
global enabled
f = open(text + ".txt", "w+")
enabled = 1
await ctx.send("New textfile created.")
@bot.event
async def on_message(message):
global f
global enabled
if(enabled == 1):
f.write(str(message.content))
await bot.process_commands(message)
Ok just send the link to replit 😂
Ok dm
Ok
no?
Yes
different error
If you rly insist on using json, that is how It’ s done
Because you're not even writing to the file. How are is it supposed to change if you're only reading the file. You just indexing the info and subtracting or adding whatever to it. You’re not changing the value in the actual file itself.
what did I just say?
write
That’s not what that says in the code block
How do I tell
@bot.event
async def on_message(message):
to only listen to a specific channel?
with open("users.json", "r")
If message.channel.id == id
👍 thanks mate
Np
that’s not really telling it to only listen to only a single channel.
You need to dump the amount back
on_message() gets fired every time a message is sent anywhere the bot can see.
yeah but it does its job I guess
You can’t change that
thanks for the info, but I think it solves my problem nevertheless 👍
🤷♂️
You cant make it trigger for only one channel, you can just execute whats in it if message has been sent in specific channel
Yeah that’s partly what I said 
.
.
It took me too long to write, so b4 I was done u alr wrote that 😂
how do i send a message with buttons?
!d discord.abc.Messageable.send
await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
the view parameter
!d discord.ui.Button
class discord.ui.Button(*, style=<ButtonStyle.secondary: 2>, label=None, disabled=False, custom_id=None, url=None, emoji=None, row=None)```
Represents a UI button.
New in version 2.0.
ok ty
Doy supports that?
It supports components, yes
Never noticed
only on the master branch tho 👌
Ohhh
Not accessible through any of the versions you can get on pip.
what is button row?
Action row u mean?
row=None
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
ok ty
It’ s probably just which row the button will be
Still useful to read
await message.channel.send(view=discord.ui.Button(custom_id="testid",row=1)) this doesnt work it tells me module 'discord' has no attribute 'ui'
……….
And that’s not even how you do it man.
Consider looking at these
@opal skiff
If u want support for components use disnake or master branch of dpy
how do i do that?
switching to fork seems like a drastic measure compared to just using the repos master branch
but if he doesn’t have git then that’s whatever then
The fork has almost same api
all wrappers use the same api
Not the api they use, api they have
the version might differ
*functions
Yes and no
Those came out after Danny stepped down.
Idk, mby they will add em
!pypi disnake
Hi
Hi
All new stuff?
ah, you are talking about the interface the forks provide
What happened to Danny?
Yes that api, not discords api
?
Oh lmao
Thank u so much
Well at least he gave us the privilege of an amazing API
Fr, they rly fucking with stuff by adding message content intent
I mean any self-respectable chat service/platform could do that.
Revolt already has an open one.
However the app itself is in really really early release.
The library does have a great api
await message.channel.send(view=discord.ui.button(custom_id="testid",row=1)) how do i fix this error discord.errors.InvalidArgument: view parameter must be View not <class 'function'> ?
Are you reading any of the things we sent you earlier
Most notably the examples.
Also it’s Button()caps matter
oh? there were examples? i didnt see them. sorry
Hi
oh
How is everyone
sleepy… 5:30 in the morning and out of all things I could be doing right now I decided to come help in this server
…
I woke up at 7 and hopped on my laptop
Like I should be doing that
It’s 10:34
Hello guys, why cant i add a button to a message that comes from a button?
add a button to a message that comes from a button
how its an error wtf
And you can just do client.remove_command() instead of making your own help
You indented it wrong
wjat
i dont get it
i thgink my python broke
I dont do nextcord

either its to much space from left or not enough
It didnt break, you just dont know simple python syntax
I’m going to look some stuff up for you
Thanks
wat
You mean it doesnt show up?
I think the error is self-explanatory
heres fine
That’s not the error
Show me line…940….
On the roll function
Show me more
I think there is a space behind async
Delete the space behind async
You’re supposed to use tabs
Like this
From about here to here
the space in between is a tab
however this is a normal Space
theres no space
yes
Supposed to be a tab
correct
alr thanks
I dont think they have a tab on their keyboard
sucks to be them
bro
DM_help=False
i wonder what it means
i legit just entered
They still DM me
I said tab not enter
They don't know what bools are
i think my python broke ig
No
Your python did not break
Python ||almost|| never breaks
Not in my experience
bro there was no error yesterday
today it just out of nowhere
and i never touched that command
You have to rewrite your code, maybe it works then
what error
we all start somewhere xd
🤷♂️
bro its just came out of nowhere
I still cant figure it out how to use buttons.
even tho i didnt touched that code
It can’t come out of nowhere
*haven’t touched
Are u using discord-components?
Disnake
do not fix my grammar 
Well that’s impossible for your code to break
no i dont think so. i found something like .add_item(discord.ui.Button(label='Click Here')) btw
Errr
but never 0%
Disnake
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.
k fine but its poor quality 
@bot.command()
async def roll(ctx, minnumb:int, maxnumb:int):
rollmsg = random.randint(minnumb, maxnumb)
if minnumb<0:
Er1 = discord.Embed(title = "Roll Error", description = f"Amount must be positive!")
await ctx.reply(embed = Er1)
return
if maxnumb<0:
Er2 = discord.Embed(title = "Roll Error", description = f"Amount must be positive!")
await ctx.reply(embed = Er2)
return
Roll1 = discord.Embed(title = "Rolling.")
editmsg = await ctx.reply(embed = Roll1)
await asyncio.sleep(0.75)
Roll2 = discord.Embed(title = "Rolling..")
await editmsg.edit(embed = Roll2)
await asyncio.sleep(0.75)
Roll3 = discord.Embed(title = "Rolling...")
await editmsg.edit(embed = Roll3)
await asyncio.sleep(0.75)
Roll4 = discord.Embed(title = f"Rolled {rollmsg}")
await editmsg.edit(embed = Roll4)```
dude still doesn't know how to use ducking tabs
i legit use tabs
i see half a tab in 3rd row
It’s supposed to be 4 I think
but how tf it can break out of nowhere even tho i didnt touched it
Or 8
what's the problem with the code tho?
you copy pasted it from somewhere?
Maybe
@slate swan
SyntaxError: invalid syntax
Maybe it’s in the wrong place
Send the entire piece of code as a screenshot
It looks like it’s been indented
bro
Problem solved
alr bet
*1 tab
…
950+ lines of code , cogs be like : 
how do i make it so that my command is usable to a specific role
lazy to do it 
has_role()
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
Yes
it can be the role name or the id
I mean ah ah tabbed it wrong I guess
so like @commands.has_role(id here) or the id is in a string?
I PRESSED TAB ONCE
role id goes there
: : i am joke to u?
o
Unless it’s in a class
if you provide a name it must be string
else id py @has_role(id) @has_role('rolename')
I meant the function
😂
The function shouldn’t be tabbed
oh
Unless your IDE is weird
well how do i make my event on_message so theres an if message.content but it can only be triggered by a specific role
ctx.author
has_role()
no it's on_messae
I’m on a phone 😭
message*
i rewrited the function and uhh
if role in message.author.roles
still same crap
message.author()?
You changed the the name
oh wait
the the 
the red line keeps moving down until your bot.run , bet
😭 can you understand
yes.
atleast it's entertaining
how can I view audit log with bot, I forgot
Yeah it is funny
That’s literally simple syntax
homework @slate swan
!d discord.Guild.audit_logs
async for ... in audit_logs(*, limit=100, before=None, after=None, oldest_first=None, user=None, action=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the guild’s audit logs.
You must have the [`view_audit_log`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.view_audit_log "discord.Permissions.view_audit_log") permission to use this.
Examples
Getting the first 100 entries:
```py
async for entry in guild.audit_logs(limit=100):
print(f'{entry.user} did {entry.action} to {entry.target}')
```...
i said that error came out of nowhere even tho i didnt touched it
You don’t want to delete the tab behind the function
thx!
yesterday it was fine but today it doesnt wanna work
I told you the answer
yw
Hahhaa
…
Delete the tab
theres no tab
Please 😭
There is 😭
ah , ah
you didnt answered if you copy pasted something :)
if you just remove it , the code gets fixed
i writed myself?
or typed
whatever
LMFAO
Space
Or whatever there seems to be a space
What is that
Is there a tab or something
😭
uhh wat
ok
roll invalid now?
No
whats the parameter for member leave
Is there tab at rollmsg?
U have an unclosed bracket somewhere above that line
on_member_leave
is it not on_member_remove?
Yes it is
ah
It’s when it’s removed, but sure
!d discord.on_member_remove
discord.on_member_join(member)``````py
discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") leaves or joins a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").
This requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
LFAMOOOOOO
.....? There's nothing like member_leave
Works now?
us trying to solve the problem :
😭 no?
i am dying from laughing
I hope I fixed your Python after it broke? @slate swan
Haha close bracket go brrrr
!d discord.on_member_leave nope
No documentation found for the requested symbol.
how i didnt noticed 
Well 🤷♂️
skill issue? well yeah...
My code goes crazy when that happens
😐
Moving on…
oh sorry
How are you HTH?
Fine 😶
If you sat !ot my god I will make you pay
!ot
Off-topic channels
There are three off-topic channels:
• #ot2-never-nester’s-nightmare
• #ot1-perplexing-regexing
• #ot0-psvm’s-eternal-disapproval
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
Please read our off-topic etiquette before participating in conversations.
alr thanks for help but it was actually funny 
(:
Lol
Goddammit Hunter
(:
So i have a this:
forward = True
general_channel = client.get_channel(914302945351311360)
if message.content.startswith('$uuhc'):
await message.channel.send('Which scenarios?')
def check(message:message):
return message.author == message.author and message.channel == message.channel
response = await client.wait_for('message', check=check)
try:
response = await client.wait_for('message', check=check, timeout=90) #90 seconds timeout before the response errors)
except asyncio.TimeoutError: #captures the error
await message.channel.send('Oh no! You did not respond in time')
forward = False
if response.content == '':
forward = False
else:
scenarios = Convert(response.content)
but it makes me give a response twice for it to work
await message.channel.send(embed=discord.Embed(description="test"),view=View().add_item(Button(label="test")))```the bot sends the embed but there isnt a button or an error message
The check and try block are both waiting for message, it might be the problem
hay how to make warn command?
Can the discord bot check, if the message was sent from Mobile or Computer?
only warn command not warn list or clear warns
def is_on_mobile
hey how to make warn command?
how would i fix this?
Remove the wait for message from check function
Do you know sql?
You have two client.wait_for
em
sorry but what is it
smth to do with databases i think it is a library
sql is a language to communicate with database
what does the colon do?
wait where? i cannot see it
there's one under def check() and another one in try except block
indicates what a argument/variable type is
but i dont know how to make a warn command bro
It tells the type of user is discord.User
You would need to know snow sql
so what is the difference between using a colon and a =
async def test(ctx, user: discord.User):``` here, discord will automatically try to convert user to a discord.user object
you cant use = for a object type lmao
a = int
a: int

but i dont know how to start and end the warn command
etd
well... do you know sql at all?
if yes, I can easily help you. If no, I can try to find resources for you
How to check that if a member's ID is in the member key, then display a message to him that he is in the black list
nope
but i just wonna make only warm command thats only warn sameone
+warn @slate swan resson and it says warned user resson
but the with mentioned user and with the resson
adn the admin or somethhing like that can use the command
start by making a simple command with parameters of ctx, member: discord.Member, *, reason: str
then send a message with mention of member & reason
and after you done with that ping me, I will be looking for docs to limit the command for admins
ok
tho there's no need to typehint to str
I'm just used to it

without that I would get confused for no reason
wym?
you don't usually do that
kick member or ban member or something like
I'd make it based on roles
a warn won't kick members
don't do that at all
maybe if a second warn kicks the member, I'd probably check for kick_members permission

first warn = ban
wat
nothing
await self.bot.db.execute("INSERT INTO messages VALUES (%s , %s)",ctx.author.id,message)
is it something like that ?
@commands.command(aliases=['store_messages'])
async def store(self,ctx,message=None):
if message is None : return await ctx.send('add a message to store')
await self.bot.db.execute("INSERT INTO messages VALUES (%s , %s)",ctx.author.id,message)
await ctx.send(f'Done inserting {message} into the database') ```
seems good to me
its more related to dpy since i'm using bot.db i've defined it , not sure if this is how it works
me neither, give it a try. The syntax of sql looks good tho
async def create_db_pool():
bot.db = await asyncpg.create_pool(database="Test_database", user="postgres", password="password")
bot.loop.run_until_complete(create_db_pool())```
Just because you're doing whatever this is inside of a bot does not make it dpy related.
"i have a toaster in my house, do i ask a carpenter how to fix it?" - Laggy
oh alright , is it really worth it to hide my db password ?
yes
fair
showing information of databases is bad
people could just delete the whole db
yes, nvm
huh its not even working ?
add print before doing anything else
Whats ur bot supposed to do?
here
how do i fix my code to display a button? py if message.content == "T!tiktaktoe": await message.channel.send(embed=discord.Embed(description="test"),view=View().add_item(discord.ui.Button(label="test",custom_id="testid")))
My most used word today is “Alexa skip”
I swear to god the taste in music of other people
inserts !ot
whos code?
mayhaps
Yours
I don't want to count the total of lines
but I would guess it's somehwere cloe to 2k lines or smth
here are most of commands
What does nitro do
👀

just sends a fake nitro gift image
of my bot?
No the command
I will maybe find it later
Just interested in commands that arent common
I keep forgetting to not be bored to make button commands
pretty simple
BucketType
whhy
Because yes
sad
Goddammit cyberweapon just put a buckettype please
no
But
if it has worked so far, it will work later as well
💀 ok
Lmao
Indeed
I meant your source command
He wants to copy and paste it
can someone please give me an code example of how to send an embed with multiple buttons using master branch of discord py
What
Code?
yes because i cant get it to work
i dont understand how disnake works
ok
oh
as its not working properly
I can see it
async def foo():
def fooo():
#do some stuff
fooo()
yes but what if that function is another discord.py command
that's not gonna work, commands inside commands?
ok
there is a problem
when someone does the command
it stores the ID ina a db
yes?
send your current code (a screenshot preferably)
What if the user has disabled DMs from the server?
thats not the point
An error maybe
im trying it on myself
.
Nesting functions don’t work I think
that wont work, make either a helper function
you've labeled dmkey as a command using a command decorator
He should maybe make an if else statement for that so that it prints an ephemeral message for him „cant dm user“
It may, but sometimes it won’t work
Or maybe it will
Error handlers
A try except statement
Will do
I don’t trust try except anymore
I dont really get the difference tbh
It doesn’t work on discord py for cool down
i get this error
So I have to use an error handler
dude...
@bot.command()
async def roll(ctx,mnnumb:int,maxnumb:int):
rollmsg = random.randint(minnumb, maxnumb)
if minnumb<0:
Er1 = discord.Embed(title = "Roll Error", description = f"Amount must be positive!")
await ctx.reply(embed = Er1)
return
if maxnumb<0:
Er2 = discord.Embed(title = "Roll Error", description = f"Amount must be positive!")
await ctx.reply(embed = Er2)
return
Roll1 = discord.Embed(title = "Rolling.")
editmsg = await ctx.reply(embed = Roll1)
await asyncio.sleep(0.75)
Roll2 = discord.Embed(title = "Rolling..")
await editmsg.edit(embed = Roll2)
await asyncio.sleep(0.75)
Roll3 = discord.Embed(title = "Rolling...")
await editmsg.edit(embed = Roll3)
await asyncio.sleep(0.75)
Roll4 = discord.Embed(title = f"Rolled {rollmsg}")
await editmsg.edit(embed = Roll4)
If someone's DMS are closed the ln an error is raised, try except statement can catch that error but if else wont
🤣 have you seen the code
dmkey requires another argument
I have

dont make fun of him, you're wrong lmao
Is what I’m trying to say
yes it the parameters are ctx, user messafe

