#discord-bots
1 messages · Page 591 of 1
I agree
speaking of heroku, anyone know about this? ._.
its “free” but you have to do hours of free advertising for this kid to use his sub par servers 
They automatically get synced if they are connected
lol
Literally I went on his server and I was like fuckkkkkkk
Expensive asf
Heroku is 1000000000000000000000000000x times better
Even repl is better than that hosting service😂🤣
Do you know why the message doesn't delete itself? ```py
msg = await ctx.author.send("** **", view=view)
await view.wait()
await msg.delete()
they did wrote this tho ._.
code can go from github to heroku but i want to make github sync with heroku cuz my bot changes some files durings its deploy and the changes are not visible on github
Is that even possible?
changing files?
No syncing
You can push code to GitHub from Heroku
I don't think you can push from Heroku to Github
You can
How?
the only method i know is to pull the code from heroku but thats a hassle everytime i wanna redeploy
tho i wonder if theres another hosting website that has github integration and the code is always updating to its github repo
that would be simpler
could you explain?
Well due to limitations that's not possible IG
^
Is it bad that I have like 3 on_message events
points_count is None
hold up
but im not sure why its none tho
have you checked the database if it exists?
the thing is insert_one begins with 0 points because i want it to begin from 0
wdym
I'm saying that if the thing ur looking for exists
@heavy folio
That might be it
you inserted 0 but your looking for 1
oh
Don't think so
Yep, jsk restart doesnt exist
Don't think you can do that with 3rd party libraries but you can try editing the view once it got clicked to another view/button
you will need to edit the message with a new button
so edit the message, and pass a new components
!d discord.Message.edit
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.
just in view= just like you are creating a new message
anyone got a list of the id for colours for embed
!d discord.Color
No documentation found for the requested symbol.
class discord.Colour(value)```
Represents a Discord role colour. This class is similar to a (red, green, blue) [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)").
There is an alias for this called Color...
grab your code where you send the message with the buttons, now replace the .send with .edit, and instead of a channel it's on a message
It's only aliased and doesn't actually exist twice
Ah
I mean having 2 class for colors is just weird agreed
don't edit whatever comes out of the wait for, store your message send return value then edit that message
discord/colour.py line 329
Color = Colour```
literally all there is to it haha
if commandInvoker.guild_permissions.administrator is False:
await ctx.channel.send(f"{commandInvoker.mention}, this command isn't allowed here.")```
is this correct? commandInvoker = ctx.author
is my badcommandInvoke defined as ctx.author?
yes
wait its wrong
doesnt seem to work tho, sends the msg for people with admin perm too
you cant check if its False just use a not statement
hm
so lets say you have the code
await ctx.send("Some text", view=MyButtons())
You can then edit it with
msg = await ctx.send("Some text", view=MyButtons())
await msg.edit(content="Some other text", view=MyOtherButtons())
yes, or if you make that View class take input you can use the same class and just use input to change the colour
oh you're not using discord.py, idk how those work
i just use discord.py's own button stuff
well okay discord_components is a third party extension for discord.py
but they do their stuff differently
no extra libraries
just plain vanilla discord.py with no third party extensions
don't forget you need discord.py 2.0 for this, which isn't on pypi
!pypi disnake personally
nah working on my own library with a few others atm
:p
!pypi disthon
Guys someone just told me that discord.py going to be shut down soon
this is correct?
it already did
it's not shut down, it's just no longer being maintained since a few months ago already
alec is working on it 🤔
i cant find the github for it
is it still private
2021-08-28 is when danny announced that he quit
he's not really working on it but he's part of the team and helping out where needed
like just as an advisor so to say
always has been public: https://github.com/AA1999/Disthon
if not commandInvoker.guild_permissions.administrator:
await ctx.channel.send(f"{commandInvoker.mention}, this command isn't allowed here.")
raise commands.CommandError('The command is limited.')```
gives the same error for this too
show error
the error is, if the commandInvoker doesnt have guild perms administrator, it should send the ctx.channel.send msg but it sends the msg even for member with admin perm
is commandInvoker context.author?
ye
the command might have been used in dms
nope
ah sorry i didnt read the edit , can show what you have in your code further
hi
Not even an example nor docs, wouldn't recommend it to anyone when most people making discord bots are complete beginners at coding in general
because we still haven't made a public release haha
it's still all WIP
Ah, understandable
just need to get it known to the public slowly and in an acceptable manner :p
¯\_(ツ)_/¯
also want an exmple:
import discord
client = discord.Client(intents=discord.Intents.all())
@client.event("on_message")
async def bounce_message(msg):
if msg['d']['content'] == "Hello":
await client.handler.send_message(int(msg['d']['channel_id']), "Hello World!")
@client.event
async def on_message(msg):
if int(msg['d']['channel_id']) == 890495312811151370:
await client.handler.edit_guild_text_channel(890495312811151370, topic=msg['d']['content'])
client.run("TOKEN")
shows how rough it is atm
Damn, that's a lotta json
ye it's currently passing the raw json stuff from the API to the code, but no fear those models are next
So I am working with nextcord to migrate my old discord.py over to it and I realised that my unload and load command for cogs stopped working (or never worked at all it's been a while since I worked in this bot) what is the best way/proper way to unload and load cogs?
Are you guys not going for a object oriented wrapper
This seems more like a rest client
Unless this is just a WIP
it's going to be like discord.py
just yeah the models aren't implemented yet, which is next on the list
so it's all just raw json parsing
The name handler doesn't make sense to me
handler is just the internal thing that does all the API calls
it handles the API calls
hence handler
Someone is gonna have fun when they figure out how shit the documentation is
discord.py named it HTTPClient
Why is your client session in handler mangled
Name mangling isn't for private variables
a single underscore is often used in python to just give off the hint of "don't use this", tho tbh no one should touch anything inside handler directly
ah did we?
That is used for classes meant to be subclassed
It's not supposed to be used for private variables as said in pep8 somewhere iirc
yeah i am aware, the double underscore means you can access the attribute using instance._Classname__attributename for when you're subclassing a lot
guys i need help
Guyz How To Change Button Color ?
by passing something into the color when you make the button
im making a discord bot that dms someone when a command is activated this is the command but i want it to later delete the message from the dms i tried it with the code below can somoen pls help? :
await user.send(f'a member has an issue they said that there was an issue with one of the following: the server one of the member idk just check out the ask owner someone mustve said it')
dmchannel = bot.get_channel(450568681898901515)
for message in dmchannel(limit=100):
if message.author == bot.user:
await dmchannel.delete(450568681898901515)
when you make a button you just pass a style like this @discord.ui.button(label='<<', style=discord.ButtonStyle.blurple, custom_id='pg_bck')
and that button is blurple
seb can you help me?
so not sure where you pulled that code from, but there's seems to be an issue on pretty much every line of code
im new to making the code i just found it online modified it and it works but i want it to delete messages from my dms with the bot
idk how to do it
and i gave up trying
when you send a message, it returns the message object, just call .delete() on it and it's gone
alternatively pass delete_after= to the send
msg = await user.send("Hello")
# some code
await msg.delete()
or
await user.send("Hello", delete_after=20) # will delete the message after 20 seconds
hello there; i get this error: AttributeError: module 'discord' has no attribute 'ButtonStyle' what should i do?
what version you are at?
3.9
discord.py version i mean
sounds like you're not on 2.0
i think i fixed it now
1.7.3
good spot
oh so i should update it?
yeah buttons and interactions and such are added in 2.0, which is not on pypi btw, so a pip install -U discord.py will not work
ah i see
read this
seb thank you i found out how to delete it
but i have another problem
i have tried this so many times
idk how to delete this
easiest way to just delete everything is to purge
ah wait that doesn't exist for DMs
crap
so you'll have to async for loop over the history and delete all messages one by one
!d discord.abc.Messageable.history
async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the destination’s message history.
You must have [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permissions to use this.
Examples
Usage...
then for every message delete it
told you already
is it still delete after?
just message.delete()
oh
!d discord.Message.delete
await delete(*, delay=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Deletes the message.
Your own messages could be deleted without any proper permissions. However to delete other people’s messages, you need the [`manage_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_messages "discord.Permissions.manage_messages") permission.
Changed in version 1.1: Added the new `delay` keyword-only parameter.
Nice, and also isn't handler a bit to broad? It leads me to believe it handles anything
Perhaps HTTPHandler or just HTTPClient
hmm, maybe httphandler
tbh most are never going to know about the class because it's hidden/backend
but for the few maybe make it slightly more clear yeah
If you want to facilitate development in your wrapper
So everything you do should be explicit
In my wrapper I have almost all internals documented
This is done so that it allows for contributors to understand the codebase without reverse engineering
that's a very good point yeah, i was expecting people to be possibly interested in the behinds the scene. I'll probs put on my todo to document the internals very well and rename a few things to make it more explicit
Is this your first time making a public wrapper meant to be used?
pythonpixels was my first one, but that was such a small and tiny project for me to work alone on
!pypi pythonpixels
Alright well a good thing to keep in mind is
It's a lot easier to make the wrapper than it is to make it easy for people to use
haha
that's replit for you
and most here will tell you to not use replit
or at least not for discord bots
@valid niche can you suggest me a host?
Replit i use and i had a problem
Don't use replit/heroku as you got told above
for entry in entries:
embeds.append(discord.Embed().from_dict(entry))
await ctx.send(embed=embeds)
```wut do i do?
- Repl.it uses an ephemeral file system.
- - This means any file you saved via your bot will be overwritten when you next launch.
``` this isn't true
which part
index it
!traceback
Please provide the full traceback for your exception in order to help us identify your issue.
A full traceback could look like:
Traceback (most recent call last):
File "tiny", line 3, in
do_something()
File "tiny", line 2, in do_something
a = 6 / b
ZeroDivisionError: division by zero
The best way to read your traceback is bottom to top.
• Identify the exception raised (in this case ZeroDivisionError)
• Make note of the line number (in this case 2), and navigate there in your program.
• Try to understand why the error occurred (in this case because b is 0).
To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.
he gotta index the list
what is the difference between task.stop() and task.cancel()?
also show me how entries is defined
one lets it end gracefully, the other one stops it no matter what
it says cancel() stops it immediately but what is is_being_cancelled() for
!d discord.ext.tasks.Loop.stop
stop()```
Gracefully stops the task from running.
Unlike [`cancel()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop.cancel "discord.ext.tasks.Loop.cancel"), this allows the task to finish its current iteration before gracefully exiting.
Note
If the internal function raises an error that can be handled before finishing then it will retry until it succeeds.
If this is undesirable, either remove the error handling before stopping via [`clear_exception_types()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop.clear_exception_types "discord.ext.tasks.Loop.clear_exception_types") or use [`cancel()`](https://discordpy.readthedocs.io/en/master/ext/tasks/index.html#discord.ext.tasks.Loop.cancel "discord.ext.tasks.Loop.cancel") instead.
New in version 1.2.
or did they just use the wrong word here?
!d discord.ext.tasks.Loop.cancel
cancel()```
Cancels the internal task, if it is running.
so does is_being_cancelled() come to use after stop()?
@valid niche @boreal ravine it worked...i tried smtn else
thenks for showing up tho
no problem
i'm not sure i never used it
looking at it, it seems rather odd
well im running a task and after some event it starts another task where in that task it stop()s the first task, letting it run its last loop, and in the meantime waits until its done with is_being_cancelled()
with the point being to avoid overwriting the same data
Hello guys, can you help me out how to get the reason (begruendung) connected with the name (user.id) so i can display a members warnings?
This is my code so far
@client.command(pass_context = True)
async def warnings(ctx,user:discord.User):
if user.id in [x["name"] for x in report["Mitglieder"]]:
gruende = [x["Begruendung"] for x in report["Mitglieder"]]
IDENT = [x["name"] for x in report["Mitglieder"]]
await ctx.channel.send(f"{user.name} wurde bereits {IDENT.count(user.id)} mal verwarnt! wegen {gruende}")
else:
await ctx.channel.send(f"{user.name} wurde noch nicht verwarnt")
And this is the .json data where the information is from
{"Mitglieder": [{"name": 502804107040653312, "Begruendung": ["taktisches Warten"]}, {"name": 290991651755786240, "Begruendung": ["baseraid"]}, {"name": 766247684859363359, "Begruendung": ["darum"]}, {"name": 502804107040653312, "Begruendung": ["TEST"]}, {"name": 569670203345207306, "Begruendung": ["TEST"]}, {"name": 766247684859363359, "Begruendung": ["Schuldspruch"]}, {"name": 766247684859363359, "Begruendung": ["Tralala"]}, {"name": 290991651755786240, "Begruendung": ["Dumbo"]}, {"name": 385001631265062913, "Begruendung": ["Datzbert"]}, {"name": 290991651755786240, "Begruendung": ["Dullibert"]}], "name": [], "Begruendung": []}
Im thankful for any help!
how i can make my bot delete his message after 3 seconds?
await asyncio.sleep(3)
await channel.delete_messages(1)
i have this but doesnt work xd
ctx.send(delete_after=5)
Code?
why send?
or in your case 3 instead of 5
so i need to change the channel delete thing for that
because that means the ctx which was send will be deleted after 5 seconds
You're welcome
For some reason
async def on_member_join():
print("member joined")
this works
but this doesnt
async def on_member_remove():
print("member left")
I tried on_member_leave too
it didn't work
only on_member_join worked
i have enabled intents to
async def membercount():
guild = bot.get_guild(serverid)
totalchannel = bot.get_channel(totalmembercountchannel)
humanchannel = bot.get_channel(humancountchannel)
botchannel = bot.get_channel(botcountchannel)
true_member_count = len([m for m in guild.members if not m.bot])
total_member_count = guild.member_count
bot_count = len([m for m in guild.members if m.bot])
await humanchannel.edit(name=str(true_member_count)+" Members |:star:") # HUMANS
await totalchannel.edit(name=str(total_member_count)+" Total Members |:sparkles: ") # TOTAL
await botchannel.edit(name=str(bot_count)+" Bots |:robot:") #BOT COUNT```
Any1 know how to add boost count
xd
is it
boostchannel = bot.get_serverboosts(serverboostcountchannel)```
wait no
thats very weird thats not how t works
let me check the docs
so ez
wait so instead of bot.get_serverboosts its guild_object.premium_subscription_count
guild = bot.get_guild(<guild id>)
boost = guild.premium_subscribers
yep
get_server boosts is kinda different
premium_subscribers
i don't think get server boosts exists
even if it did you didn't specify the guild
await boostchannel.edit(name=str(guild_object.premium_subscription_count)+" Boosts")
then that yeah
Okay
still trying to figure out why this doesn't work
u got intents setup
yes
async def on_member_remove(member):
channel = client.get_channel(ID)
await channel.edit(name = 'Member count: {}'.format(channel.guild.member_count))```
ye i did tat
also a recommendation
await channel.edit(name = f'Member count: {channel.guild.member_count}')
u looked at that
await self.coro(*args, **kwargs)
File "C:\Users\liamd\Desktop\Sen\MainGen\main.py", line 90, in membercount
boost = guild.premium_subscription_count(boostchannel)
TypeError: 'int' object is not callable```
I mean the error is self explanatory. You tried to pass arguments into an attribute.
premium_subscription_count isn’t a method. It’s an attr
sorry am new to python aha trying something different from js
How to use await edit ?
so should i do?
Idek what you’re trying to do
boost channel count
""
you await it like you await any other coroutine.
@sage otter
async def membercount():
guild = bot.get_guild(serverid)
totalchannel = bot.get_channel(totalmembercountchannel)
humanchannel = bot.get_channel(humancountchannel)
botchannel = bot.get_channel(botcountchannel)
guild = bot.get_guild(serverid)
boost = guild.premium_subscription_count(boostchannel) -- -- this line
true_member_count = len([m for m in guild.members if not m.bot])
total_member_count = guild.member_count
bot_count = len([m for m in guild.members if m.bot])
await humanchannel.edit(name=str(true_member_count)+" Members |⭐") # HUMANS
await totalchannel.edit(name=str(total_member_count)+" Total Members |✨ ") # TOTAL
await botchannel.edit(name=str(bot_count)+" Bots |🤖") #BOT COUNT
await boostchannel.edit(name=str(guild_object.premium_subscription_count)+" -- this line
Boosts")```
trying something rlse
What's wrong with repl.it?
read this
that last point is extremely important to keep in mind, because it means if you use replit to host your bot, you have a chance of literally just being banned from discord
cant figure it out cna u send me it
get_prefix is often the name of the function people implement for their dynamic prefix system
!d discord.ext.commands.Bot.command_prefix
The command prefix is what the message content must contain initially to have a command invoked. This prefix could either be a string to indicate what the prefix should be, or a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.
An empty string as the prefix always matches, enabling prefix-less command invocation. While this may be useful in DMs it should be avoided in servers, as it’s likely to cause performance issues and unintended command invocations.
eh
Figure out what? I basically gave you the solution right there
a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.
idk where to put it
sp
so
await boostchannel.edit(name=f"Boost Count: {guild.premium_subscription_count}")
@sage otter
👌
I have a question how i can make the size from a discord cdn url better
because on streams/guild thats not work
.png?size=80
File "C:\Users\liamd\Desktop\Sen\MainGen\main.py", line 91, in membercount
boost = guild.premium_subscription_count(boostchannel)
TypeError: 'int' object is not callable
do i just remove that line
#help-candy if anyone can help it would be appreciated 
Wait what the hell. Why are you passing for. That’s probably why it’s not sending anything.

Yes
You don’t need to pass after redefining
I have a 2048 game that works on desktop/browser but whenever I try it on mobile it displays this but it doesn’t work when I try to use the keys, can someone help? https://mystb.in/EnhancementYrsOriental.prolog
intents = discord.Intents.default()
AttributeError: module 'discord' has no attribute 'Intents'
works on my pc not a friends tho
@sage otter
u know?
guild = bot.get_guild(897948463243874344)
role = guild.get_role(898339367242829825)
print("people:" + str(role.members))
why does this get me an empty list? over 500 ppl have the role
No not really. That definitely exist. You’re friend just isn’t doing something t right.
You got intents?
yeah, i got them enabled
they are in a task, and the task waits for the bot to be ready
Yeah but do you have them in your code at all
intents = discord.Intents(messages=True, guilds=True, reactions=True)
bot = commands.Bot(command_prefix = "!", intents = intents)
thats how my library does it
its not discord.py
What library is it
edpy
what?
enhanced discord py
That’s literally the same thing
It’s just a fork
With mods.
I doubt they changed the intent system. Do what I said and try again.
they did, i got told so. other bots i did like this work
but ok, let me try
actually, i do get some discord api related stuff
well well a new app worked
wow literally nothing changed
Got told so and it worked on other bots i worked with 
Not sure who told you that garbage but it’s false.
anyways, thanks for helping out here I guess 
It ended up working in the end?
yeah, so do other of my bots 
low prays vps?
Anybody else having their utils.get or utils.find returning non-objects and non-Nonetype values
Good vps bot low prays and option paysafecard
.
can I hold reference to one msg in another channel msg?
I want channel with history of specific content but copied from original message, and if someone edits the message I need original message reference to be in body of history channel message
I know 😄
right now I am comparing msg.content
which is shitty solution
I would like to have id of one message in another message as a reference
Can someone help me? My on_reaction_add event is only being called when the bot reacts to a message and not when someone else reacts to a message
I don't know why this is happening it used to work, then I tried to change the event and it stopped working so I reset my version to the original code but that doesn't work anymore
Can you send your code?
!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.
@client.event
async def on_reaction_add(reaction,user):
print(reaction.message.author)
print(user.name)
print(reaction.emoji)
if str(reaction.message.author) == "mybot#3923" and reaction.emoji == "🖕" :
await reaction.message.channel.send("Hey don't react with that emoji to me!")
print("hi")
print("hsjhsdjsds")
here sorry it took so long
it only prints when its the bot itself that reacts
i have no idea why since the event should be called when anyone reacts
print(reaction.message.author)
print(user.name)
print(reaction.emoji)
This code used to work perfectly fine until today
Before I try and think of why this isn't working, you know you can also do
reaction.message.author == client.user
```to test if it's the bot user right?
Better in the long run
oh yeah I just forgot to update it
I never had any enabled before when it was working however today I tried enabling to see if they would work
I have them all enabled now
Have you tried using on_raw_reaction_add?
yes and it worked I was just unsure of how to get the message author and reaction with that and wanted to find out why
on_reaction_add
would not work
How would I access the author and emoji if I use that because it only takes in payload?
class discord.RawReactionActionEvent```
Represents the payload for a [`on_raw_reaction_add()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_add "discord.on_raw_reaction_add") or [`on_raw_reaction_remove()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_reaction_remove "discord.on_raw_reaction_remove") event.
When I run it I get told that reaction and user does not exist
in
print(reaction.message.author)
print(user.name)
If you're using on_raw_reaction_add, it's because it has different argument passed in than on_reaction_add
so how would I get the author and emoji with on_raw_reaction_add through the payload?
payload.emoji and payload.user_id
Or if you have member intents, you might be able to do payload.member
But to get the message, you can only get the id
Is there a way to get the user who added the reaction in a dm, since payload.member is only for guilds?
I dont see a parameter to do this so I assume you can't
I think I finally figured out why this did not work
apparently now the on_reaction_add will only work in a guild
so that is why it is not called
I was testing it in a dm
I just have one question
I am new to programming
do you know how this is better?
since they do the same thing
is there any way to get all attributes of a channel in one variable for discord.py?
like all the permissions, position, name, etc
and then use it later to make the channel again
If you want to remake the channel you won't need to save all the attributes of the channel you can use .clone instead
!d discord.TextChannel.clone
await clone(*, name=None, reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Clones this channel. This creates a channel with the same properties as this channel.
You must have the [`manage_channels`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_channels "discord.Permissions.manage_channels") permission to do this.
New in version 1.1.
no not clone like basically when a channel is deleted it just makes it again from data it already has stored
but idk how to get the permissions and stuff in a variable
if you really need to get all the attr, use inspect.getmembers(), returns a list of tuple of (name, value), so:
import inspect
attr_dict = {name: value for name, value in inspect.getmembers(Channel) if not name.startswith("_")}
it says invalid syntax
name: channel.name what's this
the name of the channel
ok
it works thanks, but how would i create the channel again exactly with this info?
oh, you want to create a channel with it
ye
remove the if not name.startswith("_") part
ok
you probably should've use .clone() its 1000% easier
noo im trying to make it so that when my bot joins a server, it stores all the channels & their attributes and then after that in the future if the channel is ever deleted then it can easily recreate it with the data it already has
Store the channel in a variable, when the channel is deleted call .clone() on the variable
but, you can use this:
channel = guild.create_text_channel(type("channel", (object,), attr_dict))
```not sure if this will work but just try
what
hmm?
would it clone the permissions and all?
yes
It creates a channel with all of the same properties
So yes, it does create it in the same position
ok
how do i store thw channel in a variable
so what's the "what" here
get_channel()
wait, the channel which just cloned?
whats with that code lmao
no in the first step io have to get the channel and store it in a diff file or something and then when it is deleted i retrieve that info and clone it
but how doo i store it in a variable
is it just await get_channel(channel.id)
he wanted to make a channel with the raw attributes?
so I made it with the raw way, type()
That just makes no sense here
yh it works i did it like this
tysm
wait i dont think it works when i do it like this the result was this
at least I did it in the way the wanted ¯_(ツ)_/¯
you have the channel object already, you dont need to get it again
wdym
i dnt think this works with putting channels in the right categories
.clone internally does get the attributes as well
And with what you did I'm pretty sure something would've broken
Probably with the bases
??
how can i use discord.Game to retrieve the name of the game a user is playing
bot.guild_ids = []
async def get_guild_ids(bot):
for guild in bot.guilds:
await bot.guild_ids.append(guild.id)
get_guild_ids(bot)
print(bot.guild_ids)
Warning (from warnings module):
File "C:\Users\cwals\Documents\GitHub\proxy-testing\main.py", line 70
get_guild_ids(bot)
RuntimeWarning: coroutine 'get_guild_ids' was never awaited
[]
If I await it it doesn't run. Gives me the error await outside function
How can I print the actual error in this code instead of a discord object:
@decode.error
async def decode_error(error, ctx):```
you have to await async functions like so: await get_guild_ids
if i await it it crashes
Oh right
you can only use await in async functions
so you'd have to have something like this
async def caller()
await get_guild_ids()
and to run caller in the first place you need an async loop
async for loop?
i've never heard of the term async loop
you basically need to make a loop that can run async functions
which has to be an async loop
oh i get what you're saying now.
i forgot loops existed
yah its pretty unnecessarily complex
Does anyone know how to keep the name and value in embed message on the same line?
so for example it would show "ping: shows latency in ms" all in one line
Cant you just write name="Ping: {latency}"
i think when i do that it gives me a error saying there is not a value set but let me try it real quick
embed field needs name and value as the required argument
right so just dont put anything in value
like an empty string might work
no
just use the embed's description
is asyncio different from async?
async is a function asyncio calls the function
could you possibly tag somewher i could learn about async loops?
not an async loop?
it's supposed to call the guild function but it didn't work so i changed it
Yah sure one moment I have a great tutorial
this guy teaches it well https://www.youtube.com/watch?v=t5Bo1Je9EmE
In today's video, I'll be talking to you about asynchronous programming in python. This Python Async tutorial will cover the 'async' and 'await' keyword, coroutines, futures and tasks, and some basic features from the asyncio module in Python. This video is for intermediate programmers, and it's recommended you have Python 3.7 or above.
💻 Algo...
yeah, but I eventually made the worst way to clone a channel using the attributes
import inspect
attr_dict = {name: value for name, value in inspect.getmembers(ctx.channel) if name != "__slots__"}
channel = await type("channel", (discord.abc.Messageable, discord.abc.GuildChannel, discord.mixins.Hashable,), attr_dict).clone()
I can't find a way to create a channel using the object
What do you mean create a channel using the object?
so, like I have a TextChannel object already, do they have anything regarding creating a channel using the object? Currently Guild.create_text_channel() doesn't support it
You already have the object, why would you create a new channel using the object? Or do you mean discord wise?
You would need to read the data via the HTTPClient and send a POST request to the guilds channel
then update the guilds internal channel cache
can't you do it without messing with HTTPClient?
from discord import command
this is wrong what is the correct one?
i forgot ;-;
No otherwise it won't show up on discord
Discord.py creates objects which keyword, represents the discord object
It requires the HTTPClient and the gateway in order to make the objects act upon the objects they represent
just to be clear it is required to await an append correct?
from discord.ext import commands
oo thanks
also after watching this video i have yet to find a solution to my problem.
anytime ^^
I mean, are there any built-ins which allows me to create a channel using the object? (I don't really want to send a raw request by my own, let the lib does that for me)
Haven't you constructed a channel object already?
bot.guild_ids = []
async def get_guild_ids(bot):
for guild in bot.guilds:
await bot.guild_ids.append(guild.id)
asyncio.get_event_loop().run_until_complete(get_guild_ids(bot))
print(bot.guild_ids)
======== RESTART: C:\Users\cwals\Documents\GitHub\proxy-testing\main.py ========
[]
All I'm trying to do is append all of the guilds (their ids) that the bot is in into the list.
Is there anyway to get the number of messages a member has sent in a guild
yes this
Holdon
wait until the bot's ready
discord/http.py line 845
def create_channel(```
oh
it exists
@commands.Cog.listener()
async def on_ready(self):
async def get_guild_ids(self):
for guild in self.bot.guilds:
await self.bot.guild_ids.append(guild.id)
asyncio.get_event_loop().run_until_complete(get_guild_ids(self))
print(bot.guild_ids)
RuntimeWarning: coroutine 'Events.on_ready.<locals>.get_guild_ids' was never awaited
It just crashed.
append is not a coroutine, you do not await it
wait, but it accepts only guild_id, ChannelType, reason and the things in valid_keys it doesn't accept TextChannel or any object
And your in a coroutine
You don't need to do run_until_complete
Just await get_guild_ids
Why do you even have this in a nested function?
Just do it inside of on_ready without the nested function, you don't need it
i forgot to change my logic when i copied and pasted it from the main file.
instead of this being a certain channel can i somehow make it get the history in all channels in the guild
counter = 0
async for message in channel.history(limit=200):
if message.author == client.user:
counter += 1
i've used the append function so many times before. i have no clue why it stays in my mind as if it needs to be awaited.
You pass kwargs to the function hence **options which is used to create the payload and channel_type would be the discord.py enum for text channel
so I need to pass the kwargs manually?
Iterate through the attrs of the channel
Example: If it wasn't slotted you could do for name, value in obj.__dict__.items():
i know but as it's slotted i need to use inspect.getmembers()
It's sloted so they have the names
That means you can use getattr
getattr() everything in the slot?
what kind or error is that
import inspect
attr_dict = {name: value for name, value in inspect.getmembers(ctx.channel) if name != "__slots__"}
channel = await bot.http.create_channel(ctx.guild.id, 0, **attr_dict)
print(channel)
```this works but doesn't create the channel in the right position
Does attr_dict contain a position?
yes, 55
oh wait, the method doesn't have category kwarg?
You would have to reverse engineer create_text_channel in discord.py ¯_(ツ)_/¯
I'm busy right now as I'm implementing application commands
Otherwise I'd give more in-depth help
why is it so hard to just create a channel with the object 😔
Because that just sounds dumb in itself
oh, I realized that parent_id is equivalent to CategoryChannel.id
worked!!
code:
import inspect
attr_dict = {name: value for name, value in inspect.getmembers(ctx.channel) if name != "__slots__"}
channel = await bot.http.create_channel(ctx.guild.id, 0, parent_id=attr_dict["category"].id, **attr_dict)
@client.listen("on_message")
async def automated_replies(message):
if message.author == client.user:
return
if any(word in case_insensitive for word in forbiden_words):
msg = f"{message.author}, Please don't use language like that."
await message.channel.send(msg)
await message.delete()``` Any ideas why message.delete isnt working?
You need to delete the default help command
Which is done by
Uh
Idk I forget the exact wording
client.remove_command("help")```
subclass the help cmd instead of removing it and creating a new one , its a lot more efficient
!d discord.ext.commands.HelpCommand
class discord.ext.commands.HelpCommand(*args, **kwargs)```
The base implementation for help command formatting.
Note
Internally instances of this class are deep copied every time the command itself is invoked to prevent a race condition mentioned in [GH-2123](https://github.com/Rapptz/discord.py/issues/2123).
This means that relying on the state of this class to be the same between command invocations would not work as expected.
how do i check if someone is the owner of the guild?
in a command?
yeah
you can compare author's id with guild owner's id
if ctx.author.id == ctx.guild.owner_id```
yeah ik i can but im not trying to
i wanna check if the person is the guild owner without a id or name
i dont think u can
you mean like a decorator check?
its like recognising a person wihout identification card
unless u know that guy if not u are not gonna know who is him
you can make a custom check , and use it
all inbuilt checks do the same
btw why dont you want to do that by if statement?
ill check it out
dont mean that i just dont want to check with a id
there's no other way though
since ids are the recognisation of all discord objects
dang
ill check the api reference deeply
to see what i can do
sure thing
!d discord.Guild
class discord.Guild```
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
x == y Checks if two guilds are equal.
x != y Checks if two guilds are not equal.
hash(x) Returns the guild’s hash.
str(x) Returns the guild’s name.
found a way thx
im gonna check if the person has admin perms
oh nice
so @commands.has_permission() check?
yeah i think so but it was something like that
yea thats it
yeah i just checked
message.author.id will return the user ID of the message author
message object, likely you're using this when on_message is called i assume
hi i want client.events docs discord.py can anyone help
!d discord.Client
class discord.Client(*, loop=None, **options)```
Represents a client connection that connects to Discord. This class is used to interact with the Discord WebSocket and API.
A number of options can be passed to the [`Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client").
the embed title link will bring you to the documentations
thx
btw did the dm all event still works?
dont know dont use client
if you're making a discord bot, dont use discord.Client, use commands.Bot
then bot?
!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.
client if for user right?
no discord.Client()
i use discord.ext.commands.Bot
...
okay
leme switch to bot then
i know its dumb but
@bot.command(name='start')
async def start(ctx: commands.Context):
userid = ctx.author.id
if has_registered == True:
await ctx.channel.send('Do you wanna start all over again?')
else:
db[userid + 'pogchop'] = 0
db[userid + 'cooked_pogchop'] = 0
db[userid + 'beef'] = 0
db[userid + 'steak'] = 0
db[userid + 'wool'] = 0
db[userid + 'treasure_map'] = 0
db[userid + 'wither_skull'] = 0
db[userid + 'blaze_rod'] = 0
db[userid + 'blaze_power'] = 0
db[userid + 'ender_pearl'] = 0
db[userid + 'eye_of_ender'] = 0
:)
is there a better way to do this
item = {
'mobdrop': {
'pogchop' : 0,
'cooked_pogchop' : 0,
'beef' : 0,
'steak' : 0,
'wool' : 0,
'treasure_map' : 0,
'wither_skull' : 0,
'blaze_rod' : 0,
'blaze_power' : 0,
'ender_pearl' : 0,
'eye_of_ender' : 0
},
'misc':{
'cobble' : 0,
'coal' : 0,
'iron' : 0,
'diamond' : 0,
'gold' : 0,
'netherite_scraps': 0,
'netherite_ingot' : 0,
'redstone' : 0,
'soul_sand' : 0,
'wood' : 0,
'bed' : 0
},
'illegal': {
'bedrock' : 0,
'bedrock_trophy' : 0,
'pogchamp' : 0
}
}
can i use for loop for that?
ok
Y does this unban command not work?
@has_permissions(ban_members = True)
async def unban(self, ctx, member:discord.Member):
banned_users = await ctx.guild.bans()
member_name, member_discriminator = member.split("#")
for ban_entry in banned_users:
user = ban_entry.user
if (user.name, user.discriminator) == (member_name, member_discriminator):
await ctx.guild.unban(user)
await ctx.send(f'**UNBANNED {user.mention}**')
return```
This is in a cog
Error:-
discord.ext.commands.errors.MemberNotFound: Member "295499172994351105" not found.```
The user is banned
Anyone?
You cannot unban with an id because of this terrible written (not to mention copied) code
how to fix it?
||ngl it is copied||
i tried that too
Completely rewrite it
ok
Whats the error?
Cringe lucas unban
Make ur own unban command don't copy from yt
ok sry
did not get u
Your unban command only takes the full username and not an ID. If you want an ID to be unbanned use discord.User
use typing union ig
ok
what anu said
what
can you asign custom variables to commands.Bot client?
Python allows you to set custom attributes to most objects, like your bot! By storing things as attributes of the bot object, you can access them anywhere you access your bot. In the discord.py library, these custom attributes are commonly known as "bot variables" and can be a lifesaver if your bot is divided into many different files. An example on how to use custom attributes on your bot is shown below:
bot = commands.Bot(command_prefix="!")
# Set an attribute on our bot
bot.test = "I am accessible everywhere!"
@bot.command()
async def get(ctx: commands.Context):
"""A command to get the current value of `test`."""
# Send what the test attribute is currently set to
await ctx.send(ctx.bot.test)
@bot.command()
async def setval(ctx: commands.Context, *, new_text: str):
"""A command to set a new value of `test`."""
# Here we change the attribute to what was specified in new_text
bot.test = new_text
This all applies to cogs as well! You can set attributes to self as you wish.
Be sure not to overwrite attributes discord.py uses, like cogs or users. Name your attributes carefully!
can you do this and still be able to change the values when you have intents arg passed into it?
I mean sure
theres nothing blocking you
because i have tryed that with log_channel = 0 and in a on_ready i get_channel the channel and set the log_channel to it
i try to send a message to it and it says its a int and not a discord.TextChannel
I mean to get channels your supposed to do
bot.get_channel?
!d discord.ext.commands.Bot.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
ik
yes
thats what i did
Hm
Show me what u did
does intents auto default to everything enabled except members and presence intents or does it now have message default to False
Yo so a few questions. How would I go abt getting a User's ID? and if I were to want to restrict a command to only be accessed by a certain user could I just do
<code>
else:
return```
I mean it depends on how you enable the intents in code
commands.Bot(intents = intents_var)
ctx.author or if your using in a on_message use message.author
a discord.Intents.default()
So ctx.author will give ID? and not name?
just do
if ... != ur_id:
return
bot.command(name='inv')
async def inv(ctx: commands.Context):
userid = ctx.author.id
names1 = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender']
res = '__items__\n'
for name, val in {userid}names1:
res += f"{name}: {val}\n"
await ctx.channel.send(res)
```can someone help?
yes
Alright
no use .id attribute to those
Ok, thank you :D
oo why not just do all()
because i dont have presence intents
whats wrong
you know i hate it when you ask for help without telling what to help with
or message content intents
Enable it in the developer page?
wait
the logic looks sucks
lemme reorganise it
have to get them to give it to me because my bot is verified
i only have members intents so :/ and i do not need anything else
The command prefix is what the message content must contain initially to have a command invoked. This prefix could either be a string to indicate what the prefix should be, or a callable that takes in the bot as its first parameter and discord.Message as its second parameter and returns the prefix. This is to facilitate “dynamic” command prefixes. This callable can be either a regular function or a coroutine.
An empty string as the prefix always matches, enabling prefix-less command invocation. While this may be useful in DMs it should be avoided in servers, as it’s likely to cause performance issues and unintended command invocations.
I mean u could try that
hm well idkr lol
looks like prefix variable's value is "prefix"
so you're still confused why you got the error or what
im 100% sure something is going on because in the on_ready where it sets the bot_log_channel to a channel it also sends this to the log channel too say when it started
what do you exactly need help with
Wheres this in your code it might be overwriting the variable
Did you not read his error?
because you already fixed your error with those 3 screenshots
you assigned 0 to the attribute
hence its an int
int has no attribute as send
hang on
the on_ready listener is not being called???
why would this be
if i dont use intents it is called but if i parse intents into commands.Bot its not called
I rewrote it. this returns a error
@has_permissions(ban_members = True)
async def unban(self, ctx, *, member):
print(member)
user = await self.bot.get_user(member)
if user is not None:
try:
await ctx.guild.unban(user)
await ctx.send(f'UNBANNED {user.mention}')
except:
await ctx.send(f'{user.mention} IS NOT BANNED')```
Error:-
```user = await self.bot.get_user(member)
TypeError: object NoneType can't be used in 'await' expression
The above exception was the direct cause of the following exception:
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object NoneType can't be used in 'await' expression```
who are we supposed to know that without code
@bot.command(name='inv')
async def inv(ctx: commands.Context):
userid = ctx.author.id
names1 = ['pogchop', 'cooked_pogchop', 'beef', 'steak', 'wool', 'treasure_map','wither_skull', 'blaze_rod', 'blaze_power', 'ender_pearl', 'eye_of_ender']
names2 = ['cobble','coal', 'iron', 'diamond', 'gold', 'netherite_scraps', 'netherite_ingot', 'redstone', 'soul_sand', 'wood', 'bed']
names3 =['bedrock', 'bedrock_trophy', 'pog_champ']
res = '__items__\n'
for name in names1:
res += f"{name}: {userid}{name}.values()\n"
res += '__misc__\n'
for name in names2:
res += f"{name}: {userid}{name}.values()\n"
res += '__illegal__\n'
for name in names3:
res += f"{name}: {userid}{name}.values()\n"
await ctx.channel.send(res)
```output
items
pogchop: 757508305256972338pogchop.values()
items
pogchop: 0
ok the on_ready is finaly called????? wtf is this
{name.values()}
lemme try
dont think thats going to help though
This ^^
it couldn't get the user from cache so user is None.
You have to fetch it
so fetch_user?

u should use discord.User
member: discord.User
just typehint it to discord.User
also member is string there
also why have *
the code is fully wrong rewrite again
you cant
actually there are better ways to unban users
i could easily make an unban command with 3 lines
item = {
'mobdrop': {
'pogchop': 0,
'cooked_pogchop': 0,
'beef': 0,
'steak': 0,
'wool': 0,
'treasure_map': 0,
'wither_skull': 0,
'blaze_rod': 0,
'blaze_power': 0,
'ender_pearl': 0,
'eye_of_ender': 0
},
'misc':{
'cobble': 0,
'coal': 0,
'iron': 0,
'diamond': 0,
'gold': 0,
'netherite_scraps': 0,
'netherite_ingot': 0,
'redstone': 0,
'soul_sand': 0,
'wood': 0,
'bed': 0
},
'illegal': {
'bedrock': 0,
'bedrock_trophy': 0,
'pogchamp': 0
}
}
###################################
@bot.command(name='inv')
async def inv(ctx: commands.Context):
userid = ctx.author.id
res = '__items__\n'
for name in item['mobdrop']:
res += f"{name}: {userid}{name.values()}\n"
res += '__misc__\n'
for name in item['misc']:
res += f"{name}: {userid}{name.values()}\n"
res += '__illegal__\n'
for name in item['illegal']:
res += f"{name}: {userid}{name.values()}\n"
await ctx.channel.send(res)
```idk why its not working
member = discord.Object(id=0) # user ID
try:
await guild.unban(member)
except discord.NotFound:
# member not banned / doesnt exist
😂
which part of it isnt working
maybe soon 👀
well as you see name is a string
the element item holds the name of the key, you have to get the value from the dict yourself
i would suggest to store it this way,
names = [("key1",0),("key2",0),("key3",0)]
for key, value in names:
...```
if the value is not going to be changed
from 0
otherwise use dict
the number will be different for different user
_dict = dict(name1="test")
for item in _dict:
print(_dict.get(item))```
or,
_dict = {"name1":"test"}
for item in _dict:
print(_dict.get(item))
didn't i show you an example like 5 messages above
to get the value of item
_dict = {"name1":"test")}
for item in _dict:
print("name", item)
print("value",_dict.get(item))
you could just do that
got it ty
Did anyone realize https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.create_text_channel has no permissions kwarg it just has an overwrites kwarg thats similar to permissions
output
items
pogchop: userid
cooked_pogchop: userid
@bot.command(name='inv')
async def inv(ctx: commands.Context):
userid = str(ctx.author.id)
res = '__items__\n'
for name in item['mobdrop']:
userid += name
res += f"{name}: userid\n"
res += '__misc__\n'
for name in item['misc']:
userid += name
res += f"{name}: userid\n"
res += '__illegal__\n'
for name in item['illegal']:
userid += name
res += f"{name}: userid\n"
await ctx.channel.send(res)
whats wrong lmao
lemme try
res += f"{name}: {userid}\n"
looks like you have no idea how f strings work
@bot.command(name='inv')
async def inv(ctx: commands.Context):
res = '__items__\n'
for name in item['mobdrop']:
userid = str(ctx.author.id)
userid += name
res += f"{name}: {userid}\n"
res += '__misc__\n'
for name in item['misc']:
userid = str(ctx.author.id)
userid += name
res += f"{name}: {userid}\n"
res += '__illegal__\n'
for name in item['illegal']:
userid = str(ctx.author.id)
userid += name
res += f"{name}: {userid}\n"
await ctx.channel.send(res)
how do i print the value of {userid}
{userid.values()}?
the value is in database
well i give up i have wasted alot of time
@client.command()
async def activity(ctx, arg1, arg2):
if ctx.author.id == 591047383044063244:
if arg1.lower == 'listening':
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=arg2))
elif arg1.lower == 'playing':
await client.change_presence(activity=discord.Game(name=arg2))
elif arg1.lower == 'watching':
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=arg2))
elif arg1.lower == 'streaming':
await client.change_presence(activity=discord.Streaming(name=arg2, url='url'))
else:
await ctx.send('This command is for Wind only!')```
I am trying to create a command that will let me change the presence within discord. This is what I came up with but it is not responding. I had an else statement there and it would only reply with the else statement.
o shit advertising, mb hold on
:(
this is why you complete your basic course of python before using libs like discord.py.
you seem to have no idea what methods are, the only thing you care about is getting your values() somehow work no matter what object it is
this is my message to a person yesterday. hope this helps
alright
i just realised what is wrong
...
the key in dictionary and in my database is different
one missing _
🤦
but i want it to begin from 0
how do you fix corutine 'x' was never awaited
i tried adding the loop but diidn work
@warped spear await x()
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/Users/aarav/Documents/GitHub/awaffle_bot/main.py", line 314, in help
await message.clear_reactions()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/message.py", line 1309, in clear_reactions
await self._state.http.clear_reactions(self.channel.id, self.id)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/http.py", line 248, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/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: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions```
im getting this whenever i put a reaction
on the bot
's embed
where code
sry did it alr
are there any api which can allow my bot to have a kill function
Your bot didn't have the perms
like dank memer
Kill?
yup dolved it
so theres no api?
Nah
oh
could someone help
then find it with 0 not 1 then?
it'll still return the same error
why would it?
the first time i run the command, it'd return this ```py
Ignoring exception in command auc:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 167, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\user\Desktop\theBot\cogs\dankdaily.py", line 166, in auc
for x in points_count:
TypeError: 'NoneType' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 994, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 894, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 176, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'NoneType' object is not iterable```
well poins_count is none
im making a help command for my bot but it gives an error saying
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1280, in decorator
self.add_command(result)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1149, in add_command
raise CommandRegistrationError(command.name)
discord.ext.commands.errors.CommandRegistrationError: The command help is already an existing command or alias.
and the code is this:
@client.group(invoke_without_command=True)
async def help(ctx):
em = discord.Embed(tittle = "Help", description = "Use ?help <command> for extented info on a command.", color = ctx.author.color)
em.add_field(name = "Modration", value = "Kick, Ban, Unban, Mute And Unmute")
em.add_field(name ="Fun", value = "No fun commands yet")
await ctx.send(embed = em)
@help.command()
async def kick(ctx):
em = discord.Embed(tittle = "Kick", description = "Kicks a member from the server", color = ctx.author.color)
em.add_field(name = "Example", value = "?kick {User} {Reason} eg ?Kick Mixu#0720 Get out!")
await ctx.send(embed = em)
@help.command()
async def ban(ctx):
em = discord.Embed(tittle = "Ban", description = "Bans a member from the server", color = ctx.author.color)
em.add_field(name = "Example", value = "?ban {User} {Reason} eg ?ban Mixu#0720 Get out!")
await ctx.send(embed = em)
@help.command()
async def unban(ctx):
em = discord.Embed(tittle = "Unban", description = "Unbans a member from the server", color = ctx.author.color)
em.add_field(name = "Example", value = "?unban {User} {Reason} eg ?unban Mixu#0720 Appealed")
await ctx.send(embed = em)
@help.command()
async def mute(ctx):
em = discord.Embed(tittle = "Mute", description = "Mutes a member", color = ctx.author.color)
em.add_field(name = "Example", value = "?mute {User} {Reason} eg ?mute Mixu#0720 spamming!")
await ctx.send(embed = em)
@help.command()
async def unmute(ctx):
em = discord.Embed(tittle = "Unmute", description = "Unmutes a muted member", color = ctx.author.color)
em.add_field(name = "Example", value = "?unmute {User} {Reason} eg ?unmute Mixu#0720 mute appealed.")
await ctx.send(embed = em)
you might want to disable the default help command if you want to make your own
how?
!d discord.ext.commands.Bot.remove_command
remove_command(name)```
Remove a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") from the internal list of commands.
This could also be used as a way to remove aliases.
do that first before making a help command
How do i send a message to a specific channel in every guild?im close but it only sends it to one
you have to get the guild the channel is in + the channel for that guild
Loop through the channels?
BTW that will rate limit u hard
Rn my code looks like this im on mobile so indents are bad:
for guild in bot.guilds:
for channel in guild.channels:
if channel.name == "name":
h = channel.id
await bot.get_channel(h).send("msg")
Looks like that but idk if the for loop are right
I see
Why not simply do
if channel := discord.utils.get(guild.channels, name="name"):
await channel.send()
!d discord.utils.get
discord.utils.get(iterable, **attrs)```
A helper that returns the first element in the iterable that meets all the traits passed in `attrs`. This is an alternative for [`find()`](https://discordpy.readthedocs.io/en/master/api.html#discord.utils.find "discord.utils.find").
When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have to meet every attribute passed in and not one of them.
To have a nested attribute search (i.e. search by `x.y`) then pass in `x__y` as the keyword argument.
If nothing is found that matches the attributes passed, then `None` is returned.
Examples
Basic usage...
Idk tbh
Bruh
I edited does it look right now cause idk if the for loops are right @maiden fable
Too lazy lmao
or just do what I did..?
isnt that API abuse
I mean idk its just one message in one channel per guild might give it a delay too
i already inserted it tho..
huh
Can i just add asyncio.sleep()after the await so everytime it sends a message it goes to sleep?or does it not work like that
I mean ig
Ima calculate the rate limit so i can see how much time i need
Thx but i still have the same problem
can someone help? https://mystb.in/SalemRecorderMunicipality.python
error says it right there it cant import the objects
what do i do then
install it
install what
Wouldn't that raise a module not found exception..?
oh... right
are you using replit?
yeah
then thats the problem I'd say. I don't think replit has that module there
oh
How do bots even get bigger ratelimits?
they dont
Didnt big bots like the verified ones get bigger rate limits?
rate limit is depends on invites
On invites?
discord will increase the limit to get ratelimited if your bot gets big (gets invited by many people)
what does that mean
I see thx
They send support requests to discord to increase their ratelimits
Good vps bot low prays and option paysafecard
guys i need help im not sure how to fix this it isn't working for some reason and i tried fiddling with it for about 20 min now
did you import discord?
if you dont get any error, you should enable intents from dev portal
and enable it your code as well
!intents
Using intents in discord.py
Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default, discord.py has all intents enabled, except for the Members and Presences intents, which are needed for events such as on_member and to get members' statuses.
To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.
Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:
from discord import Intents
from discord.ext import commands
intents = Intents.default()
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.
how would i go about making my help command do something like -help ban
and list a new embed
about the ban command
just if it
how did i not think about that
is that sarcastic or did you forget to use it?
I really didnt think of that
somehow
ok
if message.content.lower() in any(['welc','welcome','welc']):
TypeError: argument of type 'bool' is not iterable
Remove the any
well i added intent yet it didn't do anything
@slate swan do u have intents?
presence intents
dev portal
!d discord.Intents.presences
Whether guild presence related events are enabled.
This corresponds to the following events:
This also corresponds to the following attributes and classes in terms of cache...
also better do discord.Intents.all() and remove intents.members = True
Yea
yes

