#discord-bots
1 messages · Page 903 of 1
yea
Theres no ()
No parenthesis for that decorator
Bad news for ya m8
Uh
If I remember correctly, the devs of that package changed the name
To?
They had a massive overhaul and changed the entire package
So how do I get slash commands to work lol
try discord-interactions-py on pypi
No point of using an external slash library anymore
So you have a couple options. Either use the old old version of that package which they've discontinued support for, use their updated package or just use discord v2 I think
Dpy 2.0 has pretty easy / commands, else use slash_util
slash_util was featured by dpy community before dpy 2.0 got resumed
Think I switched to nextcord like 2mths ago. Thankfully, it's 99.95% the same syntax and it installs discordv2 along with it I think
So I'm good
Yeah
is there a methode to host my disocrd bot with my old mobile phone?
host.....method....?
oh nvm
Use dpy 2.0 or its fork
many people host their bot on their pc but i want to do this with my old phone
Who are those many people lmao
PC is not suitable for hosting unless you leave it on 24/7
VPS is the best option
replit is good but you also can't host it 24/7
Replit is bad
replit ew
is it free?
Most of them no but you can get free credits
How then? Can you send a link
can you send a link of this thing`?
!pypi disnake for example
thanks
isnt dpy ending
there is
d.py's application commands are not stable yet
Got resumed
How do I implement slash commands then?
That's true, but I would still recommend slash_util. It was featured by dpy when it was down
use either
stable: use slash_util
unstable (d.py): https://gist.github.com/Rapptz/c4324f17a80c94776832430007ad40e6
will be stable
"will" :)
dpy has always had the best quality by far
I don't even think it will take much time
Danny's gotta catch up aswell after that drama
and how original the dpy devs always are
I love it
True
Yes
which?
Is it an android?
Ok, so you need to use:
Termux (download from F-Droid, not play store)
A GitHub account
That's about it.
Also probably a code editor just incase, I'd say probably Acode
Damn i didnt know dis

thats it? sounds easy
Yes along with a power adapter and internet connection
Once you have them, open Termux and do the following in order:
termux-setup-storage (press allow when it pops up)
termux-change-repo pick grimler
pkg install build-essential (if it fails, it's build-essentials idk it's one of the two)
pkg install python
pkg install git
of course
Get to there then lmk, don't want to overcomplicate it to all fuck right off the bat
Also I recommend making a folder in your phone titled bots just so you can put the code there
Once you have all of them,
You need to setup git to actually get the files from whenever you edit the code on presumably a pc.
To do that, it's this
git config --global user.name "username"
git config --global user.email "example@example.com"
discord.Attachment maybe?
ok imma read the docs
!d discord.ext.commands.Context.send
💩
await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, ...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.
To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.
To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.10)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
Don't you use the file kwarg to send video files
Ping sarthak
@jolly basalt
Why would i ping sarthak
What is his nick here
I'm pinging lonely cause of his question
Find out
hello
i kinda fixed it soooo
I did
👀
@slate swan hey bro i needed a help
what help
this was what I had written
the downloadvideo func is just basic pytube stuff
so does it save the video locally or in-cache?
what name does it get saved with?
name of the video
so you would be doing discord.File('name of video.format')
may i see your downloadvideo function?
ight, gimme a moment ill check the docs
yo sooo, I kinda have to go
can you try printing path?
there is a testpaper now XD
🗿
alright, ping me later if you need help with it
um, my name is on there so im not showing the rest of the path
am not checking dms though
it's on desktop
ok tyyy
this shows some error right?
import discord
from discord.ext import commands
class Ping(commands.Cog):
def __init__(self, client):
self.client = client
@commands.Cog.listener()
@commands.command()
async def ping(self, ctx):
await ctx.send(f'Pong! **{round(self.client.latency * 1000)}**ms')
def setup(client):
client.add_cog(Ping(client))
``` Why doesn't this work
since the vide has \ in the title, and in computers means directory
oops
I just did not see that lmao
import discord
from discord.ext import commands
class Avatar(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(name='Avatar',aliases=["av"])
async def avatar(self, ctx, *, avamember : discord.Member=None):
userAvatarUrl = avamember.avatar_url
await ctx.send(userAvatarUrl)
def setup(client):
client.add_cog(Avatar(client))
``` hm?
i need to make a command with wich the bot inters through guild channels and automatically detects multiple channels i.e. channels with same name and delete them
how to do that
!d discord.Guild.channels , this returns a list of all channels , you can do a list comprehension
property channels```
A list of channels that belongs to this guild.
how to detect those i couldnt think of help
I can't find the serverinfo and userinfo code to send them in embed can you help me ?
Please anyone
@junior verge avatar.url
I can't find the serverinfo and userinfo code to send them in embed can you help me ?
On what line?
eeh where u think?
userAvatarUrl = avamember.avatar_url
ye
userAvatarUrl = avamember.avatar.url Like that?
Yea
calm ty
@junior verge but why u make a cog for each command
u can have like users or info as cogname n have avatar as command n add more related commands about user/info in same cog
Wdum?
he wants spoonfeed codes?
uh yeah I maybe should lmao
Why do you have avamember as None
If you don't mention a member of course the avatar_url won't work
Because you made it default to None
regular ToS breakers
so, in dyno and stuff, there is this feature where if you react to a pre-programmed message (say reaction roles) twice, your first selection is gone, how would you replicate such behaviour?
just loop through the reactions and check the reacted users and un-react their messages
!d discord.Message.reactions
Reactions to a message. Reactions can be either custom emoji or standard unicode emoji.
!d discord.Message.remove_reaction
await remove_reaction(emoji, member)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Remove a reaction by the member from the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
If the reaction is not your own (i.e. `member` parameter is not you) then the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission is needed.
The `member` parameter must represent a member and meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.
Changed in version 2.0: This function no-longer raises `InvalidArgument` instead raising [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)").
Imagine
what
when i try to run a await ctx.guild.unban(user, reason=None) the bot return CommandInvoke error, can anyone help me?
class user(commands.Cog):
def __init__(self, bot):
self.bot = bot
user = app_commands.Group(name="users", description="Check User stuff.", guild_ids=[default_guild])
async def _userinfo_(self, interaction, member):
member = interaction.user if member is None else member
embed = Embed(title = f"{member}", description = f"Status: **{member.status}**\n*{member_status}*", colour = member.colour)
await interaction.response.send_message(embed=embed)
@user.command()
@app_commands.describe(member="The discord member to get information for.")
async def info(self, interaction: Interaction, member: Union[Member, User]):
await self._userinfo_(interaction, member)
@app_commands.context_menu(name="User Info")
async def userinfo(interaction: Interaction, member: Member):
await self._userinfo_(interaction, member)
def setup(bot):
bot.add_cog(user(bot))
bot.tree.add_command(userinfo, guild=discord.Object(id=default_guild))```okay so i have this `_userinfo` func that I call inside of my app command and that I want to call inside of my context menu, but context menu's don't have self so I get an error that self is not defined (understandable) when I call the function as the context menu. I then took the `_userinfo_` func out of the class and am now calling it like `await _userinfo_()` in my menu and app command and this raises an error saying `_userinfo_` is not defined
Making discord bots
mhm
I just.... lost a few braincells tryna comprehend what u doing here. Is there an easier explanation of what u want to achieve?
same
but you intelligent 😔 you should understand
@client.event
async def on_ready():
print('Daxbot is ready!')
servers = len(client.guilds)
members = 0
for guild in client.guilds:
members += guild.member_count - 1
await client.change_presence(activity = discord.Activity(
type = discord.ActivityType.watching,
name = f'{servers} servers and {members} members'
))
``` Anything wrong with this?
I mean, I respect that u gave such an explained.... explanation, but still... Think about us low IQ people 
Yes
What is
!d discord.Client.activity exists
property activity```
The activity being used upon logging in.
hm?
hm?
Don't get what's wrong
In the constructor
That's why I told him about the kwarg
I better not start what things I do in on_ready in my bot
also Client.users exists btw so you know you don’t have to do whatever you just did there.
I still don't get it, sorry.
ah yea
Both ways work tho
Why do it it’s already done for you 
Stop with these crying emojis, u gonna make me feel pity for you these emojis

Say this to people who try to make their own command handlers :D 👀
S. T. O. P.
time wastage lol
Like you said, they both provide the same result. And it’s not like you need any modifications. So why not use what’s given.
Indeed
Yeah okay.
The re-inventors of the wheel.
Done that now.
Indeed
@client.event
async def on_ready():
print('Daxbot is ready!')
servers = len(client.guilds)
for guild in client.guilds:
members += guild.member_count - 1
await client.change_presence(activity=discord.Activity(type = discord.ActivityType.watching,name = f'{servers} servers and {client.users} members'))
It’s users
oh
client.users
yeah done
@maiden fable how you gonna access the users in constructor though
Hmmmmm, good point... idk tbh
Idk try doing:
bot = Bot(...)
bot.activity = ...
Tho this isn't gonna work, I'm 90% sure
I mean mine used to work how I had it
Why not?
I mean I think it would work.
didn't I say the same thing bro
I have this _userinfo_ func which sends a msg when it's run. I want to run this func inside of my @user.command() func (so I had _userinfo_ inside of my cog class) but I also run to run _ussrinfo_ from inside of my context menu however d.pys context menus can't be inside of classes (so it doesn't have self) so I can't put my userinfo` func inside of my cog class.
In short how do I run a async func that's not inside of my class?
bot = Bot()
async def change_activity():
bot.change_presence or whatever that method is i dont really care
asyncio.run(change_activity())
bot.run(uwu_token)

@client.event
async def on_ready():
print('Daxbot is ready!')
servers = len(client.guilds)
for guild in client.guilds:
members += guild.member_count - 1
await client.change_presence(activity=discord.Activity(type = discord.ActivityType.watching,name = f'{servers} servers and {client.users} members'))
``` So this should work?
Might as well use a task instead
well yeah
maybe try it?
Sure
Me?
So you definitely don’t need to do this.
yes?
How should I define members here
you dont need to define them.....?
You just said it
just cut out that loop
What loop?
for loop
Oh wait. You should probably call len on bot.users
That’s definitely not gonna be good if you don’t
it wont-
Did that explanation make more sense? I'm on mobile so I didn't go into much detail
@client.event
async def on_ready():
print('Daxbot is ready!')
servers = len(client.guilds)
await client.change_presence(activity=discord.Activity(type = discord.ActivityType.watching,name = f'{servers} servers and {client.users} members'))
``` Just that then?
plus who cares if a number is lesser or more 
Idk 
len(client.users)
len(client.users)
say i have an embed that reaches the 6000 char limit, what would be the best way to get a 2nd, 3rd, 4th etc embed sent (i dont want to do pages).
I currently have:
channel = self.client.get_channel(943393646248591361)
msg = await channel.fetch_message(952383491457286214)
async with aiosqlite.connect("database.db") as db:
guild = self.client.get_guild(607675165785980932)
embed = discord.Embed(title="KB Current Status:")
cursor = await db.execute('SELECT * FROM "kb-manage"')
rows = await cursor.fetchall()
for row in rows:
article = row[0]
lan = row[1]
assigned = row[2]
expire = row[3]
try:
assigned = guild.get_member(int(assigned))
assigned = assigned.mention
except:
assigned = "Unassigned"
status = row[4]
embed.add_field(name=f"**{article}**",
value=f"Language: {lan} - Assigned: {assigned} - Status: {status} - Expire: <t:{expire}>", inline=False)
del article, lan, assigned, status
embed.set_footer(text="Updated every 60 seconds.")
await msg.edit(embed=embed)
but im reaching the limit, and would like to have more embeds sent.
Whats the best way to do this with what I have?
If I would just write len{client.users} that wouldnt work
{len(client.users)}, basically len counts the users aka members
client.users returns a list of User objects
and using the len function on a list will count the number of those objects in the list and tell you the number of users the bot can see
Thanks
What is the difference between discord.Client and commands.Bot?
It’s like a really nice Tesla model S vs a old broken down Toyota Prius.
commands.Bot inherits discord.Client and allows you to create commands with a bunch of other features
iirc discord.Client doesnt have error handlers basically commands.Bot has alot of features
more than discord.Client
damn you're older than me 
Watch out she’s gonna rule 7 you
Ah lemme see. just got on my laptop

Ok yeah
members intent
kiddo 
enable members intent
Kiddo 👀
i mean
Is there an example like what you can also do what discord.Client can‘t
Lmao
Then just restart the bot?
ill see xD

That is a big diffenrence between them😳
still says 1 
Bot is an extended version of Client (it's in a subclass relationship). Ie. it's an extension of Client with commands enabled, thus the name of the subdirectory ext/commands.
The Bot class inherits all the functionalities of Client, which means that everything you can do with Client, Bot can do it too. The most noticeable addition was becoming command-driven (@bot.command()), whereas you would have to manually work with handling events when using Client. A downside of Bot is that you will have to learn the additional functionalities from looking at examples or source codes since the commands extension isn't much documented. UPD: Now it is documented here.
If you simply want your bots to accept commands and handle them, it would be a lot easier to work with the Bot since all the handling and preprocessing are done for you. But if you're eager to write your own handles and do crazy stunts with discord.py, then by all means, use the base Client.
In case you're stumped by which to choose, I recommend you to use commands.Bot since it's a lot easier to work with and it's in addition of everything Client can already do. And please remember that you do not need both.
did you enable intents in your code?
show me ur intents in ur code
stop blushing 
Did not, how do I?
PoV: You're the only one using your bot in your bot test server
intents = discord.Intents.all() gets all the intents 
I want the total members of all the servers if you get me
And no there are like 10
yes, we told you how
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(blahblah, intents=intents)
is how i used to do it.
I dont think intents.members = True is needed now
intents = discord.Intents.all()
client = commands.Bot(blahblah, intents=intents)
Still shows 1 member
import discord
import os
from discord.ext import commands
import json
intents = discord.Intents.all()
client = commands.Bot(command_prefix = ".", intents=intents)
with open("config.json", "r") as f:
config = json.load(f)
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
@client.command()
async def unload(ctx, extension):
client.unload_extension(f'cogs.{extension}')
for filename in os.listdir('./cogs/'):
if filename.endswith('.py'):
client.load_extension(f'cogs.{filename[:-3]}')
@client.event
async def on_ready():
print('Daxbot is ready!')
servers = len(client.guilds)
await client.change_presence(activity=discord.Activity(type = discord.ActivityType.watching,name = f'{servers} servers and {len(client.users)} members'))
client.run(config["bot_token"])
also i recommand u to change presence in the client variable
Can someone help?
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds0.thumbnail.url: Scheme "none" is not supported. Scheme must be one of ('http', 'https').
!paste
next time
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 how can i print first and second line with specific text using request and api
example
geoip = requests.get("https://api.hackertarget.com/geoip/?q="+ arg1)
Sorry.
mobile users be like 
cope, looks fine on desktop :P
anyone know what is Scheme "none" is not supported error?
where are you getting it?
This is all the code for it though
im trying to show the guild avatar on embed
as an embed thumbnail
Yep
hey guys,
I was wondering how can I install discord.py v2.0
this is what I used earlier - pip install git+https://github.com/Rapptz/discord.py@rewrite
but it doesn't work anymore, is there any other way to install v2.0?
Got this now
or anyone know how to show guild avatar image in nextcord?
his bot in 13 guils
Guild.icon_url if you're on dpy 1.7.3
Guild.icon.url if you're on dpy 2
guilds*
nothing ig it should returns more than 1
ctx.Guild.icon.url or just Guild.icon.url?
ctx.guild
done
i did this, and i got that error (im using nextcord)
this in 2v
Does this help?
shameless bump :P
property icon: Optional[nextcord.asset.Asset]```
Returns the guild’s icon asset, if available.
.
so its url = ctx.Guild.icon?
@slate swan getting this
thats embed with api
and i asked how can i replace text from this api with spefic text and first and second line
@slate swan Actually it works now, how do I make it so it updates like every 5m instead of when I restart my bot.
The embed won't appear, but when i use that on slash command, it says
nextcord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In data.embeds0.thumbnail.url: Scheme "none" is not supported. Scheme must be one of ('http', 'https').
wait
u need tasks
!d discord.ext.tasks.loop
discord.ext.tasks.loop(*, seconds=..., minutes=..., hours=..., time=..., count=None, reconnect=True, loop=...)```
A decorator that schedules a task in the background for you with optional reconnect logic. The decorator returns a [`Loop`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop "discord.ext.tasks.Loop").
@client.command(aliases=["serverinfo"])
@commands.cooldown(1, 5, commands.BucketType.user)
async def si(ctx):
role_count = len(ctx.guild.roles)
list_of_bots = [bot.mention for bot in ctx.guild.members if bot.bot]
siEm = nextcord.Embed(timestamp=ctx.message.created_at, color=ctx.author.color)
siEm.set_thumbnail(url=ctx.guild.icon)
siEm.add_field(name="Server Name", value=f"{ctx.guild.name}", inline=False)
siEm.add_field(name="Member Count", value=ctx.guild.member_count, inline=False)
siEm.add_field(name="Verification Level", value=str(ctx.guild.verification_level), inline=False)
siEm.add_field(name="Highest Role", value=ctx.guild.roles[-2], inline=False)
siEm.add_field(name="Total Roles", value=str(role_count), inline=False)
siEm.add_field(name="Bots", value=", ".join(list_of_bots), inline=False)
siEm.set_footer(text=f"Requested by {ctx.author}", icon_url=ctx.author.avatar.url)
await ctx.send(embed=siEm)
@junior verge
Thanks for taking a look, unfortunately I had to leave to go to work so I won't be replying for 6 ish hours so if you have a question or something then give me a ping and I'll reply when I'm back. I may respond in 2 to 3 hours when I'm on break but I'll be on mobile
Yeah
hm
Also what's wrong here ```py
import discord
from discord.ext import commands
class Avatar(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(name='Avatar',aliases=["av"])
async def avatar(self, ctx, *, avamember : discord.Member=None):
userAvatarUrl = avamember.avatar.url
await ctx.send(userAvatarUrl)
def setup(client):
client.add_cog(Avatar(client))
lemme try
idk
but ye
if the command you inputted didn't have the member argument satisfied, it will be none
so it is trying to get the avatar of nobody which isn't possible
The fact that you're using mixedCase instead of snake_case for variable names
But when I do .av @junior verge gives this
Yeah but gives this error
just do
avmember = avmember or ctx.author```
property avatar```
Equivalent to [`User.avatar`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.avatar "discord.User.avatar")
well i'd suggest using this
avamember = avamember or ctx.message.author```
show ur codes
!paste
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.
:P
which version are u using?
nextcord or something
definitely not using nextcord
oh, that might have been someone else
try avamember.avatar_url
uh, it printed None
I'd just say print discord.__version__ to double check
oh gosh im dumb, ik the prob
3.10.2
im running the code in my test server, which it has no guild avatar
the library version
facepalm
@slate swan but how to make so that error won't appear in my console
so its _ not .
Someone told me to change it to
for example if someone use my bot on the server that has no guild avatar
if not xx:
not exist
if you have dpy 2.0 + then yes
ctx.guild.icon_url
So leave it to .
avatar_url
No not guild? It's from a user
No.
dpy 2.0v has ctx.guild.icon basically this returns the guilds icon url, if the guild doesnt have a pic it will returns None
change it to member.avatar_url, I'm sure it would work Daxles
I'll try
in nextcord it raise an error in console if the guild doesn't have a pic
you can try and except it
icon = ctx.guild.icon.url or "No Icon"
kekw, one liners pog
oh didn't see, lemme edit
try:
get icon url
except Exception as e:
print(e)
and then icon would become No Icon
is there a ban appeal?
nope, try it
since there's an or, it moves to the next assignment
wrong command name?
@slate swan :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | AttributeError: 'NoneType' object has no attribute 'upper'
Please
hm
for role_id in teamss:
for member in ctx.guild.members:
if ctx.guild.get_role(role_id) in member.roles and FO in member.roles:
people.append(f"{member.mention} - {ctx.guild.get_role(role_id).mention}")
lst.append(role_id)
for roles in ctx.guild.roles:
if roles in team:
if roles.id not in lst:
checked.append(roles.mention)
checked is returning None
their is no command with the name of "avatar"
Should be
import discord
from discord.ext import commands
class Avatar(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(name='Avatar',aliases=["av"])
async def avatar(self, ctx, *, avamember : discord.Member=None):
if not avamember:
avamember = ctx.author
userAvatarUrl = avamember.member.avatar_url
await ctx.send(userAvatarUrl)
def setup(client):
client.add_cog(Avatar(client))
``` Or I just made a stupid mistake
try lowercase name='avatar'
use Bot not client
that doesn't matter
it does
how so
No does not matter at all
discord.Client doesn't have commands
he defined client as commands.Bot
discord.ext.commands.Bot does
Yeah
yeah he defined client ascommands.Bot
change it to bot
No
its only a var
it doesnt matter :l
I am not changing it
Yes it does
how?
no its not only a var. it is confusing to people trying to help. it shouldn't be client when discord.Client exists
pep8 style? so ppl can understand the code?
Readability
oh i see
if you are using discord.ext.commands.Bot, name the variable bot
Alright so how can I get my code to work, just chang it to a lowercase?
Im not going to aruge over this, its just a variable, client = commands.Bot like it can be that easy to name it anything u want lol = commands.Bot like litterally
its not just a variable...
it is in this case
did they start maintaining discord.py again?
yes. v2.0 is in prod
yes
It matters
^
View this example
oh lol. wonder how all the fork maintainers must be feeling
if im helping someone, and I see @lol.event, I won't know whether they initialized discord.Client or discord.ext.commands.Bot
Not really affected
all of understood that he was using "client = commands.Bot" rather than it being "discord.Client"
user: discord.Member
member: discord.User
See how confusing this is?
^
User and Member are 2 differently things
discord.User and discord.Member are two different things
exactly..
a User is a Discord account. a Member is someone in the server
this is my point, i understand that, but code wise/running wise it wouldn't matter.
it might not effect code running, but do you want the person helping you to be confused?
facts
but we all understood that he was using, client = commands.Bot
no lol
for all I know, he could have initialized discord.Client and was trying to use cogs in it because he didn't know discord.Client didn't have commands
this tbh
is there a decorator for only the server owner to use a command ?
add if statement
def check()
for example if ctx.author.id == ctx.guild.owner.id
!d discord.ext.commands.is_owner
@discord.ext.commands.is_owner()```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that checks if the person invoking this command is the owner of the bot.
This is powered by [`Bot.is_owner()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.is_owner "discord.ext.commands.Bot.is_owner").
This check raises a special exception, [`NotOwner`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NotOwner "discord.ext.commands.NotOwner") that is derived from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
wait so if ctx.author is ctx.guild.owner.id?
thats for app owner
owner for server
ye read the msg incorrectly
^^ this should work
you can also create a custom check
def is_guild_owner(ctx):
ctx.author.id == ctx.guild.owner.id
that doesn't work for custom checks
you need to return a predicate inner function
async function? for what?
oh
def is_guild_owner():
def predicate(ctx: Context) -> bool:
if ctx.author.id == ctx.guild.owner.id:
return True
return commands.check(predicate)
is isn’t supposed to be used for equality checks 👌
ok
i think i would do this?
^^
~~```py
def is_guild_owner() -> Callable[[Context], bool]:
def predicate(ctx: Context) -> bool:
if ctx.author.id == ctx.guild.owner.id:
return True
return commands.check(predicate)
spice it up a bit with type hints
wait how did you que
anyone have any idea?
🗿
alrighty
any ideas?
oh huh you can do @bot.check ok
and after @bot.command would I do @is_guild_owner()?
wait i think i know why
Its meant to be a board in a read only channel that people can all look at to get the information for articles to be written. I dont want pages because that would mean people would have to interact with it whilst someone else may be reading it...
do I call it like @bot.is_guild_owner()?
@commands
@commands.is_guild_owner() correct?
yes
I have a problem
yeah i think i know the problem, roles return a list correct, since im looping through all the roles, and teams are just roles name so
is_owner
no
im not sure how well that would work here as things get added to this list..
I was thinking having 10 items per embed but i wasnt sure how to pull that off with how im editing the embed currently
the bot does not connect to the voice channel
that's a diff check
is that some custom check or something?
its a custom check
dont see a point of making one. but sure
Code:
@client.event
async def on_ready():
print('Bot turned on')
@client.command()
async def join(ext):
embed = discord.Embed(title ="Error!", description = "You are not connected to a voice channel.", color = "32FF00")
channel = ext.author.voice.channel
if ext.author.voice is None:
return ext.send(join=embed)
if ext.author.voice is not None:
return ext.author.voice.channel
await channel.connect()
thanks, i solved it. I had to realize what i was checking for, and what the bot was returning
no i have a custom check
yea its correct, i misunderstood it
oh alright
tho, dont use ctx.guild.owner
compare the ids instead
return ctx.author.id == ctx.guild.owner_id```
reason: .owner needs member intents
this was kinda what i was thinking.. ill play around with it more. thanks
ok for interaction
it would be
@bot.check()
def is_guild_owner_interaction(interaction):
return interaction.user.id == interaction.guild.owner.id```
since they can change their name right
.owner_id
AttributeError: module 'nextcord.ext.commands' has no attribute 'is_guild_owner_ctx'```
```py
@bot.check()
def is_guild_owner_ctx(ctx):
return ctx.author == ctx.guild.owner_id```
yea i changed it
ctx.author.id == ctx.guild.owner_id
shoot ok
This will never be True
you could've used if statement instead 
ok fine
yep
it doesnt have update_per_limit too 
Pls help me.I have a problem with bot voice channel connect.Code:
@client.event
async def on_ready():
print('Bot turned on')
`@client.command()
async def join(cxt):
embed = discord.Embed(title ="Error!", description = "You are not connected to a voice channel.", color = "32FF00")
channel = cxt.author.voice.channel
if cxt.author.voice is None:
return ext.send(join=embed)
if cxt.author.voice is not None:
return ext.author.voice.channel
await channel.connect()`
Have you ever coded python?
No,i'm beginner
I can see that
property voice```
Returns the member’s current voice state.
i don't understand the code tbh, the naming is confusing
!d discord.VoiceChannel.connect | I'd just use this if member.voice is not none
await connect(*, timeout=60.0, reconnect=True, cls=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Connects to voice and creates a [`VoiceClient`](https://discordpy.readthedocs.io/en/master/api.html#discord.VoiceClient "discord.VoiceClient") to establish your connection to the voice server.
This requires [`voice_states`](https://discordpy.readthedocs.io/en/master/api.html#discord.Intents.voice_states "discord.Intents.voice_states").
Thx
ctx.channel.send 
oh wait, yerlikaya, long time 
How do i get it so it says how long ago a message was deleted..
<t:{int(message.delete.timestamp())}:R>")```
you need to convert the timestamp to its epoch value and not an integer
um
You need to get the current time inside of an on message delete event
Because the current time is the time of deletion within an on message delete event
Robin have u ever done game deving? 👀
Error
what is guild_id in discord ?
The guild’s ID.
But no guild_id
yes what is guild.id?
the id of the server
The id of the discord.Guild object you have
and what is session_id ?
A bit
!ot
Off-topic channel: #ot2-never-nester’s-nightmare
Please read our off-topic etiquette before participating in conversations.
heh
come on, it was a joke
Some other people have used the command a bit too many times that it isn't a joke to me anymore
smh
@bot.event
async def on_message(message):
for channel in config["whitelist_channels"]:
if message.channel.id == channel:
pass
else:
return
What's the issue?
wait i forgot to show entire code
Are you an Indian?
@bot.event
async def on_message(message):
for channel in config["whitelist_channels"]:
if message.channel.id == channel:
pass
else:
return
# If embed is true check all properties of embed
if message.embeds:
print("Embed Exists")
else:
print(f"Message: {message.content}")
no lmao 🤣
@bot.event
async def on_message(msg):
if msg.channel.id in config["whitelist_channels"]:
pass
# 'else' part is unnecessary, itd quit the function anyways
# if nothing else to get executed after it.
else:
return
This guy found the bug.
Keep in mind that a whitelist usually implies inclusivity.
@bot.event
async def on_message(message):
if message.channel.id in config["whitelist_channels"]:
pass
so this should be correct?
it worked thanks
What are you gonna write in else?
I think you should use continue instead of pass.
how does continue and pass differ?
If you wanna skip executing code after if block then use continue to send loop to next iteration
continue isn't used in if statements afaik
In this case, what you'd want is a guard statement. Which would exit if its not within the whitelisted channels.
e.g.
@bot.event
async def on_message(msg):
if msg.channel.id not in config["whitelist_channels"]:
return
if msg.embeds:
print("Embed Exists")
else:
print(f"Message: {msg.content!r}")
continue is a keyword used in a loop that begins the next iteration of that loop.
pass moves on to the next line.
if statements don't iterate they just check if a condition is true
continue is used in loops to resume the loop and pass is basically a space filler that doesn't do anything
oh ok
pass is what i wanna use
Don't use pass.
well continue continues the loop which is what i dont want to
There is no loop to continue here.
I want to skip and go to the next line so it prints the message
Thanks!
I don't even need pass anymore I could just do if bla_bla not in config: return
Reducing the indentation and unnecessary pass statment -
Instead of
if something: ...
else: return
It'd be
if not something: return
...
pass is typically used when you made a function but you want to add contents to it later, and in this construction
try:
...
except:
pass```
As well as for making empty classes
if something: ...
return
Yes. But in this context, he/she only wanted it to exit on the else statement; which is unnecessary and can be written as a "guard" if statement instead.
Ok
N o .
The less indentations the better.
if not something:
return
pass # your code
!zen
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than right now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
!zen 5
Sparse is better than dense.
aliving, you? 
Oh lol, it starts counting the lines from 0 o.O
hello
Hola
how do i add aliases to a command when im using this
elif user_message == 'GTN':
number = random.randint(1, 10)
await message.channel.send('Guess my number')
def check(msg):
return msg.author == message.author and msg.channel == message.channel and int(msg.content) in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
msg = await client.wait_for("message", check=check)
if int(msg.content) == number:
await message.channel.send("Correct")
else:
await message.channel.send(f"Nope it was {number}")```
how do i add aliases to a command when im using this
elif user_message == 'GTN':
number = random.randint(1, 10)
await message.channel.send('Guess my number')
def check(msg):
return msg.author == message.author and msg.channel == message.channel and int(msg.content) in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
msg = await client.wait_for("message", check=check)
if int(msg.content) == number:
await message.channel.send("Correct")
else:
await message.channel.send(f"Nope it was {number}")```
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
Traceback (most recent call last):
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 349, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 302, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main - Kopie.py", line 61, in <module>
bot.run(token)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 631, in run
return future.result()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 610, in runner
await self.start(*args, **kwargs)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 573, in start
await self.login(*args)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 424, in login
await self.http.static_login(token.strip())
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 353, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002931E407040>
Traceback (most recent call last):
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002931E407040>
Traceback (most recent call last):
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002931E407040>
Traceback (most recent call last):
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
elif user_message == 'GTN':
number = random.randint(1, 10)
await message.channel.send('Guess my number')
def check(msg):
return msg.author == message.author and msg.channel == message.channel and int(msg.content) in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
msg = await client.wait_for("message", check=check)
if int(msg.content) == number:
await message.channel.send("Correct")
else:
await message.channel.send(f"Nope it was {number}")```
?
Any fix? i already changed/rested my discord bot token
What's the issue?
not issue but can you pls tell me how to alias this command
Perhaps instead of checking against one string, check for membership in a list/set?
elif user_msg.lower() in ("gtn", "g", "other"):
pass # your code
thanks so much
global mess doesn't create a variable my guy
and you dont use global in the global scope

@inland crest a quick refactoring -
def check(old, new) -> bool:
return (new.author, new.channel) == (old.author, old.channel) and 1 <= int(new.content) <= 10
...
elif user_message.lower() in {"gtn", "g", "other alias"}:
await message.channel.send('Guess my number')
msg = await client.wait_for("message", check=lambda x: check(message, x))
number = random.randint(1, 10)
if int(msg.content) == number:
await message.channel.send("Correct")
else:
await message.channel.send(f"Nope it was {number}")
** Please dont mind the indentation, writing this on the phone...
why not use a list 😔
Lol, I used a tuple instead. 
how to edit send embed
await edit(content=..., embed=..., embeds=..., attachments=..., suppress=..., delete_after=None, allowed_mentions=..., view=...)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the message.
The content must be able to be transformed into a string via `str(content)`.
Changed in version 1.3: The `suppress` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited message is returned instead.
Changed in version 2.0: This function no-longer raises `InvalidArgument` instead raising [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)").
ok
I see, a man of culture
How do I remove the picture from the message? For instance if I want to remove the embed, then i set it's value None, but it doesn't work for file/images..
so, i think im using dpy 1, what changes to my code do I need if I upgrade to dpy 2
big changes
are there only new features or are there any big changes to any existing ones
just set files=None or file=None
Nah doesn't work
or even pycord
yeah, what I need to change to upgrade to pycord, im using discord and discord-py-slash-command
or is pycord just dpy
but better
Use disnake
i think pycord is better ngl
Okay
but im reallly confused rn
a lot has happened in a year
when I last made bots, only a week had passed since slash commands really became a thing
no one cares
Why are you so confused about slash commands?
im not!
Immutables are faster
Wdym?
im confused on what library/fork im supposed to use
oh ic
disnake
nice server no one helping
ideally, i dont really want to convert
It was really easy to me
need check individual user of id in task
but, as I looked through the docs, a lot had changed
thats a big one
you can mass replace it
also, i think(im not sure) that pycord has a bigger community?
ok, all i need is to make a dropdown selection
Ez to make with disnake
is that possible in dpy1?
With other modules imported into dpy i guess.. (not sure)
ok, and also, what are (if you know) the biggest differences between disnake and pycord?
darn, discord.py was definetely a better name
or, dispycord2.5infinityCoroSupportedawaitAsyncSnowflake
u can just use dsicord.py
its back in dev
the codebase
yeah, so should I use dpy2?
my bot is hosted on heroku, it's been working fine until yesterday when i tried to login in pycharm with heroku CLI, it gives me this error Error: connect EACCES 0.0.0.0:443
yes, it should be more reliable
lets go 😃
most discord.py tutorials on youtube are unreliable :)
i barely understand the docs
what do u not understand?
sure, it has the classes, but it doesn't clearly describe how they should be used
in dpy 2.0 you can use dropdowns with discord.ui.Select as shown in one of their examples https://github.com/Rapptz/discord.py/blob/master/examples/views/dropdown.py
pycord and disnake are both forks of dpy 2.0 so they have this same feature
oh did that 1 mean <2.0
Check out Github examples
^^
ok
Disnake has good ones
tho i kinda prefer stackoverflow
lol
ok, im gonna go for dpy2
Most people here don't use heroku. Have you tried googling your error?
you have to install it from github directly
ok, what if I dont have git?
then you hsould get git
can u not put in req.txt
why not use heroku at that point
i tried
and?
ah yes
absolutely nothing happens
this guy trolling
yes
who, me?
yes
hmm, did u have a procile file, with the worker declared?
yes
ok, i thought that wouldnt work cuz, well, replit
did u read the errors>
none
yes, but i can't find anything on how to fix it
Did you start the worker?
i think I did?
@commands.Cog.listener()
async def on_member_leave(member):
FO = []
teamname = []
channel = bot.get_channel(notice_leave)
FO1 = await find_by_name("Franchise Owner", ctx.message.guild.roles)
for roles in member.guild.roles:
if roles in team:
if roles in member.roles:
teamname.append[roles.name]
x = teamname[0]
for user in member.guild.members:
if FO1 in user.roles and x in user.roles:
FO.append(f"{user.mention}")
em = discord.Embed(title="Player Left", description=f"{member.mention} left", color=color)
await channel.send(content=''.join(FO), embed=em)
``` why does the bot send nothing in the channel
ok, anyways, its fine, thx
error?
no error
prob cache issue
Use discord.utils.find instead of find_by_name
from discord.utils import find
role = find(lambda r: r.name == "Franchise Owner", ctx.messsge.guild.roles)
i use this because, it sorts through fonts
also this
I'm good, thanks.
these types of servers, use fonts 24/7
ok
o
oh, why dont u have self?
its a cog class right?
💀
has anyone here made ticket tool if so can i have i dont rlly wanna code alot rn XD
github exists
☝️
all js
no
yes
It's still code
damn that person looks happy

i did self.bot = bot
💀
u need self as a parameter of any func if its not a static method
rn ur saying member param is the self param
This is a yikes
Why json though
😭 ikr
send ur code again @slate swan
MOST RELIABLE DATABASE
Funny joke
@commands.Cog.listener()
async def on_member_leave(self, member):
FO = []
teamname = []
channel = self.bot.get_channel(notice_leave)
FO1 = await find_by_name("Franchise Owner", ctx.message.guild.roles)
#ASSUMING THE `find_by_name` is imported not in the class
for roles in member.guild.roles:
if roles in team:
if roles in member.roles:
teamname.append[roles.name]
x = teamname[0]
for user in member.guild.members:
if FO1 in user.roles and x in user.roles:
FO.append(f"{user.mention}")
em = discord.Embed(title="Player Left", description=f"{member.mention} left", color=color)
await channel.send(content=''.join(FO), embed=em)
it imported
Ok
you don't need anything major for a ticket bot, JSON will do :)
async def on_member_remove(member): why is the bot saying this is 2 arugements rather than 1
Then the guild doesn’t have an icon
Add self param in front of member
yes
Yea, already solved, also got the error handling
teamname = [role.name for role in ctx.guild.roles if role in team and role in member.roles]
you can use this though, list comps are generally faster in most cases
[role.name for role in team if role in member.roles] no?
Hello! I have a little problem,..
So I've created a await guild.create_role(name="text") function in my code.
I tested a lil bit around and now It's not responding anymore.
So for example:```
print("creating role") # works
await guild.create_role(name="text") # no response, even with wrong input
print("created role") # not printing because the role creator is being awaited
@client.command(help='Access Reddit')
async def Rmemes(self,ctx,subred="rmemes"):
msg=await ctx.send('Loading meme.....')
reddit = asyncpraw.Reddit(client_id='',
client_secret='',username='Livid-Brick-74',password='',user_agent='pythonasycpraw')
subreddit=await reddit.subreddit(subred)
all_subs=[]
top = subreddit.top(Limit=50)
async for sumbission in top:
all_subs.append(submission)
random_sub=random.choice(all_subs)
name = random_sub.title
url = random_sub.url
embed = discord.Embed(title=name)
embed.set_image(url=url)
await ctx.send(embed=embed)
await msg.edit(content=f'https://reddit.com/r/{subreddit}/')
i am getting the error of ctx is a required arguement that is missing
what am i doing wrong
traceback?
yh
why async praw 😔
Just use the JSON API bro
nvm hunter god here
Eh I am going to get smth to eat anyways
so
json api?
@pliant ocean send traceback so we can help you
Traceback (most recent call last):
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
await self.prepare(ctx)
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
await self._parse_arguments(ctx)
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
transformed = await self.transform(ctx, param)
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: ctx is a required argument that is missing.
I'm really so lazy that I use this for reddit memes lol - https://meme-api.herokuapp.com/gimme

too lazy
its actually easier
to sort them first of all, is a big headache for me
😔
Traceback (most recent call last):
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: ListingGenerator.init() got an unexpected keyword argument 'Limit'
this is what i get its showing loading meme but gives this
is L in limit small?
yes
okay
Traceback (most recent call last):
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 349, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 302, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "main - Kopie.py", line 61, in <module>
bot.run(token)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 631, in run
return future.result()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 610, in runner
await self.start(*args, **kwargs)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 573, in start
await self.login(*args)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 424, in login
await self.http.static_login(token.strip())
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\http.py", line 353, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002931E407040>
Traceback (most recent call last):
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002931E407040>
Traceback (most recent call last):
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000002931E407040>
Traceback (most recent call last):
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 719, in call_soon
self._check_closed()
File "C:\Users\Vestige\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 508, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
how i can fix this error?
you have passed the wrong bot token
Traceback (most recent call last):
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Subhojit Roy\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'submission' is not defined
but i think i already defined submission?
error is unauthorized and it gives "improper token passed" this means you've passed the wrong bot token
wtfff
?
is this not the bot token?
Yes it is
rather open the reddit app to see memes 
So why the fuck its not working
Rather stop seeing memes
see you uwu yeps right
okay it worked but it spams memes like 15-20 times
😔
from distutils import command
from re import X
import traceback
import discord, json, os, random
from discord.ext import commands
import time
import sys
from datetime import datetime
from os import listdir
token = "" # Bot Token
prefix = "?" # Bot Prefix
status = "VGen" # Playing Status
os.system("cls")
os.system("title Account Gen Bot")
bot = commands.Bot(command_prefix=prefix)
logo = """
╦ ╦╔═╗╔═╗╔╦╗╦╔═╗╔═╗
╚╗╔╝║╣ ╚═╗ ║ ║║ ╦║╣
╚╝ ╚═╝╚═╝ ╩ ╩╚═╝╚═╝
"""
@bot.event
async def on_ready():
await bot.change_presence(activity=discord.Game(name=status + " | " + prefix + "help"))
print(logo)
print(f'Connected in: {bot.user}')
print(" Satus : " + status)
print(" Prefix : " + prefix)
bot.remove_command("help")
@bot.command()
async def help(ctx):
helpmenu = discord.Embed(title="Help", description="", color=0x9208ea, )
helpmenu.description += prefix + "search <mail>"
helpmenu.set_thumbnail(url="https://media.discordapp.net/attachments/933028046364106752/946877687140614304/chrome_FkkVv3EboU.png?width=80&height=40")
await ctx.send(embed=helpmenu)
@bot.command()
async def search(ctx, arg1):
await ctx.message.delete()
embed=discord.Embed(color=0x39fd3f)
embed.set_author(name="test1", url="https://test.com/")
embed.set_thumbnail(url="https://i.pinimg.com/originals/40/55/da/4055da716e80ffef4742b05d40dce139.png")
embed.add_field(name="Searching File now", value="Results for **"+arg1+"**...", inline=False)
await ctx.send(embed=embed)
search = open("dumps.txt") #Your path to the file you want the bot to search for
for line in search:
if arg1 in line:
embed=discord.Embed(color=0x39fd3f)
embed.add_field(name="Data Search", value=line, inline=False)
await ctx.send(embed=embed)
bot.run(token)
we are talking about discord ap here :)
anything wrong?
in-built help command: Am I a joke to you?
bro just help me
latest code
Calm down, no one is liable to help u here
WHYYYY
czzzzzz we are doing it voluntarily?
@client.command(help='Access Reddit')
async def Rmemes(ctx,subred="memes"):
msg=await ctx.send('Loading meme.....')
reddit = asyncpraw.Reddit(client_id='1Oyh8I8h57AV-ID98PHyWQ',
client_secret='cJ0uGjkhTvRGvoI2xPD4lbLJYRn_cQ',username='Livid-Brick-74',password='',user_agent='pythonasycpraw')
subreddit=await reddit.subreddit(subred)
all_subs=[]
top = subreddit.top(limit=50)
async for submission in top:
all_subs.append(submission)
random_sub=random.choice(all_subs)
name = random_sub.title
url = random_sub.url
embed = discord.Embed(title=name)
embed.set_image(url=url)
await ctx.send(embed=embed)
await msg.edit(content=f'https://reddit.com/r/{subreddit}/')
!code
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
indent goes brrrrrrr
Wott is this lmao
u r just passing in the wrong token bruv, cannot help with that

