#discord-bots
1 messages · Page 864 of 1
ohhhhhhh how i dident think of that thanksssssssssssssss
yw
any way to change a bots status normally, not listening watch or streaming/playin
it says listening lmao
client.change_presence(activity=nextcord.Game(name=message.content), status=current_status)
thats nextcord + it'll say playing
didnt say what your using
i think next time i will change to nextcord do u think it's better than discord.py? @sullen linden
yes as discord.py is discontinued and nextcord took over maintaining it, just different name
along with some other forks ^^
yes, not saying its the only one, just the one i went with
disnake 
@bot.command()
async def alex(ctx, arg):
name, leng, amnt = arg.split(':')
users = 0
name = name
leng = leng
amnt = amnt
for i in range(int(amnt)):
user = "".join(sample(ascii_lowercase+digits, int(leng)))
users += 1
print(f"{user} | {users}")
buffer = BytesIO(user.encode('utf-8'))
file = discord.File(buffer,filename=name)```
For I in range doesn’t work for discord bot command any alternative
This PR removes discord.py, disco and Sword from the community resources libraries list as the libraries are unmaintained (GitHub repos have been archived) and they do not provide an interface for ...
it does work, what inside it doesnt work?
define "doesn't work"
Bruh
they are still usable
It sends the txt file with 1 string instead of amnt
do you provide 2 : : s in the arg?
Also why not use multiple arguments?
I just find it easier
ikr! Even if discord.py is archived it still works decently ( altho without application commands) , I wonder why disco was still there tho
Noone uses disco
people used it during 2015-2017 iirc
but then people started using discord.py
Yea and I'll assume it was blocking since all of the methods there are normal functions ( or maybe they use them in run_in_executor)
examples/basic_plugin.py lines 50 to 56
@Plugin.command('test')
@Plugin.command('echo', '<content:str...>')
def on_echo_command(self, event, content):
# Commands can take a set of arguments that are validated by Disco itself
# and content sent via messages can be automatically sanitized to avoid
# mentions/etc.
event.msg.reply(content, santize=True)```
print(interaction.message.mentions)
is being inconsistent on seeing the mentions from the message and im not sure why
what's the interaction variable there? A discord.Interaction?
!d discord.Interaction.message
The message that sent this interaction.
ya
working with persistent buttons
do you have member intents? That may be the issue
since .mentions returns a list of Member objects
It's always printing an empty list right?
No one uses / commands and if you do there just preparing for update so discord.py works fine for me personally
no, in two servers im in, its working just fine, printing out every mention just fine. In a new server, its ether doing none or only one
are you sure no one uses slash commands 
hello could i get som help?
Ask your question please
@commands.has_role("Bot Tillgång")
async def swish(ctx:discord.ApplicationContext , namn: str, nummer: str , belopp: str):
interaction = await ctx.respond(f"Processing payment request from {ctx.author.mention} to {namn}. Amount: {belopp} .....")
msg = await interaction.original_message()
payment = utils.Payment(namn,nummer,belopp,msg.created_at,msg.id)
await msg.channel.send(file = discord.File(fp=payment.mp4))
payment.close()
This is not working, how do i fix this?
I said some people do read again
okay
What exactly is not working
quick question, with is utils.util already come with discord.py? or do i have to install it
async def swish(ctx:discord.ApplicationContext , namn: str, nummer: str , belopp: str):
this
and can someone teach me how to make a slash command?
What exactly is not working? Provide the error message too
it is no error message the function just not working
discord.utils, you talking about this?
idk if utils.util is a thing 
yes discord.utils that's what i meant
yeah its a dpy inbuilt thing
am I able to GetMessage from discord.utils?
why you gotta use utils for that?
!d disnake.ext.commands.Bot.get_message
get_message(id)```
Gets the message with the given ID from the bot’s message cache.

import discord
from discord.commands import slash_command,permissions
from discord.ext import commands
GUILD_IDS = [945410623737589801]
Intents
intents = discord.Intents().all()
bot = commands.Bot(command_prefix="!", intents = intents)
@bot.event
async def on_ready():
print(f"We have logged in as {bot.user}")
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name ="my server"))
print(discord.version)
guild = bot.get_guild(945410623737589801)
# print(guild.roles)
<Role id=945014621033599036 name='Bot Tillgång'>
@bot.slash_command(
name = "swish" , usage="/swish" , description = "Command for making payment" , guild_ids=GUILD_IDS , default_permission = False
)
@permissions.has_role("Bot Tillgång")
async def swish(ctx:discord.ApplicationContext , namn: str, nummer: str , belopp: str):
interaction = await ctx.respond(f"Processing payment request from {ctx.author.mention} to {namn}. Amount: {belopp} .....")
msg = await interaction.original_message()
payment = utils.Payment(namn,nummer,belopp,msg.created_at,msg.id)
await msg.channel.send(file = discord.File(fp=payment.mp4))
payment.close()
need som help / command is not working
Imagine not being pos only arg 👀
thats a good thing lol, pos only args are just irritating
hey, can i get the docs for guild
I sent docs here https://pypi.org/project/discord-py-slash-command/
ok ty
Hello.
Need help. How do I get the bot to mention the user who used the command?
use a fork
NO.
Why
that library is really unmaintained and discord.py is dead anyways
author.mention
use an actualy fork which does more than just slash commands
Thanks
Like nextcord
or disnake
¯_(ツ)_/¯
I might use disnake
Never used before tbh
@edgy osprey f"{message.author.mention}
Thanks
Any error just ping
Okay
It takes about 1h for discord to add command
how do i get the bot mention the user i mention?
and i did all right?
Should be
okaa
and i did all right?
Use if statement?
Hm
You did it wrong
ctx is the command context
await ctx.send(f"{message.author.mention} hello”)
@edgy osprey
Just copy and paste that
🥄
Also don’t use client use bot
Okay
@edgy osprey
Bot has a lot more features compare to client
@bot.command()
async def alex(ctx, arg):
name, leng = arg.split(':')
users = 0
name = name
leng = leng
amnt = "10"
for i in range(int(amnt)):
user = "".join(sample(ascii_lowercase+digits, int(leng)))
users += 1
print(f"{user} | {users}")
buffer = BytesIO(user.encode('utf-8'))
file = discord.File(buffer,filename=name)
The amnt amount doesn’t work bc it only sends 1
whats the command for the bot to send a custom video?=
Use docs before you ask basic py questions
Google > stack overflow > discord
For me: DMs > discord > stack > google
agreed
True
I got a really good coder friend to help with dms lol
cheese
Just send problem here
odd question
Go on
im trying to grab the authors icon , i don't see anything about it in the documents, unless im literally blind
is this correct? {ctx.author.icon_url}
You mean pfp?
yeah pfp
how to make discord bot send attatchments? 🙂
Use docs bro
how im new?
Somewhy my print command in main file got excecuted twice only when i had cogs loading
Documentation
you mean files?
yeas
@kind cargo https://stackoverflow.com/questions/50860397/discord-py-bot-sending-file-to-discord-channel
yeah
Stack overflow is really handy ngl
what does pass_context do ?
@slate swan
Yes
@commands.has_role("Bot Tillgång")
async def swish(ctx:discord.ApplicationContext , namn: str, nummer: str , belopp: str):
interaction = await ctx.respond(f"Processing payment request from {ctx.author.mention} to {namn}. Amount: {belopp} .....")
msg = await interaction.original_message()
payment = utils.Payment(namn,nummer,belopp,msg.created_at,msg.id)
await msg.channel.send(file = discord.File(fp=template.mp4))
i have coded this but it does not send the template.mp4
May I ask have you read python docs before you started coding
yes
no XD
Otherwise this will make your project 100x harder
yea
okay so then i just paste the name of the file in 'my file' right?
you need to specify file path
whatt?
Specify file path
oka
It’s self explanatory
if it's not in the main folder
it is not in the main folder or it is
yeah copy the full path
Copy the path
okk
Once the file is in path it should work
and how? im sorry, i use to talk swe.
Not to be rude but file path should be basic pc knowledge
I’m not sure myself
you uh, find the file, in the location bar on your file explorer copy the location, don't forget to add the file name and extension on the path
is this right now?
@commands.has_role("Bot Tillgång")
async def swish(ctx:discord.ApplicationContext , namn: str, nummer: str , belopp: str):
interaction = await ctx.respond(f"Processing payment request from {ctx.author.mention} to {namn}. Amount: {belopp} .....")
msg = await interaction.original_message()
payment = utils.Payment(namn,nummer,belopp,msg.created_at,msg.id)
await channel.send(file=discord.File('C:\Users\sweti\OneDrive\Skrivbord\swishbot\swishbot\video\template.mp4'))
payment.close()
but i got an error
U got an unclosed bracket somewhere
me?
remove the last bracket
Use google don’t keep resorting here
okay
but like so i cannot get help or what?
.
I’m just gonna treat you like every other coder here I’m not gonna spoon feed
i saved them all, it was in pycharm
Which is better vscode or pycharm?
Personally I use vscode but I heard of pycharm
i would say pycharm, cuz im still learning
Same
i code cpp and htmls with vscode tho
I might use it what are advantages to pycharm
for python, pycharm is def one of the best.
it's just more tidy and commands are grouped so it's easier to edit and look
O

@bot.command()
async def alex(ctx, arg):
name, leng = arg.split(':')
users = 0
name = name
leng = leng
amnt = "10"
for i in range(int(amnt)):
user = "".join(sample(ascii_lowercase+digits, int(leng)))
users += 1
print(f"{user} | {users}")
buffer = BytesIO(user.encode('utf-8'))
file = discord.File(buffer,filename=name)
How to send more then 1 string
you mean you want to join more than one acii_lowercase?
name = name and leng=leng 
Ty
W
Good luck
what kind of game is that
API fun
Guess the hidden word in 6 tries. A new puzzle is available each day.
dude
this is an easy kind of game
I mean, thats just 2 unnecessary lines...
Does anyone know why loading cogs makes the main file prints this "Connecting to the internet"(it's in the main file) twice, it doesn't happen when i don't have any put any cogs in

when is the internet thingy triggered?
U do know u r just wasting resources, right?
Wdym
when starting the bot
Reassignment just wastes RAM and CPU, tho it almost being 0 but still
"what" exactly triggers it
loading cogs
smh 
REALLY
Show the loop where u r loading the cogs
i kind of don't get this but it loops this code
# listing all extensions in startup
for extension in os.listdir('./cogs'):
if extension.endswith('.py'):
bot.load_extension(f'cogs.{extension[:-3]}')
print(f'> {extension} has been loaded.')```
And where u printing connecting to internet?
right above it
I asked exact same question 
Didn't read the chat history sorry
Try restarting yr bot. Does it still print twice?
yeah whenever i have an extension in cogs folder.
no need to be sorry, they didnt answer when I asked
i was lost LOL sorry
load properly 
it worked a week ago just fine...
@slate swan cogs r so much better my friend, i made the switch. makes everything more organized and easier to use imo
Show whole code
imagine them sending all of the code with cogs 
Do u know what's funner?
Then the question goes again!
ill remove the unecessary codes
I just need the code of the main file
yeah i was trying to send that wait
Ok

