#discord-bots
1 messages · Page 790 of 1
highly advertised and the name is pretty decent
cant talk about features cause there's nothing too amazing there
I think the name is just too shit
!pip pycord ,
imagine installing this instead of pycord
sad dpy noises
How do you even install pycord
!pip py-cord
wao
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...
no
Nobody is going to spoonfeed you code
read the description 
slow development/other better forks existing
!d asyncio.sleep would be better
coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.
If *result* is provided, it is returned to the caller when the coroutine completes.
`sleep()` always suspends the current task, allowing other tasks to run.
Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.
Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [What’s New in 3.10’s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.
Example of coroutine displaying the current date every second for 5 seconds:
No features and their slash command implementation is bad imo
Well, hikari is not a fork so it uses very different implementation. interactions.py is nice but lacking on their discord data models. last I checked pycord and disnake were almost the same but pycord seemed to move faster so I went with pycord
pycord initially started well
There is also nextcord which I also thought seemed like pycord but at slower development
member.created_at.timestamp()
Is this in seconds?
Yeah 😆 
...
It's in Unix time
How do I make it so it's Days?
!e
import datetime
print(datetime.datetime.now().timestamp())
@final iron :white_check_mark: Your eval job has completed with return code 0.
1643562077.934694
Convert the timestamp to days
How?
¯\_(ツ)_/¯
-_-
Does anyone know how to convert unix time to days?
!e
import datetime
import time
print(time.time() - timestamp() // 86400)
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | NameError: name 'timestamp' is not defined
nvm it's seconds -_-
time.time() - member.created_at.timestamp() // 86400
Will this work?
You tell me
!e
import time
print(time.time())
@slate swan :white_check_mark: Your eval job has completed with return code 0.
1643562606.7080872
You might be able to use strftime
!e
import time
print(time.time() // 84600)
@slate swan :white_check_mark: Your eval job has completed with return code 0.
19427.0
!e
import datetime
print(datetime.datetime.now().strftime("%Y/%m/%D"))
@final iron :white_check_mark: Your eval job has completed with return code 0.
2022/01/01/30/22
!e
import time
print(time.time().strftime("%Y/%m/%D"))
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | AttributeError: 'float' object has no attribute 'strftime'
Do you want to not allow those perms?
@slate swan
permoverwrite = member:discord.PermissionOverwrite(view_channel=True, connect=True, move_members=True, manage_channels=True, mute_members=True, deafen_members=True, manage_permissions=True, use_voice_activation=True)
I use this
@slate swan
@bot.command()
async def vouch(ctx, *, reason=None):
user, vouchs = reason.split(':')
message = await ctx.send("sending..")
time.sleep(0.3)
await message.edit(content="**vouch received!!!**")
vouch = 0
name = ("vouches.txt")
o = open(‘vouches.txt')
user = (f"{ctx.author.mention} vouched {user} reason: {vouchs} ")
vouchs += 1
print(f"{user} | {vouchs}")
o.write(f"{user}\n")``` I’m kinda dumb and bad at py
guys quick how can i download an attachment from a message to my device?
!d discord.Attachment.save
await save(fp, *, seek_begin=True, use_cached=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Saves this attachment into a file-like object.
thnx
How can i set if arg3 not "123" or "abc":
!or
When checking if something is equal to one thing or another, you might think that this is possible:
if favorite_fruit == 'grapefruit' or 'lemon':
print("That's a weird favorite fruit to have.")
While this makes sense in English, it may not behave the way you would expect. In Python, you should have complete instructions on both sides of the logical operator.
So, if you want to check if something is equal to one thing or another, there are two common ways:
# Like this...
if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon':
print("That's a weird favorite fruit to have.")
# ...or like this.
if favorite_fruit in ('grapefruit', 'lemon'):
print("That's a weird favorite fruit to have.")
isnt...
guys 
i need help
pls i beg u

damn
def check(r: discord.Reaction, u: Union[discord.Member, discord.User]):
return u.id == ctx.author.id and r.message.channel.id == ctx.channel.id and
str(r.emoji) in ["
"]
uh bruh how do i do the code thingy
What do you need help with? Don’t say you need help and not say what the issue is
uh true mb
well i need help with this code Below. so basically its for a message being sent. user types $RR and the game starts. Message with the
reaction appears. When this appears i want 7 memebers to react to it and all those 7 to be put into a list
def check(r: discord.Reaction, u: Union[discord.Member, discord.User]):
return u.id == ctx.author.id and r.message.channel.id == ctx.channel.id and
str(r.emoji) in [""]
i have put the unicode for the cat emoji dont worry about it. it just transforms into it in discord
why are you doing Union for the member and user objects
i used this of a doc in github. wanted to pick up the union but wasnt sure if it makes a diff
@slim ibex i have
if arg3 == 'free': and
if arg3 == 'free1':
how can i check
if arg3 not 'free' or 'free1':
should i remove like one of them and leave one in there?
does os.rename return the edited file
!d os.rename
os.rename(src, dst, *, src_dir_fd=None, dst_dir_fd=None)```
Rename the file or directory *src* to *dst*. If *dst* exists, the operation will fail with an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "OSError") subclass in a number of cases:
On Windows, if *dst* exists a [`FileExistsError`](https://docs.python.org/3/library/exceptions.html#FileExistsError "FileExistsError") is always raised.
On Unix, if *src* is a file and *dst* is a directory or vice-versa, an [`IsADirectoryError`](https://docs.python.org/3/library/exceptions.html#IsADirectoryError "IsADirectoryError") or a [`NotADirectoryError`](https://docs.python.org/3/library/exceptions.html#NotADirectoryError "NotADirectoryError") will be raised respectively. If both are directories and *dst* is empty, *dst* will be silently replaced. If *dst* is a non-empty directory, an [`OSError`](https://docs.python.org/3/library/exceptions.html#OSError "OSError") is raised. If both are files, *dst* it will be replaced silently if the user has permission. The operation may fail on some Unix flavors if *src* and *dst* are on different filesystems. If successful, the renaming will be an atomic operation (this is a POSIX requirement).
you want to check if the arg isn’t free or free1?
yes
yo @slim ibex u mind helping me with the code after u helped others? i also need a second person to try out the code with but if you cant its fine i totally understand 
dont work
can I see more code?
and I don’t think this is the right channel if it isn’t related to discord bots @slate swan
But I’ll help
ok
tq 
whenever u are ready
i can invite u to my server so we test it out there
if u comfortable with that
Does anyone know how to respond nothing to a interaction in disnake?
I could create interaction.send_message(content=''), but i think there's more proper way for it
do you not want the interaction to do anything? What do you mean by respond nothing
if arg3 == 'free':
free = discord.Embed(title=f"McBott")
await ctx.channel.send(embed=free)
if arg3 == 'free1':
free1 = discord.Embed(title=f"McBott")
await ctx.channel.send(embed=free1)
@slim ibex
i want the user to press multiple buttons before bot starting to respond
Right now bot starts to think for 5 seconds, and gives interaction failure
all work but i cant check if (“free”, “free1”) not in arg3:
An else statement should be fine
Because if the first two if’s aren’t true then it will run the else
and replace the second if with elif
I'm sure i need to respond with something here
if fixed
in other library, i had to respond with type 6,
!d disnake.ui.Select.min_values
property min_values: int```
The minimum number of items that must be chosen for this select menu.
@tidal hawk
async def vouch(ctx, *, reason=None):
user, vouchs = reason.split(':')
message = await ctx.send("sending..")
time.sleep(0.3)
await message.edit(content="vouch received!!!")
vouch = 0
name = ("vouches.txt")
o = open('vouches.txt')
user = (f"{ctx.author.mention} vouched {user} reason: {vouchs} ")
vouchs += 1
print(f"{user} | {vouchs}")
o.write(f"{user}\n")```
It’s not sending vouches to file
@slim ibex yo btw i cant send you a message in dms to invite u to my server. accept my friend req
nvm u have to add me as friend cause i cant send u a req
because you arent opening the file in append/write mode and also, time.sleep may break your bot
Sleep doesn’t affect it + write should work
but you are opening the file in read mode
sleep does affect it
Can disnake respond to context command with ephemeral true?
time.sleep isnt async and will stop your whole code
no you can only send ephemeral msgs on interactions
:(
¯\_(ツ)_/¯
going to use slash commands then
Damn whoever recommended disnake to me.. I love you.
👁️ 👁️
welcome to the disnake gang, we will turn every pycord user to a disnake lover
lmao
lmao😂
how do i code in jobs to my discord bot? im very new to python and i only watched a 1 hour tutorial
I would recommend learning python before you tackle discord.py
youll need to have intermediate python, oop and asynchronous programming knowledge
What's the best reliable bot hosting service out there?
And why everybody hatin' Heroku
I think this interaction is brand new
i know, is there a library for it yet?
Look's like Select but not sure how those keywords are in Computer Science
Pycord has them, it is a select with multiple select options
Vultr
I top that, I have been using Vultr for a long time now
although I have heard about them being a little overpriced
I recommend their 5 dollar plan either way
it isnt just made for hosting bots
Vultr does require some setup and minimal Linux knowledge if you deploy to a Linux server
you can get a decent vps for 3 dollars too
can i dm someone my code and the problem that pops up cuz im over the character limit
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.
ok
No clue how to get those things in computer science
pYcOrD
you reduce the message length, easy
Can you be more specific?
import discord
from discord.ext import commands
import json
import os
cmds = commands.Bot(command_prefix = "%")
@client.command()
async def balance(ctx):
await open_account (ctx.author)
async def open_account(user):
users = await get_bank_data()
with open("mainbank.json", "r") as f:
users = json.load(f)
if str(user.id) in users:
return False
else:
users[str(user.id)]["wallet"] = 0
users[str(user.id)]["bank"] = 0
with open("mainbank.json", "r") as f:
json.dump(users,f)
return True
async def get_bank_data():
with open("mainbank.json", "r") as f:
users = json.load(f)
@client.event
async def on_ready():
print("Bot is gay.")
await bot.change_presence
(activity = discord.Game)
@bot.command(description)
why doesnt it work it returns import discord
from discord.ext import commands
import json
import os
cmds = commands.Bot(command_prefix = "%")
@client.command()
async def balance(ctx):
await open_account (ctx.author)
async def open_account(user):
users = await get_bank_data()
with open("mainbank.json", "r") as f:
users = json.load(f)
if str(user.id) in users:
return False
else:
users[str(user.id)]["wallet"] = 0
users[str(user.id)]["bank"] = 0
with open("mainbank.json", "r") as f:
json.dump(users,f)
return True
async def get_bank_data():
with open("mainbank.json", "r") as f:
users = json.load(f)
@client.event
async def on_ready():
print("Bot is gay.")
await bot.change_presence
(activity = discord.Game)
@bot.command(description)
client.run("my bot token")
oops sorry
Disnake don't have those yet, but tbf pydis prob rushed those multiple select view anyways.
!codeblock
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.
9 times
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.
guys
Where? You just send those whole class.
i need help with something
do not ask to ask
Refer to that same message.
You are giving me a whole class, do you got something specific?
nvm i found it.
I was asking about the multiple options section.
print("ratio + didn't ask")
?
Can you run multiple bots on 1 plan?
@slim ibex
yes
i believe so
i got a free $100 dollar credit which is more than enouugh for many bots
what site?
like most sites have "starts credit" to work with, but this expires within a set period of time ofc
Yea I also got those $100, it expired after 30 days, so about over half a year ago
x)
and yes you can
I have 6 months left on the free AWS EC2 trial
but my bot is private, so I don't have to worry about usage etc
although I am not sure about scaling up
I only make bots for my servers, I have about 4/5 bots running at the same time together with a radis db
this is what you get with 5 dollars
I'll only ever pay for a hosting service if it generates income for me
what's the download speed like?
Does anyone know why my image is being sent separate while it should be in the embed as a thumbnail?
import instaloader
import discord
from discord.ext import commands
import os
client = commands.Bot(command_prefix='.')
@client.event
async def on_ready():
print('bot ready')
@client.command(name='user')
async def get(ctx, username):
l = instaloader.Instaloader()
profile = instaloader.Profile.from_username(l.context, username)
l.download_profile(username, profile_pic_only=True)
for filename in os.listdir(username):
f = os.path.join(username, filename)
if f.endswith('.jpg'):
break
print(f)
embed = discord.Embed(
title = f'@{username}',
color = discord.Color.purple()
)
file = discord.File(f, filename=f)
embed.add_field(name='User ID', value=profile.userid, inline=True)
embed.add_field(name='Followers', value=profile.followers, inline=False)
embed.add_field(name='Following', value=profile.followees, inline=False)
embed.add_field(name='Posts', value=profile.mediacount, inline=False)
embed.set_thumbnail(url=f'attachment://{f}')
await ctx.send(embed=embed, file=file)
It should look like this
set_thumbnail(*, url)```
Sets the thumbnail for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the thumbnail.
I am right
you are indeed
So I don't know what's going on haha
does disnake.FFmpegOpusAudio.from_probe accept file paths?
besides whatever is going on, your download code is blocking
and it's also not that useful to save that image, as you only have to send it...
Eh, it is alright, never had it be an issue
5 dollars is cheaper then Netflix, but I get more out of running my bots then watching Netflix
so to each their own
¯_(ツ)_/¯
what has that have to do with each other?
Yeah ur right
But scraping the image url from an instagram page seems kinda complicated lol, but I'll try
just look for an async wrapper or run the blocking code in executor
As in I enjoy minor devops and bot coding as hobby, and I get fun out of it
I get that, you just rather code and spend money on that than do nothing and spend money on a streaming service
Yup, pretty much x)
Do you guys earn money by creating bots?
You can integrate websites with python bots as well why not
API generally
mhmmh
I mean if the website & bot is in same language, it's bit easier to integrate them with eachother
Maybe you are right in some terms
But imo python bots are more convenient to write than nodejs
Mhm
What site
Totally, there are different options for that. Personally I use screen multiplexer which is really easy
vultr
Heroku 😋
Oracle free tier
You get like 4 cores and 24gb of ram
What the heck
I just got 8gb ram server on digital ocean for free xdxdxdxd
For 2 months
How long does it last?
guys
!e
!eval [code]
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
nvm
Idk
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
It's very much against discord tos
i do this on my own risk
i know they are against tos
but is not for something bad
i just tryna create a loop
We still don't help with them here
remove bot = False
you don't get it, do you
selfbots are against ToS and pretty useless if you'd ask me
Yep, that is how everyone keeps getting scam messages
The only thing they could "exploit" is other bots systems
and you could bump your server with it every 2 hours on disboard
still not useful
I find that useful
They can scrape member lists
I mean, to someone with good intentions they are useless
imo
Selfbot with AI chatbot embedded is interesting tho 😏
lmao
You know something I have always wanted to find but every time I looked for it I would only find SelfBots
BotSelfs
The only fun thing about selfbots is you can send embeds from non bot account
still not useful
that is sometime I would like to find on github
if you're famous and you wanna answer everyone without answering anyone
I never said it's useful 🙄
in that case, you have managers lol
u give them your account?
why would you even want to answer everyone if it isn't coming from you?
I once made a simple AI responder for a bot but it went aids
tell them to speak to someone else
happens all the time, especially with posting content to prevent getting "cancelled"
lmao, that's pretty much a voicemail
but on your own account cuz people are dumb enough to message you
you can always try
why are we talking about the priorities of something illegal
Like where people make interfaces to talk through a bot
oh
well I've seen one of those but idk how he did it
and I think it's just as much against ToS as selfbots
I never found anyone saying that it is against ToS
did you find anyone talking about it
also It doesnt make much sense for it to be against ToS, because there is nothing privileged about a bot
it's free nitro
yep, free nitro in all the servers you are admin sure
You cant even join servers without people adding you
Would be a pretty pathetic nitro experience xD
well
no idea how their detection system works, but I wouldn't like to be the one to find out
sending embeds
oops
got his account terminated in a day
I think
not sure, his name still appears
Can't you do that with also tos breaking alternative clients?
no, his account still exists
Like better discord
did you say that cuz of my screenshot
Yeah
damnit
What? xD
nobody has to know
can't discord sue betterdiscord?
don't you need an API key for that
idk
ytdl breaks youtube TOS
I think pydis is trying to strain the use of ytdl as much as possible
!ytdl
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
you can't download videos with the youtube api
ytdl breaches ToS
yeah, i know
why do people even use it
because it lets them download videos
😂
👀
NO
lmao
The mods are always watching 
stalkers
Nah jk.
we both exposed ourselves now, didn't we
my personal space 😠
how dare thou
you're on a public server
oh
I should call the "see it, say it, sorted" lmao
You do but you get it for free from google
It has a normal limit
Iirc 10k queries per day
Does anyone know how to make the title in an embed a hyperlink (url)?
@client.command(name='user')
async def get(ctx, username):
r = requests.get(f'https://www.instagram.com/{username}/?__a=1')
embed = discord.Embed(
title = discord.Embed(title=f'{username}', url='www.instagram.com'),
color = discord.Color.purple()
)
embed.add_field(name='User ID', value=r.json()['graphql']['user']['id'], inline=True)
embed.add_field(name='Followers', value=r.json()['graphql']['user']['edge_followed_by']['count'], inline=False)
embed.add_field(name='Following', value=r.json()['graphql']['user']['edge_follow']['count'], inline=False)
embed.add_field(name='Posts', value=r.json()['graphql']['user']['edge_owner_to_timeline_media']['count'], inline=False)
embed.set_thumbnail(url=r.json()['graphql']['user']['profile_pic_url_hd'])
await ctx.send(embed=embed)
!d discord.Embed.set_url
!d discord.Embed.url
The URL of the embed. This can be set during initialisation.
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: type object 'Embed' has no attribute 'set_url'
Simple markdown
(text)[https://example.com]```
I am pretty sure you can use it there as well
Yeah check it please I can't myself
let me check
if it does not
.
How to fix the error when leaving the voice channel
embed = discord.Embed(
title = discord.Embed(title=f'(text)[https://instagram.com]'),
color = discord.Color.purple()
)
!e
embed = discord.Embed(title='(gogel)[https://google.com]', description='Sample text')
await ctx.send(embed)```
@vale wing :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | SyntaxError: 'await' outside function
what am i doing wrong ://
there's no such thing as a channel for a member
maybe after.voice.id?
I thought you can eval async code can't you 🤨
Or I did something wrong
you can't
You need to provide a string into the title param, not a whole new embed lol
Then the private channel is not created
Um what args does that event even accept
What do you mean? Sorry I'm confused
embed = discord.Embed(
title = discord.Embed(title='(google)[https://google.com]', description='Sample text'),
color = discord.Color.purple()
)
Is this still wrong?
When a person enters the voice channel, the bot should create a voice channel with the name of the author and move it there
after and before
disnake
embed = discord.Embed(
title='(google)[https://google.com]'
...)```
!d disnake.VoiceState
class disnake.VoiceState```
Represents a Discord user’s voice state.
Then why does he have argument eater between them
!d discord.on_voice_state_update
discord.on_voice_state_update(member, before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") changes their [`VoiceState`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceState "discord.VoiceState").
The following, but not limited to, examples illustrate when this event is called...
Ok nvm
I don't see his params
not voice, but channel
Is there a way to code a discord bot to search a website for somethin? For example Im coding a bot for an equestrian server, and one of the things we want is have a command where we put the name of the racehorse we want searched, and it comes up with information or a link to that horses page on the website equibase
I see, I thought you used dpy
API
urllib good
Maybe someone knows how to fix this?
if after.channel == None:
thanks you
can someone link me to the dpy docs on chunk_guilds_at_startup as i can't seem to find them
never heard of it
Uhm this looks like bot constructor param maybe check it?
Yeah it is a bot constructor param but i can't seem to find it which is weird since i've seen it before
!d discord.ext.commands.Bot
class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.
This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.
This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
it's not there
How could I bass boost input in vc from my bot?
couldn't sound more like a music bot
Bass boost a song

what does courotine mean
Is it an ffmpeg option?
async functions
oh ok
!rule 5
5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.
^^
accusations passed
I got some non copyright songs downloaded on my pc, and want to bass boost them
Well it's about a discord bot...
I don't know what I should use to bass boost it
It might've been an option in discord.py, idk
!d discord.FFmpegAudio
class discord.FFmpegAudio(source, *, executable='ffmpeg', args, **subprocess_kwargs)```
Represents an FFmpeg (or AVConv) based AudioSource.
User created AudioSources using FFmpeg differently from how [`FFmpegPCMAudio`](https://discordpy.readthedocs.io/en/master/api.html#discord.FFmpegPCMAudio "discord.FFmpegPCMAudio") and [`FFmpegOpusAudio`](https://discordpy.readthedocs.io/en/master/api.html#discord.FFmpegOpusAudio "discord.FFmpegOpusAudio") work should subclass this.
New in version 1.3.
no bass kwarg or anything
I see
I found this on google: https://stackoverflow.com/questions/39607741/ffmpeg-how-to-reduce-bass-and-increase-treble-like-audacity
oh well ask that somewhere else now
Yh indeed
so I tired following a youtube tutorial to make a bot but it doesn't want to run at all and won't let me name the secondary file .env
Pretty much same. I got a public discord bot almost ready for launch
seems like a youtube tutorial of 2014
url kwarg, not file
youtube tutorials suck
i'm screaming at the screen because of the lack of PEP8
how to attatch a file then
well I don't use pep8 either, I've got my own habits
how to set image as a file
!local-file
Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:
# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
file = discord.File(f)
When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.
discord.Embed instances have a set_image method which can be used to set an attachment as an image:
embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png") # Filename here must be exactly same as attachment filename.
After this, you can send an embed with an attachment to Discord:
await channel.send(file=file, embed=embed)
This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.
SORRY
don't be sorry. moai is here
I'm a beginner with a year of experience
Ffmpeg is a tool for working with audio files
save it
so what should I input?
add a filename kwarg to the discord.File()
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")
embed.set_image(url="attachment://file.png")
ohhh ok
like this
github would have it work properly I assume if this other site isn't going run it
the .env was to keep the token private ^^
this seems exactly like it
perfect thanks
👍🏿
how to mention in embeds
i tried {member.mention}
but it just shows the @ plus the id
ripppppp
Mentions will render in the embed description or field values but they won't actually ping
oh no this a test , in the actual one its on an on_member_join event
also i get this error
what's not clear about the error?
ctrl+f on that, people who have seeked help previously about this topic probably do
uh i dont know how to display the number of members in the guild
isnt it member.guild_count
where would the logic be in that? the attribute name makes no sense
close
property members: List[discord.member.Member]```
A list of members that belong to this guild.
no it used to work
it's because you forgot something
property member_count: int```
Returns the true member count regardless of it being loaded fully or not.
Warning
Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires [`Intents.members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.members "discord.Intents.members") to be specified.
member.guild**.member**_count
oh
makes more sense, right?
Hi, a quick question, how can i async my youtube downloads in pytube?
like i am trying to download a couple of videos from a playlist but it keeps blocking my bot from responding to other commands
Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.
For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:
The following restrictions apply to your use of the Service. You are not allowed to:
1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service; (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;
3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;
9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
alr, thanks for responding
how can I check a user for a sertain role in a role list? But also return the sertain role?
I tried doing
if author.roles in info.roleList:
but when I have role names in roleList, it doesnt work. But if I have role objects, I just get a syntac error.
Loop through the list and compare
!e
author_roles = ["a", "b", "c", "1"]
roles = ["j", "1", "b"]
for i in author_roles:
if i in roles:
print(i)
@final iron :white_check_mark: Your eval job has completed with return code 0.
001 | b
002 | 1
!e ```py
roles1 = set([1, 2, 3])
roles2 = set([2, 3])
print(roles1.intersection(roles2))
@pliant gulch :white_check_mark: Your eval job has completed with return code 0.
{2, 3}
You can use set here because it's 100% that a member does not have the same role twice
alright, so where are you getting the role from
are you just hardcoding?
if so
role_id = ...
await message.channel.send(f'<@{role_id}>')
OK thanks
!d discord.Role.mention
property mention: str```
Returns a string that allows you to mention a role.
Another way to do it is <@&role_id>
im confused on how i can apply sets to my code
I construct the set's with a list for each one. You can imagine the lists instead has the roleList and roles in your situation
OH yeah my bad, it would be f'<@&{role_id}>'
still confused ;/
Same thing up here, just construct the sets with your list of roles, e.g author.roles and info.roleLIst
so would roles1 be author.roles? or info.roleList?
You'd check the intersection on the info.roleList to author.roles
so like
returnedRole = info.roleList.intersection(author.roles)
?
you need to actually construct the sets
so
authorRoles = set(author.roles)
roleList = set(["member", "moderator", "verified"])
returnedRole = info.roleList.intersection(authorRoles)
Your checking the intersection on info.roleList, not the newly created set roleList and your roleList is a set of strs, not a set of discord.Role objects which is what author.roles is
Once you fix those two it will capture the intersection of the two sets into returnedRole
so returnedRole will have any roles that are in both lists?
also, i get a syntac error when i try to put role objects in a list
Yes.
Can you show what info.roleList is
alr, ty for the help 🙂
sure
roleList = [<Role id=926477597355962401 name='member', <Role id=926477597372727374 name="mod"]
it looks like that. I got this stuff from this command
@client.command()
@commands.has_permissions(administrator=True)
async def roleINFORMATION(ctx, type=None):
client.memberList = []
await ctx.reply("Working...")
amount = len(info.roleList)
i = 0
for i in range(0, amount):
try:
role = discord.utils.get(ctx.guild.roles, name=info.roleList[i])
except:
await ctx.reply("You are missing some roles... Please fix them, then redo the command.")
return
client.memberList.append(role)
i = i+1
await ctx.reply(client.memberList)
Ok, so info.roleList is a list of role objects. Just construct your set with info.roleList like how you did with the author.roles
then check the intersection of info.roleList to the other
but i cant even run my code...
when I try to run it says that the line that roleList is on has a syntac error
Can you show the error
SyntaxError: invalid syntax
kk
hey, could someone explain to me why my code cant load the file commands.py?
this is my main.py file
if __name__ == '__main__':
for extension in extensions:
try:
bot.load_extension(extension)
except Exception as error:
print(colored(f'{format(extension)} cannot be loaded. [{format(error)}]', 'red'))
and my commands.py file
class c_cog(commands.Cog):
def init(self, bot):
pass
# a lot of code and commands...
# ...
def setup(bot):
bot.add_cog(c_cog(bot))
first off, follow naming conventions
^
class names should be in PascalCase
pep8 is coming to get you
but all the other cogs/files works perfect, just having problem with this one
the officer is here!
Don't use bare exceptions!
^
pep8 says thats a nono
its
def __init__(self, bot):
self.bot = bot
I have tried that also but it didnt work either
your init method isn't even dunder
or magic method
I have the code for an API, but im confused on how I make the command to search using the API?
youll have to make a request to the api
GET request
you can use aiohttp for it
and Im using this same way in all my other files for different commands, it works perfect at all those places...
Then you're developing bad habits which is very very bad
holy the whole squad showed up
things working perfectly doesnt mean it can be good
code that works isn't always code that is good
^ theres always something better you can do with it
depends on the commands even if your the owner of the guild it wont affect any command only if theres something in it that will
yeah of course there will always be something better, this was just the way I was learned to do it and that's the reason why I did it in this way. but if this is wrong I will try to change it
It is wrong
ok so cuz i couldnt send the whole list, here is just one of them in a variable
C:\Users\toren\OneDrive\Desktop\newCode>python main.py
Traceback (most recent call last):
File "C:\Users\\OneDrive\Desktop\newCode\main.py", line 12, in <module>
import info
File "C:\Users\\OneDrive\Desktop\newCode\info.py", line 17
role1 = <Role id=926477597355962401 name='member'>
^
SyntaxError: invalid syntax
!pep8 check it out
PEP 8 is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide.
More information:
• PEP 8 document
• Our PEP 8 song! :notes:
and hey andy
...
?
hi
I'm so confused as to what you are doing here. Just construct your set with the info.roleList variable you have
but i cant even run my code, due to the error
so delete roleList?
i get same error with roleList
Can you show your roleList again
Cause for whatever reason, it changed from the one you showed me before apparently
roleList = [<Role id=926477597355962401 name='member', <Role id=926477597372727374 name="mod"]
how?
Oh wait that isn't the repr of the role
You copy pasted the repr in roleList instead of having actual role objects.
You need to make roleList have ACTUAL role objects
Once you do that, construct the set then check the intersection
??? they are the actual role objects... at least i think so, i get them from this cmd
@client.command()
@commands.has_permissions(administrator=True)
async def roleINFORMATION(ctx, type=None):
client.memberList = []
await ctx.reply("Working...")
amount = len(info.roleList)
i = 0
for i in range(0, amount):
try:
role = discord.utils.get(ctx.guild.roles, name=info.roleList[i])
except:
await ctx.reply("You are missing some roles... Please fix them, then redo the command.")
return
client.memberList.append(role)
i = i+1
await ctx.reply(client.memberList)
Please read over pep8
ok
Function names should not be in camelCase, they should be in snake_case
use the name kwarg if you want to name your commands that way
Same thing for variables
Wdym they are role objects... Look at this snippet you sent
i dont fucking care, dont tell me that
now im confused
i dont fucking care, i prefer camel case
its faster tto type
they just said that in a normal way, why do you need to be so toxic
Whats to be confused about? You just need to make roleList have actual role objects. You did something weird and copy pasted the repr's of some roles into the list.
reprs are representations of an object. Not the object itself
- your making me confused about the role object stuff
- so i need to do
role = ~~~~~that stuff?
and if so, how do i hard code that in?
don't make the pep8 officer mad
When a user has a default avatar it returns None
For an example, role = guild.get_role(123) here, role has captured an ACTUAL role object. not <Role, ...>
Member does not have a avatar , use member.display_avatar maybe
Consider using display_avatar instead as it will always return an avatar
so then why when i print role i get the <Role, stuff?
!d disnake.Member.display_avatar
property display_avatar: disnake.asset.Asset```
Returns the member’s display avatar.
For regular members this is just their avatar, but if they have a guild specific avatar then that is returned instead.
New in version 2.0.
That's the representation, print will send the return of __str__ or __repr__ in that order. Again > reprs are representations of an object. Not the object itself
andy is so smart smh
now im even more confused ;-;
disnake/role.py lines 211 to 213
def __repr__(self) -> str:
return f"<Role id={self.id} name={self.name!r}>"```
Have you learned the basics of object oriented programming?
i dont use disnake
It's the same
Doesn't matter ,it's same.
no idea what that is
...
what? i was never told i needed to learn it
It's one of the fundamentals needed for discord.py
It's basic python, not limited to discord.py
^
python is based on objects
...
well i never learned that stuff in my python class, my online or in person classes
-_-
....
!e
print(type("a"))
what was that even supposed to imply?
@final iron :white_check_mark: Your eval job has completed with return code 0.
<class 'str'>
nvm, goodbyue
See, object
this dude
I don't think he learned the fundamentals
Atleast they may try to learn it after being asked to :)
I doubt it, barely anyone actually does. I understand why, you don't want to go back to learning basics after you tasted the sweet nectar of an interesting project
It's understandable but people should actually try
its ok if they dont master it, but having a basic idea is always good
I have downloaded dotenv multiple time
can someone help me here
Why do you need it?
You don't need it
oh
okay
only replit does since its public
and you should use the bot framework
meh you dont require that even in replit
just use os.getenv
or os.environ
yeah
Tell them to join this channel
State your issue, any errors and what you need
and your code
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.
do homework like me
I only have a group project
And my group members are being (redacted) and not working
Refactor my discord APIs event parsers, they are kind of bland
I think thats a bit too complicated for me
Can someone please help me
Don't ask to ask, just ask
So I have this error in my bot project it says couldn’t find module when i literally put the module as what I should put
@final iron
Wrong server
We only help with Python code
!guilds
Communities
The communities page on our website contains a number of communities we have partnered with as well as a curated list of other communities relating to programming and technology.
Oh
Both
This channel died hard
always does at this time
Mind helping me?
feel free to facepalm but I'm new at discord.py and I want to make a command which reads values, how do I do it?
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
You'd have to use that ^, input() won't work for a discord bot
thanks
Cannot have install fields on a private application what does that mean
its on the discord dev/app portal for my bot
Mind showing?
You have to remove your “add server” first before setting to private
thank you
which library
discord-components
user discord.py beta and use views
that library will stop working soon
as discord.py will be dead
i just wanna know can i increase width of my embed?
why?
@client.command()
async def pdoubles(ctx):
mc = Image.open("teamcard.png")
font = ImageFont.truetype("playfair-font.ttf", 55)
channel = ctx.author.voice.channel
members = channel.members
memberlist = []
for member in members:
memberlist.append(member.mention)
random.shuffle(memberlist)
team11 = memberlist[0:1]
team12 = memberlist[1:2]
team21 = memberlist[2:3]
team22 = memberlist[3:4]
draw = ImageDraw.Draw(mc)
draw.text((48,106),f"{team11}",(220,20,60),font=font)
draw.text((290,313),f"#",(220,20,60),font=font)
mc.save("profile.png")
file = discord.File("profile.png", filename="nice.png")
embed = discord.Embed(title=f'Welcome',description=f'{ctx.author}', colour = discord.Colour.green())
embed.set_image(url="attachment://nice.png")
await ctx.send(file=file, embed=embed)
why doesnt this send the embed
How come this no work? I wanna announce a gg message everytime we get 100 members.
So 1000, 1100, etc.
First of all
[member.mention for member in channel.members]
is it possible to have to prefixes ?
for one bot
like +one, -one
U can pass in a list to command_prefix
How good are you with bot code?
You can ask yr question directly (:
Well I was trying to make a command like when I invoke it, the bot sends a dm to the owner of every guild my bot is in containing my message and I’ve tried so many things and none of them worked and now I’m just looking to see if anyone knows code for one…
property guilds: List[discord.guild.Guild]```
The guilds that the connected client is a member of.
!d discord.Guild.owner
property owner: Optional[discord.member.Member]```
The member that owns the guild.
i need help w this
If the owner is returning None, then that means that y need members intent
The token is wrong
i regened
!pypi python_dotenv
copied
Use the load_dotenv() method
This is what i got ```py
@commands.is_owner()
async def broadcast(ctx, message):
for guild in client.guilds:
# get the owner of guild
owner = guild.owner
# check if dm exists, if not create it
if owner.dm_channel is None:
await owner.create_dm()
# if creation of dm successful
if owner.dm_channel is not None:
await owner.dm_channel.send(message)
for channel in guild.channels:
if channel.name == 'general':
await channel.send(message)
i install module?
Just do
for g in bot.guilds:
await g.owner.send(...)
Yea, the python_dotenv one
k
Do you have them defined?
It takes about an hour for them to get registered
What program you using?
Then what's the issue
i installed the module but when i import, it shows eror
The is_me func isnt checking any condition?
Nope still won't work
Of course, it has to, dude
also can u tell me how to use python_dotenv, i dont really understand, like am i just supposed to add load_dotenv to my code?
members intent?
i tried to import, results in an error
!pypi dotenv
Yeah, check the ids
from dotenv import load_dotenv
load_dotenv()
As long as it's returning True, no need to add any other thing tbh
If he doesn't wanna check anything
Might as well remove the check
Still won't work
Yea changed the code
mind printing g.owner?
what if the dms are closed or the bot isnt in any server
its not about the guilds
its about the client/bot
he is looping through bot.guilds, so only the first part applies
wym
from dotenv import load_dotenv this is the correct usage
all i can say is most of my code is kind of messy and rn it says bot is not defined when it is
still shows
Sad
ok
Restart Vs Code
Uhh, self.bot.guilds then
Since u r in a cog
now it says self is not defind when it is :/ I'm just unlucky
Thats strange .... it works fine for me
ye it probs is
Are you using some virtual environment
i had the same problem with requests
do u mean vm?
No
then'?
!d venv
New in version 3.3.
Source code: Lib/venv/
The venv module provides support for creating lightweight “virtual environments” with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (which matches the version of the binary that was used to create this environment) and can have its own independent set of installed Python packages in its site directories.
See PEP 405 for more information about Python virtual environments.
p sure im not using that
Have you tried running it? Maybe it's the ide's bug
guess it isnt
What code do u have?
should i share main.py here?
No need
Just DM me it bc that happened to me before
can you try using pip list and see if dotenv is in there?
install it then
also im using discord.py, should i just change to pycord
pip install -U dotenv
discord py is not maintained anymore so yeah use some other lib/fork
Huh
ok wait now dot env is there
and it's working?
nope
dont understand this anymore, pip list shows python_dotenv and this shows no module named python_dotenv
Are you in venv by any change?
no
Correct python version?
3.9?
Have you restarted the vsc?
yep
Weird
You have the dotenv in the wrong place then bc when i had this i just kept moving the dotenv file till i got it right
have it in same dir as main.py
wait do u mean the dotenv file? where am i supposed to check that
or the env file where the token is
Well, the error says that dotenv is not installed, it doesn't have anything to do with the env file you have
pip list shows dot env is there
And what did you install?
!pypi python-dotenv
This one?
yep
done it 2 times
And restart vsc
@burnt heath
Oh
yes
You got more than one Python versions?
Control Panel
yeah i hve 3.7
3.9
There the issue is
Does it fail to respond?
Try running python -V in the cmd prompt
oh frick
There (:
ahhhhh
Now do py -3.9 -m pip install python_dotenv
Hmm, try using dummy prints and see where the error is
Who would have guessed about two Python versions
tysm @maiden fable
(:
The Hunter
BTW uninstall Python 3.7 since its more or less dead (according to me at least)
Just a usual thing 🤷♀️
yep that works yet my final issue isnt resolved, still got about 200more errors to fix
Painful
Its now saying Self is not defined when it is
At least the token issue is fixed
Sup everyone
Lmao Python got a stroke ig
Show a screenshot of the whole cog
self*
idt u can help with this?
the token is wrong
regen token and put it?
Google uses robots to make sure you are not a robot
true
ok
You buy a better GPU for yr laptop/computer just to see the colors on yr screen sharper and faster
the token error got fixed but this.
p sure
it gives Unauthorized,so i bet he didnt even pass it
there must be 2 periods in it
He did, its a required arg
there arent
how am i supposed to get it right, i put what regened token gave
From where u regened
Mind showing a pic?
that's client secret most likely
Ah thought so
wait
Hahaha
im not supposed to do from there lmao
ty
Whole code was the link sent to you which leads to codeshare:/ .......
Anyone else here got this except me?
!paste please use this
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.
i got it too
Verified Bots ^^^
Everyone has it