well, it "will" spam, because of uwu indent
😔 Stop uwuing, uwu isn't uwu anymore
sedlyf will fix it thank you 
correct the token for them :)
lmao
🗿
Well he isn't responding, soooo 🤷
Subclass the help command as shown in pins
he left
L ok
@bot.command(pass_context=True)
@commands.has_role("3l")
async def claim(ctx, *, reason=None):``` how do i make it reply if you dont have 3l role
there are 2 options:
N1: Use the on_error event and use the right instance (forgot wich one)
N2: Put this in your code: if not get(ctx.guild.roles,id=int(ROLE_ID)) in ctx.author.roles:return await ctx.send("You do not have the right role to use this command") # requires discord utils import
with 2nd option would i put before or after async
you have to use async in every command (eg. async def command_name_or_function_name(ctx)
ok
@commands.has_role("3l")
async def claim(ctx, *, reason=None):
username, user = reason.split(':') if not get(ctx.guild.roles,id=int(ROLE_ID)) in ctx.author.roles:return await ctx.send("You do not have the right role to use this command") # requires discord utils import
await ctx.send(f"{username} {user}")```
im dumb sorry
is this right format?
It should look like this:
@bot.command(name="claim",description="This is the description of your command. both name and description are optional",pass_context=True)
async def _claim(ctx, *, reason=None):
username, user = reason.split(':') if not get(ctx.guild.roles,id=int(ROLE_ID)) in ctx.author.roles:return await ctx.send("You do not have the right role to use this command") # requires discord utils import
await ctx.send(f"{username} {user}")
ty
you dont need pass_context
username, user = reason.split(':') if not get(ctx.guild.roles,id=int(952619437427654696)) in ctx.author.roles:return await ctx.send("You do not have the right role to use this command") # requires discord utils import
^
SyntaxError: invalid syntax
why is code so spaced out
the "simpler" version:
@bot.command(name="claim",description="This is the description of your command. both name and description are optional",pass_context=True)
async def _claim(ctx, user:discord.Member=None,*, reason:str=None):
if not get(ctx.guild.roles,id=int(ROLE_ID)) in ctx.author.roles:
return await ctx.send("You do not have the right role to use this command") # requires discord utils import
await ctx.send(f"{username} {user}")
(please format this if neccessary I'm curentlöy not in a editor and discord is cursed for me)
How can I correct the calculation errors that my bot makes ?
its ok
@commands.command()
@commands.has_permissions(manage_channels=True)
async def slowmode(self, ctx):
if time == 0:
await ctx.send("Slowmode Off")
await ctx.channel.edit(slowmode_delay = 0)
elif time > 21600:
await ctx.send("Vous ne pouvez pas mettre le slowmode au-dessus de 6 heures.")
return
else:
await ctx.channel.edit(slowmode_delay = time)
await ctx.send(f"Slowmode mit à {time} secondes !")
``` Hello, i have this error with this code
The readability on this is so bad and this wont work as expected
you forgot ctx, *, reason=None):
username, user = reason.split(':')
Help me please
Show how you're counting the amount of roles roles
It's actually much easier with the discord.Member args (if you need it)
its not discord user
envoi ton code
its a variable not discord member @humble granite
@bot.command() @commands.cooldown(1,5,commands.BucketType.channel) async def userinfo(ctx,member: discord.Member = None): if member == None: member = ctx.author try: roles = [role for role in member.roles[1:]] embed = discord.Embed( color = discord.Color(0xff3400), title = f"{ctx.member}") embed.add_field(name="**ID**", value=f"{member.id}", inline=False) embed.add_field(name="**Status**", value=str(member.status).replace("dnd", "Do Not Disturb"), inline=False) embed.set_thumbnail(url=f"{member.avatar_url}") embed.add_field(name=f"**Rôles ({len(ctx.author.roles) - 1})**", value='• '.join([role.mention for role in roles]), inline=False) embed.add_field(name="**Compte crée le**", value=f"{member.created_at.date()}".replace("-", "/"), inline=False) embed.add_field(name="**A rejoins le serveur le**", value=f"{member.joined_at.date()}".replace("-", "/"), inline = False) embed.set_footer(icon_url = f"{ctx.author.avatar_url}", text = f"Demandé par {ctx.author}") embed.timestamp = datetime.datetime.utcnow() await ctx.send(embed=embed) except: roles = [role for role in member.roles[1:]] embed = discord.Embed( color = discord.Color(0xff3400), title = f"{member}") embed.add_field(name="**ID**", value=f"{member.id}", inline=False) embed.add_field(name="**Status**", value=str(member.status).replace("dnd", "Do Not Disturb") , inline=False) embed.set_thumbnail(url=f"{member.avatar_url}") embed.add_field(name=f"**Rôles (0)**", value="No roles", inline=False) embed.add_field(name="**Compte crée le**", value=f"{member.created_at.date()}".replace("-", "/"), inline=False) embed.add_field(name="**A rejoins le serveur le**", value=f"{member.joined_at.date()}".replace("-", "/"), inline = False) embed.set_footer(icon_url = f"{ctx.author.avatar_url}", text = f"Demandé par {ctx.author}") embed.timestamp = datetime.datetime.utcnow() await ctx.send(embed=embed)
Time not defined
config.json
"whitelist_channels": [
id_here
],
"blacklist_channels": []
@bot.event
async def on_message(message):
# Counters
print(type(whitelist))
print(type(blacklist))
print(whitelist)
print(blacklist)
blacklisted_messages = 0
whitelisted_messages = 0
messages = 0
embed_counter = 0
if whitelist:
if message.channel.id not in config["whitelist_channels"]:
blacklisted_messages += 1
return
elif blacklist:
if message.channel.id in config["blacklist_channels"]:
blacklisted_messages += 1
return
elif message.channel.id not in config["blacklist_channels"]:
whitelisted_messages += 1
pass
elif whitelist is False and blacklist is False:
messages += 1
This code doesn't work and shows messages from all channels
oh yes thanks man
I'm trying to make a system where if whitelist_channels is True it should let the message pass
ah yes I forgot the replace the vars from the ctx.send with reason, user I forgot It
ta commande est trop compliqué bg
ah
main.py but this is the code underneath that codeblock above
print(f"{channel} -> {author}: {msg}")
and channel, author, and msg are my own variables and they do work since they are correct but they print every message instead of just the ones in the whitelisted channel
je sais pas comment la simplifier dans ce cas là
!rule 4 btw
4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.
@slate swan viens dm je t'en passe une bien plus simple sans l'erreur
asy
french 😔
The conditions are very complicated
get not defined
How should I make them more simple?
you have to as I said earlier, import discord utils
I think it was from discord.utils import get
You could do something like
channel_id = message.channel.id
if whitelist_enabled and channel_id not in config['whitelist']:
# when the message is not whitelisted
elif blacklist_enabled and channel_id in config['blacklist']:
# when the message is blacklisted
this checks if my whitelist is enabled or not but doesn't work, the whitelist variable is a NoneType in the on_message func and this codeblock runs before the events and stuff like that are setup (at beggining of file)
if not config["whitelist_channels"]:
whitelist = False
print(f"{bad} Whitelist is empty!")
print(f"{bad} Showing all messages from all channels")
# Check if blacklist is empty
if not config["blacklist_channels"]:
blacklist = False
Yes but the conditions you were making there are most likely incorrect
These are less complicated aren't they
Yes
But how would I check if my list is empty in the main.py file
The list is in a json file
Would I have to convert it first to a python list?
Wait uh how do you decode json
Idk 🤷🏿♂️
oh nvm
That should be json.load
Like this:
with open("config.json", "r") as f:
config = json.load(f)
Ok this is normal
so it already converts it to python dict?
Afaik if you parse something other than bool to condition it will just check if its length is not equal 0
Of course
What format would you expect it to be
Ok so I can't check if by doing if True or if False
I thought it would list first
[] = array in json, [] = list in python
but it becomes dict?
!e py ls1 = [10, 20, 30] ls2 = [] if ls1: print('ls1') if ls2: print('ls2')
@vale wing :white_check_mark: Your eval job has completed with return code 0.
ls1
but in json [] this is array and when using json.load() that it should become dict right?
or does it convert to list?
Yes
that doesnt seem to work for me 😦
Well this worked
It sets atrributeError : the message object has no server attribute
`@bot.command()
async def serverinfo(ctx):
"""Shows server info"""
server = ctx.message.server
roles = str(len(server.roles))
emojis = str(len(server.emojis))
channels = str(len(server.channels))
embeded = discord.Embed(title=server.name, description='Server Info', color=0xEE8700)
embeded.set_thumbnail(url=server.icon_url)
embeded.add_field(name="Crée le:", value=server.created_at.strftime('%d %B %Y at %H:%M UTC+3'), inline=False)
embeded.add_field(name="Server ID:", value=server.id, inline=False)
embeded.add_field(name="Membres sur le serveur:", value=server.member_count, inline=True)
embeded.add_field(name="Server owner:", value=server.owner, inline=True)
embeded.add_field(name="Default Channel:", value=server.default_channel, inline=True)
embeded.add_field(name="Server Region:", value=server.region, inline=True)
embeded.add_field(name="Verification Level:", value=server.verification_level, inline=True)
embeded.add_field(name="Nombre de rôle:", value=roles, inline=True)
embeded.add_field(name="Nombre d'émojis:", value=emojis, inline=True)
embeded.add_field(name="Nombre de Channel:", value=channels, inline=True)
await ctx.send(embed=embeded)`