Hey @scarlet rune!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
what?
Separate file for each command 👀
@bot.command()
async def alex(ctx, arg):
name, leng = arg.split(':')
users = 0
amnt = "10"
for i in range(int(amnt)):
user = "".join(sample(ascii_lowercase+digits, int(leng)))
users += 1
print(f"{user} | {users}")
buffer = BytesIO(user.encode('utf-8'))
file = discord.File(buffer,filename=name)``` it prints the string but doesn’t make it in txt it only writes 1 on txt
couldn't be asked to do that.
.
Heh?
lol
Damn dude yr pfp
very_useful_bestest_discord_bot/
bot.py
.env
cogs/
kick.py
ban.py
nickname.py
warn.py
news.py
ping.py
damn, this looks smexy af
I mean yea... That is doable
looks cool though 
Then use djs
why is my slash command like this?
Ezzz
They are locked to only people with certain perms/roles or smth idk
I don't know nothing about djs 
but im the owner
discord.gg/djs do be waiting for u
Dude stop
Mind showing the code?
nah they be making fun of me if I ask somethign stupid 
ye

Like some people make fun of people here?
!paste the code here
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.
!paste
count me in
use this link - https://paste.pythondiscord.com/
I know (:

Would be fun to see how the tables turn
here is my code @maiden fable
would make me realize what it feels like to be made fun of
yes'
I know (:
u have that role?
done
That is why I don't make fun of a beginner. I know how it feels like (:
yes i do ..
try setting default_permissions to True
I've stopped too
kind of, bad habits dont leave instantly
it worked @maiden fable 🙂 ty so much
Cool!
yee, but i got one more problem could u help me again? 🙂
the cat do be cute tho 👀
Sure haha, what's up
Yea haha
so my problem is
my bot should be able to send a gif when i type a command (custom gif)
but it does not send
Mind sharing the command code?
Cannot get on a call rn
okay wait i will just pm you
So show me where is the gif and where is the Python file
Sorry no DM help. I am ready to help u here itself
Sure
yep
okay ty lemme try
is there any way to make paid commands? (patreon's API down...)
it does not work @maiden fable
Oh, show the latest code (u can paste it here itself since its smol)
how does one make it so that when a github link is posted with specified lines it displays the lines?
U should use regex and on_message
@commands.has_role("Bot Tillgång")
async def swish(ctx:discord.ApplicationContext , namn: str, nummer: str , belopp: str):
interaction = await ctx.respond(f"Processing payment request from {ctx.author.mention} to {namn}. Amount: {belopp} .....")
msg = await interaction.original_message()
payment = utils.Payment(namn,nummer,belopp,msg.created_at,msg.id)
await msg.channel.send(file = discord.File(fp=video/template.mp4))
payment.close()
do you know where it is in @unkempt canyon's implementation so I can take a look?
for references
wel, now how to add each patrons to dat database
🗿
and @maiden fable i made custom text for this gif aswell i hope it will work if we fix this gif
It is a string bruv
""
where is the string?
will nextcord cogs work if main.py file was discord.py??????
@maiden fable
Hy guys how i can code my discord so that if one specific user do something i do something base on that action
For ezampme if akai mentioned me my bot reply dont mention me but if another mention me
Bot didn't apply
In short one functionality specifically for one user base on his one specific action
Can i do it with discord.py
If yes then how
user = "".join(sample(ascii_lowercase+digits, int(leng)))
How would I add amount of strings
I got length but no amount
Why i dont have access via reaction to a older bot message anymore?
Not sure
on_raw_reaction_add
show code
the error handling code
It looks better as it tells user it doesn’t exist imo
Await reaction_add

Yes
hello
^^^^^
How can I host a bot what uses FFmpeg?
is how to mention someone in discord.py ?
this piece of code didn't working in discord.py ??
is something im doing wrong or there is anyother way to do it
if yes plz let me know
id’s are always ints
remove the “

Smh imagine using emojis for no reason
what the prob.?
thats u show much
?
one more thing how to sent custom emoji in embedd msg ?
?
i try :python : this way but didn't work
it sent default emoji which available in windows but not the one which is on custom servers
Do \:emoji: and then pass the string u get in the code
i do the same but didn't work
Show
no
do, \:emoji: and copy paste the format of name and numbers
<:name:id>
^
didn't get ser
see it send the message but not the emoji
that attach to :SOL:
Can someone help me? I am trying to make my bot send a video, but it is not working. What did I do wrong?
await ctx.channel.send(file = discord.File(fp=video/template.mp4))
cann u plz tell me where to get id ?
@bot.command()
async def envers(ctx, *text):
enversChar = "ɐqɔpǝɟƃɥı̣ɾ̣ʞן ɯuodbɹsʇnʌʍxʎz"
enversText = []
for word in text:
for char in word:
if char.isalpha():
index = ord(char) - ord("a")
transformed = enversChar[index]
enversText.append(transformed)
else:
enversText.append(char)
enversText.append(" ")
await ctx.send("".join(enversText)) ``` Hello, this code don't work, I try to make the bot say a phrase but in reverse (with characters) but the bot say something completely different :
can someone help me please ? (this code work with an another alphabet)
U do know there are better emojis, right?
\😭
lol
uh....it works with custom emojis only
@maiden fable can u help me?
I just DMed u a link, click on it. That's the answer
@bot.command()
async def envers(ctx, *text):
enversChar = "ɐqɔpǝɟƃɥı̣ɾ̣ʞן ɯuodbɹsʇnʌʍxʎz"
enversText = []
for word in text:
for char in word:
if char.isalpha():
index = ord(char) - ord("a")
transformed = enversChar[index]
enversText.append(transformed)
else:
enversText.append(char)
enversText.append(" ")
await ctx.send("".join(enversText)) ```
Hello, this code don't work, I try to make the bot say a phrase but in reverse (with characters) but the bot say something completely different :
can someone help me please ? (this code work with an another alphabet)
Please don't post repeatedly
I am trying to make my bot send a video, but it is not working. What did I do wrong?
await ctx.channel.send(file = discord.File(fp=video/template.mp4))
remove the fp kwarg and just put the path in a string
Can someone help me? I need to create a command, that will mute users for estimated time and the time will go even after the bot was off
yeah thats the best option
await ctx.channel.send(file = discord.File(fp="video/template.mp4"))
Change it to this
disnake*
Literally copy paste the code (:
nah all forks
how to change the color of embed message title name ?
You gotta edit the 2.0 version of the lib, edit lines 637-752 in discord/member.py
https://github.com/Rapptz/discord.py/blob/45d498c1b76deaf3b394d17ccf56112fa691d160/discord/member.py#L637-L752
You need to add a parameter for timed_out_until: Optional[datetime.datetime] = MISSING
async def edit(
self,
*,
nick: Optional[str] = MISSING,
mute: bool = MISSING,
deafen: bool = MISSING,
suppress: bool = MISSING,
roles: List[discord.abc.Snowflake] = MISSING,
voice_channel: Optional[VocalGuildChannel] = MISSING,
reason: Optional[str] = None,
timed_out_until: Optional[datetime.datetime] = MISSING,
) -> Optional[Member]:
Then add handling for the param:
if timed_out_until is not MISSING:
if timed_out_until is None:
payload["communication_disabled_until"] = None
else:
payload["communication_disabled_until"] = timed_out_until.isoformat()
If any of this is confusing -> don't do it.
No, don't ask for help with it, we won't help.
Need to add getting the timeout duration of a member added to the Member class checkout ?tag timeout duration for Member
If u want to try implementing it yourself, @slate swan
can someone help me please ?
Sorry, never used ord function
no problem
await ctx.channel.send(file = discord.File(fp="video/template.mp4"))
is this correct? @maiden fable
Yes.
okay
how to change color of embed message ?
it takes another argument discord.File(fp, filename)
color = 0x(color)
when i used color =red it chaneg the left bar color not the text color
text color cant be changed
ok
yes
you must use color HTML for better color and text color can't be changed
color html?
what..... 
ThTs optional
o
that would change the strip colour
yes that what i say..
they were asking about text, not the strip
yes and i tell him a tips; problem about that ?
they ?
what.....
what did I even say 
yes, they?
nothing relevant
he was solo ?
I used "they" as a gender neutral pronoun
Does the file have to be in his code?
lmao what a world i imagine you are a teenager girl
there war and some people create problems
can we please stop now?
ofc i dont like people like you
?
Command raised an exception: TypeError: can't compare offset-naive and offset-aware datetimes
Like, does the file he is trying to send have to be in the same folder his code is in?
U gotta set timezones for both

can we please stop 🤓
how would I do that? created_at already has tzinfo im not sure how i would 'set' the tzinfo for the timedelta```py
if data['last_daily'] is None or data['last_daily'] < (ctx.message.created_at - datetime.timedelta(days=1)):

does last_daily have timezone?
sorry to hurt you little gay girl :(
Can we stop this?
yeah
@vale sierra @slate swan go to dms
she block me unfortunately
just do [::-1] to reverse a string
your whole code is useless
Then just shut up both of u
i already test this but its dont work
LMFAOOO
???
its worst than my code when i tested this
Print it
print what?
screen
how to replace {0} with a variable in an embed's title?
async def test(self, ctx):
embed = discord.Embed(
title = 'Title {0}'
)
embed.title.format('text')
await ctx.send(embed = embed)
that does nothing
i test
also ye dont forget the * before the sentence parameter
!f-strings
Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.
>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."
Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.
ok
how can I do it with format?
Why would you use format when you can just use use a f string
because its cleaner
no?
Also, you are not changing the title with embed.title.format(..., It's just an operation you performed which is not making any changes
Hi guys! I am trying to make my bot send a video, but it is not working. What did I do wrong?
await ctx.channel.send(file = discord.File(fp="video/template.mp4"))
How is that cleaner?
thats not work (the message is a error)
!d discord.File
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
show your code
@bot.command()
async def reverse(self, ctx, *, sentence : str):
await ctx.send(sentence[::-1]) ```
@thick sigil u mean me?
no
OK SORRY
remove self @vale sierra
templateEmbed = discord.Embed(
title = 'Your word {0}',
description = (
'really long text here'
'really long text here'
'really long text here'
'really long text here'
'really long text here'
'really long text here'
'really long text here'
)
)
@commands.command()
async def test(ctx, word):
embed = templateEmbed.copy()
embed.title.format(word)
await ctx.send(embed = embed)
Error? It may take time to send if the file size is large and you have High latency
U gotta send a discord.File instance
its cleaner that way
Not just file path
okay
I defined the embed outside of the command
It's not, anyways```py
embed.title = embed.title.format....```
Would is be possible to update code without restarting the bot?
let me try that
its work, thx
If you use cogs you can just use reload_extension
If you reload the cog
ah yes thank you :)
@cedar stream so how do i do?
Send discord.File()
!d discord.File
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
Read this
What else is he doing?
ok
file=
if i am not using cogs, no way right?
Nope
Nope
2022-02-27 13:01:12.254000
I mean dpy will create a file object once it finds the file on the mentioned path
be sure that it is reachable
Add timezone here
Also this.
Actually there is
fp isn't a kwarg and ctx.send is enough
How?
!pypi watchdog this was also implemented in disnake
He's not doing that if you notice it
This restarts the bot...
he's not doing what
someone help me with this
With?
Well we don't have to manually do that tho iirc
i dont understand
await ctx.channel.send(file = discord.File(fp="video/template.mp4"))
he's not doing what
Wym u don't understand?
He does not have a fp argument in send?
what im gonna type there
in discord.File
And its a kwarg
yes

!d discord.File
class discord.File(fp, filename=None, *, spoiler=False)```
A parameter object used for [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send") for sending file objects.
Note
File objects are single use and are not meant to be reused in multiple [`abc.Messageable.send()`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable.send "discord.abc.Messageable.send")s.
not a kwarg
hm
You both do know that I told him that code right? 👀
Try it with absolute path
I know nothing Hunter
remove the channel attribute
.
i dont understand what hes meaning
Still doesn't matter if he uses it
what should i remove what should i type?
await ctx.send(file = discord.File(fp="video/template.mp4"))
changes nothing, but definitely triggering
Copy the whole path of the video
Removing channel attribute wont fix his code. Try to instantiate discord.File and see if it found something
!e ```py
def fn(not_a_kwarg):
print(not_a_kwarg)
fn(not_a_kwarg=1)
🏃doesn't matter if he used It as a kwarg
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1
Does it even raise an error?
no but it does not send the video
what's your bot's latency
today = datetime.date.today()
new_daily = datetime.now(today.year, today.month, today.day, tzinfo=datetime.timezone.utc)
``` good?
what?
um, your bot's ping
Do I look like an interpreter
how can i see that
you gotta use bot.latency to check it
I’ m stupid
property latency: float```
Measures latency between a HEARTBEAT and a HEARTBEAT\_ACK in seconds.
This could be referred to as the Discord WebSocket protocol latency.
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() got an unexpected keyword argument 'timeout'
Error ^
button = Button(label="Invite", style=discord.ButtonStyle.primary,timeout=180)
Code ^
Lib | discord.py
Question | How do I fix this?
timeout is not a thing in discord.py
what is in discord.py then
Oh, it's a View
for cooldown
!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.
you gotta attach it to a View object then override it's on_timeout method, you can then do whatever you want in the method
oh ok ty
can anyone maybe help me? my problem is : await ctx.send(file = discord.File(fp="video/template.mp4"))
.what have i dont wrong?
can anyone remind me how to import function/class from my main file into a cog?
what the file structure
what do you mean?
how are you folders and files structured
is there a way to make a cooldown for one specific person on buttons lib is discord.py
I have main file for the main bot script and in a folder cogs I have my cog files
are both cogs and the main file in the same directory
yeah
thats why eval should ONLY be for the owner of the bot
@bot.command()
async def test_premium(ctx):
role = get(guild.roles, id=924915779835691008)
print(role)```
guild is not defined, and if i can, i also wanna get the example of `get()` usage ples
well the people that made this bot are on bigger brain
@languid wagon :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'token' is not defined. Did you mean: 'open'?
they probably secured it to another level
is there a way to make a cooldown for one specific person on buttons lib is discord.py
how do i make my bot send discord links?
🗿 just await ctx.send("link")
?
how would i make it so if a person clicked my button it's only disabled for that person
ctx.guild.roles
and did you directly import discord.utils.get?
cogs are in a folder main file is not but yes same directory
🗿 ?
can you still send your file structure? it will make it easier
now how to get persons that hav that role in my server
im frustrated rn because it says my db connection is established when i run the bot, and that connection is bound to my self.db instance variable, but when i try to do a transaction outside the bot file, it says no active connection 🗿
my ide always brings me back to that instance variable so i know that the connection is on that variable
could anyone help me with buttons :\
what about them
i want to make a cooldown for each person that clicks it
or better the button get's disabled after they click it
what lib are you using
you probably should use a fork instread of dpy for buttons and stuff
but do you have a idea on how to do it
yes
you can make a callback that sets the buttons disabled attribute to True
!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.
i only want it disabled for one person
async def swish(ctx:discord.ApplicationContext , namn: str, nummer: str , belopp: str):
interaction = await ctx.respond(f"Processing payment request from {ctx.author.mention} to {namn}. Amount: {belopp} .....")
msg = await interaction.original_message()
payment = utils.Payment(namn,nummer,belopp,msg.created_at,msg.id)
await msg.channel.send(file = discord.File(fp=payment.mp4))
payment.close()```
Whats wrong with my code?
I want it to be a custom image and custom text, number, name on it.
It does not send the image.
What can i do?
yeah disabled for the interaction user
you want to import from chatbot.py?
ApplicationContext is not a thing..
okay
its discord.Context
i am confused could you please show me a example
Instead you can make a turn variable when the turn is 1 when a certain person clicks it, it doesn’t work and says a message of some sort
yeah
nah just set disabled attribute to True
what should i do more? @slim ibex
i want to import functions from chatbot to utility file
from ..chatbot import your_function. i would put an empty __init__.py in each directory you make
the relative import might not work though. they never do
i got this error now
AttributeError: module 'discord' has no attribute 'discord
i am confused could you please show me a example
anyone mb help me?
two questions:
what adoes ..file do?
and mind giving an example on __init__ py?
.. goes two directories down from where it is being called
if it was ., it would search in the cogs directory
one second
u don't even need a dot then
an __init__.py file can be empty
but you can also import all names in that directory to that file to use them in __all__
!star-imports
Star / Wildcard imports
Wildcard imports are import statements in the form from <module_name> import *. What imports like these do is that they import everything [1] from the module into the current module's namespace [2]. This allows you to use names defined in the imported module without prefixing the module's name.
Example:
>>> from math import *
>>> sin(pi / 2)
1.0
This is discouraged, for various reasons:
Example:
>>> from custom_sin import sin
>>> from math import *
>>> sin(pi / 2) # uses sin from math rather than your custom sin
• Potential namespace collision. Names defined from a previous import might get shadowed by a wildcard import.
• Causes ambiguity. From the example, it is unclear which sin function is actually being used. From the Zen of Python [3]: Explicit is better than implicit.
• Makes import order significant, which they shouldn't. Certain IDE's sort import functionality may end up breaking code due to namespace collision.
How should you import?
• Import the module under the module's namespace (Only import the name of the module, and names defined in the module can be used by prefixing the module's name)
>>> import math
>>> math.sin(math.pi / 2)
• Explicitly import certain names from the module
>>> from math import sin, pi
>>> sin(pi / 2)
Conclusion: Namespaces are one honking great idea -- let's do more of those! [3]
[1] If the module defines the variable __all__, the names defined in __all__ will get imported by the wildcard import, otherwise all the names in the module get imported (except for names with a leading underscore)
[2] Namespaces and scopes
[3] Zen of Python
so you want me to make a file with the name __init__.py? Sorry I'm not good at these stuff
yeah its good practice to make one in each directory
ok
so then I have a function async def Button in my main file, in the cog I do from ..chatbot import button?
could you help me ik ur smart
no
:((
but I might be able to
i want to make a cooldown for each person that clicks it
or better the button get's disabled after they click it
for one person?
and i'm using discord.py
yes
@command()
async def some_command(your_params):
view = SomeView()
button = ButtonView("a_button")
view.add_item(button)
async def button_callback(interaction: MessageInteraction):
button.disabled = True
button.callback = button_callback
there is 100% a better way of doing this
make a petition
i believe you can do the callback in the view itself
make a petition for the Button's disabled attribute to take a BucketType
lets do it
how would this disable for one person just wondering
you cant just `disable` it for one person
^
letsgo
that's why we're making a petition
discord doesnt really care about what devs need
you would have to make a variable that includes people who pressed it already
and on_callback, you'd have to go through that variable and see
it's the only way
discord's developers also have good in their hearts
~~it's just deep down in overweight, but ~~it's there
if many people join our petition, we can do it
Anyone has a reddit meme command with buttons?
what?
just disable it for the person in the code
.
who are you making this petition to?
discord
but it'd be cool 
nah
you wouldnt even notice
5 people signing a petition is not enough for discord to do anything
@bot.event
async def on_reaction_add(reaction, user):
if reaction.emoji == "👑":
role = user.guild.get_role(947333237951315971)
wanted from office by reaction more not of the post
str(reaction.emoji)
!d discord.Member.kick
await kick(*, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Kicks this member. Equivalent to [`Guild.kick()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.kick "discord.Guild.kick").
Help me
property video: _EmbedVideoProxy```
Returns an `EmbedProxy` denoting the video contents.
Possible attributes include:
• `url` for the video URL.
• `height` for the video height.
• `width` for the video width...
no
iirc its a read-only property
yea nvm
you cant embed videos, its generated by discord E.g. Youtube link. The property exists to read that
Cirno here 👀
hi
🗿
yeah ^^
Imagine nitro still
cant live without it 
no, but you're the only one who rejected free nitro 
yo can anyone help me to embed a video?
I still remember that
U can't brub
you cannot embed a video? or what?
Yea u can't embed a video
okay i have a video how do i fix it to a gif?
Just search up mp4 to gif converter on google
how about to flex?
shard_count works with disnake too?
whats that?
Idk how to ;-;
nvm it works
!d disnake.ext.commands.AutoShardedBot.shards_count
wuts wut?
Meh bot broke
😂
does that even matter, it inherits from CLient
Ik, but sometimes it's worth trying
lemme show u
it is ijust found it
nah, inherited functions of classes aren't documented
um wouldn't this disable the button for everyone
So I have this code where if someone joins, the bot sends a message to a channel. The only issue is, if someone joins another server that the bot is in then it also sends a message even thought the user joined another server. How would I fix this:
@commands.Cog.listener()
async def on_member_join(self, member: discord.Member):
channel = self.bot.get_channel(935580211926405170)
if not channel:
return
await channel.send(f"Welcome to Galaxy Dankers, {member.mention}!")```
use member.guild.get_channel instead of bot.get_channel
so if the member is not for the guild the channel is in, the def will return
ok ty
how do we delete the commands "help" pre-existing on the system ?
in your commands.Bot add help_command=None
i have a cog folder, and in the cog folder I have a file x.py and y.py
If there is a function test in x.py, how do I import it to y.py?
is that commands.Bot?
np
ah okay how to import those then?
Use an ide or text editor with intelisense when you're importing
also, how do I check if a author is a bot in commands.Cog.listener('on_message')?
It will make your life so much easier
!d discord.Member.bot
property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
is this an extension?
gudyyhdhfd how get media link of gifff
i'm using visual studio code
?
like media link
It shows me all the files in the directory I'm importing from which is extremely useful
@slate swan also what's bad about having a file in a cog for your functions?
instead of making a seperate folder just for that one file
maybe this ig https://marketplace.visualstudio.com/items?itemName=christian-kohler.path-intellisense
if channel permission got true and false what is the normal one? like in the center thing
ur pfp is sexy lol
do all functions in cogs need to be self as first param?
yes
even this?py def cleanup_code(content): if content.startswith('') and content.endswith('```'):
return '\n'.join(content.split('\n')[1:-1])
else:
return content.strip('` \n')
hm
whoops it got messed up
um
i tried that but it reset whole permission
i tried to type X and it reset whole perm
Hey guys so i got stuck somewhere here
hm
await add_roles(*roles, reason=None, atomic=True)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gives the member a number of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this, and the added [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role")s must appear lower in the list of roles than the highest role of the member.

why not?
?
You're making a command to give yourself random roles
Extremely inappropriate
no no
Yes
thats not the main purpose of this command
hm
Sure
im mixing several commands into one command

can anyone help me?
will try
okay
And if someone gives the bot admin role?
Yeah they cant
Still cant assign roles that you have
yea thats how my frends server got nuked
@bot.command()
async def ping(ctx, self):
the_ping = client.latency * 1000
rounded_ping = round(the_ping)
embed = discord.Embed(title = "🏓 **Ping**", description = f"{ctx.author.mention} Ton ping est de {round(client.latency * 1000)} ms !", color = 0x9400D3)
await ctx.send(embed = embed) ``` Hello, i try to make a ping client commands, but there is a error in the code
nope
error?
missing args
that used to be a thing but you cant do that anymore @slate swan
sigh
what's the best way to make it so when a user clicks a button it get's disabled
only for that person using discord.py
remove self, ure not in a cog + its never the 2nd arg
ok
Bots can create roles...?
could anyone help me
thats dont work either
with?
same error?
It cannot
did u restart ur bot? show ur current code
no i have nothing like error just nothing happend
yup they can, never said they couldnt
I believe they can't give admin perms
what's the best way to make it so when a user clicks a button it get's disabled
only for that person using discord.py
@bot.command()
async def ping(ctx):
the_ping = client.latency * 1000
rounded_ping = round(the_ping)
embed = discord.Embed(title = "🏓 **Ping**", description = f"{ctx.author.mention} Ton ping est de {round(client.latency * 1000)} ms !", color = 0x9400D3)
await ctx.send(embed = embed)
@bot.command()
client.latency
no just nothing append
no error
it can give it provided the bot role is above the role you're trying to give admin to
dont see anything wrong tbh
Then why can't they create the role with admin perms and assign it?
@bot.command()
client.latency
so you are doing two of the same things?
whats ur commands.Bot variable called
rounding it in the embed and rounding it outside?
its bot
then bot.latency
u cant do that
oh ok, thank
I appear to be wrong
USERS can't make a role with administrator when they are an administrator
for some fuck all reason, bots can
Guys how i can make reboot bot command?
the ss of the code you sent does not match with the error
you cannot make a reboot command
Sad
The only good way to restart your bot is to shut it down and have your process manager handle it. You can shutdown your bot by running Bot.close().
Do use:
- run your bot in a process manager such as:
- systemd
- openrc (gentoo, devuan)
- runit (void linux)
- supervisord
- upstart (old ubuntu)
- docker
- manually reboot it
Do not use:
- a bash loop (it can eat your C-c by rapidly spawning python and if your bot fails it won't stop it from constantly failing)
- subprocess.call (you will eat your memory up by not letting your old processes die)
- os.exec*
u cant?
yeah i tried using './cogs' still is the same problem
so anyone can help me ?
you can, ?tag restart in the d.py server
can you? idk
can anyone help me with a problem involving buttons
Thank you very much❤️
yes ofc
do you have a cogs folder?
yep
👍
try running your bot again to see if you get the same error
same error
discord.py 2.0? anyways its not going to be disabled but if the user clicks the button it'll response with something like " you've clicked the buttons". just use something like ```py
user_clicked_button = []
user = ctx.author.id
if user in user_clicked_button:
await ctx.response.send_message("You've clicked the button")
show ss
hm
wrong screenshot
youre running some file named akiri bot.py
i just changed it
how is that related to this folder?
show the current dir then
isnt it still the same?
wait i just noticed my problem
doesnt matter what file you have opened, the folder needs to be inside the bot file's dir
im stupid i had the module installed
odd how it wasn't raising that error tho
my bot giving command not found exception on this cmd, but it alr runs the cmd ```py
@client.command(aliases=['swaggy', 'swagger'])
@commands.cooldown(1, 30, commands.BucketType.user)
async def swag(ctx):
await open_account(ctx.author)
swagger = ["Your fans give you $* for being a swag master."]
money = random.randint(100, 500)
await cluster.Botswag.Accounts.update_one({"_id": str(ctx.author.id)})
embed = discord.Embed(title="Swaggy Af",
description=random.choice(swagger).replace('*', str(money)),
color=discord.Color.green())
embed.set_footer(text="N.B. This command is under development. It may not work as expected", icon_url='https://cdn.discordapp.com/avatars/748609140896694394/216c2e4a3ab7574609c049a7d3ebbdaa.webp?size=1024')
await ctx.send(embed=embed)```
what not found exception? from your db or the discord module
anyone?
why would "X" be in a lower cased message
@bot.event
async def on_reaction_add(reaction, user):
if reaction.emoji == "👑":
role = user.guild.get_role(947333237951315971)
wanted from office by reaction more not of the post?
change it to "x"
discord module
ignore about that, the problem is when i say x it reset all of the perm role
its because you are completely overriding the perms, first, get the old permissions of the user, then apply the new changes on it
wouldnt the params be message, reaction
nah
how?
could you please elaborate?
!d discord.TextChannel.permissions_for
permissions_for(obj, /)```
Handles permission resolution for the [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role").
This function takes into consideration the following cases...
^^
can anyonew help me out?
whats your problem though?
i dont have like an problem but, i need help to code
the discord module is saying that the command is not found but still runs the command:
you have the bot running multiple times maybe
or is the command made using on_message event?
code what ?
im confused, what is obj and /
obj is basically the object you want to get permission for! , message.author in your case ( ignore the slash it means that it is a positional argument)
await message.channel.permission_for(get(message.guild.roles, id = theroleid) so it would be like this?
so you may get the message author's permission using perms = channel.permissions_for(message.author) , set send_messages =False perms.send_messages=False and use it as the permission in set_permissions
can I set sticker in embed?
no, and why would you do that
does anyone know why vs code returns this error File "c:\Users\lange\Documents\Python Bot\VibecordModmail\bot.py", line 7, in <module> from discord_ui import Button File "C:\Users\lange\AppData\Local\Programs\Python\Python37\lib\site-packages\discord_ui\__init__.py", line 34, in <module> from .client import * File "C:\Users\lange\AppData\Local\Programs\Python\Python37\lib\site-packages\discord_ui\client.py", line 1, in <module> from .cogs import BaseCallable, InteractionableCog, ListeningComponent File "C:\Users\lange\AppData\Local\Programs\Python\Python37\lib\site-packages\discord_ui\cogs.py", line 5, in <module> from .slash.types import BaseCommand, ContextCommand, MessageCommand, SlashCommand, SlashSubcommand, UserCommand File "C:\Users\lange\AppData\Local\Programs\Python\Python37\lib\site-packages\discord_ui\slash\__init__.py", line 20, in <module> from . import ext File "C:\Users\lange\AppData\Local\Programs\Python\Python37\lib\site-packages\discord_ui\slash\ext\__init__.py", line 13, in <module> from .builder import * File "C:\Users\lange\AppData\Local\Programs\Python\Python37\lib\site-packages\discord_ui\slash\ext\builder.py", line 4, in <module> from ..types import ( File "C:\Users\lange\AppData\Local\Programs\Python\Python37\lib\site-packages\discord_ui\slash\types.py", line 31, in <module> class OptionDataPayload(t.TypedDict): AttributeError: module 'typing' has no attribute 'TypedDict' when I add from discord_ui import Button to my code? (discord ui is installed)
do you mean emoji?
no sticker
then what sarthak said
for logging deleted messages
I'm using disnake
does discord py even support stickers?
2.0 does i think
maybe you can get the sticker's link and put it into the embed then
is there any thing like embed.set_sticker()?
no
then how
FileNotFoundError: [Errno 2] No such file or directory: './db/shop.jsonc'
``` what
Not possible
hey i tried to make an welcome event and when someone joins nothing happend
you have multiple instances of your bot running

do you have intents enabled?
yeah
heres the code
@client.event
async def on_member_join(member):
channel = client.get_channel(947526938577240095)
await channel.send(f'{member} has joined the server')
print(f"Welcome to city 17 {member}")
show the code then
whats your python version
im using pycord
just use the master branch or a fork mate
wait