#discord-bots
1 messages · Page 600 of 1
yup.
you did add the bot.add_cog() at the end of your cog file?
Also you may have an issue which is why the cog isn't showing. I would recommend adding a try/except statement in there to handle errors.
Just like the video
RePlIt
Yes I can’t use vsc cuz chromebook
Yes I use chromebook to. I also made my own discord bot.
yes you can. i started programming on a CB
just visit their site and download the tar file or .deb file and run it in the terminal
Well you can run it using chromebook crostini
Ahh ok
or whatever linux distro you have.
Or use wine
Ima stick to repl for now lol
Yes you can. I made my own discord bot
indents
try:
await client.load_extension(f"cogs.{filename[:-3]}")
print(f"{filename[:-3]} has loaded.")
except Exception as e:
print(f"Failed to load {filename[:-3]} : {e}")
On why there’s no error
functions inside classes must be on the same line the init dunder is called
yes and like Kayle said make sure you are indented in your cog. ^^
!e
class a:
def __init__(self, bot):
self.bot=bot
def ping(self):
print(1)
a=a("j")
a.ping()
``` this is what ur tryna do lol
@boreal ravine :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 7, in <module>
003 | AttributeError: 'a' object has no attribute 'ping'
what is the whole a=a("j") portion for?
does any one have a method of getting the guild in on_user_update(before: discord.User, after: discord.User)
ok so i add the role with Guild.get_role() first
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 254, 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 "D:\gg$\Cloner + Nitro claimer\Zzz.py", line 319, in <module>
client.run(token, bot=False)
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 723, in run
return future.result()
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 702, in runner await self.start(*args, **kwargs)
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 665, in start
await self.login(*args, bot=bot)
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 304, 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 0x000001D28A4B81F0>
Traceback (most recent call last):
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py", line 108, in close
```...
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 745, in call_soon
self._check_closed()
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```
why?
data = await self.request(Route('GET', '/users/@me'))
File "C:\Users\damie\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
is this a selfbot?
Yes, don't worry, there's no nuke thing or anything
...
Selfbotting is against discord's terms of service, regardless of your intentions.
you do know self bots arent allowed right
Yes, don't worry, there's no nuke thing or anything
yes^^
tell me when your done so you can help me
we're done.
Do you know why it doesn't want to light up anymore?
well imma need some help
ok
i kind of have not use python in like a year so i pretty much remember nothing
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", timeout=10, check=check)
if str(reaction.emoji) == "▶️" and cur_page != pages:
cur_page += 1
await message.edit(embed=embed1)
await message.remove_reaction(reaction, user)
elif str(reaction.emoji) == "◀️" and cur_page > 1:
cur_page -= 1
await message.edit(embed=emb)
await message.remove_reaction(reaction, user)
else:
await message.remove_reaction(reaction, user)
except:
pass``` no errors, problems in the video
:x
ok
so imma trying to make my discord dm people with a certin roles
and i forgot how to start
i also forgot how to do loops
so imma need some help
add to your check to allow for checking the reaction.message.id == message.id
@brittle ingot do you have any idea why he doesn't want to? :c
if reaction.message.id != message.id:
pass```?
no and we will not help you if you self bot.
yes
can you explain what you would like to do in more detail. What you expect to happen, etc.
ok
does the same thing
please :c
@slate swan skidling leave the server u wont get help breaking tos
no its against the rules of this server and discord's terms of service. make a legitimate bot.
🙄
def check(reaction, user):
-.-
damn hold up
def check(reaction, user):
return reaction.message == message and user == ctx.author
oh alright
ok so i trying to make this discord bot im makeing dm people with a specific role a certain question like if i do !quest it will ask the people with the hero role if they would like to start a quest
i can figure out out to code my bot to do that
ahh gotcha. and they reply with something? or they just come into the server?
currently have this
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"]
return reaction.message == message and user == ctx.author
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", timeout=10, check=check)
if str(reaction.emoji) == "▶️" and cur_page != pages:
cur_page += 1
await message.edit(embed=embed1)
await message.remove_reaction(reaction, user)
elif str(reaction.emoji) == "◀️" and cur_page > 1:
cur_page -= 1
await message.edit(embed=emb)
await message.remove_reaction(reaction, user)
else:
await message.remove_reaction(reaction, user)
except:
pass
``` and it does the same thing 😭
they they respond with something
the second return is unreachable code... just add it to the first return
ok
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"] and reaction.message == message and user == ctx.author```
like that?
yes
long line lol
yeah 😂
wanna see my heaviest line?
pages = 5
cur_page = 1
gsperms = discord.Embed(color=0x2f3136, title="", description=f"**General Server Permissions**\nView Channels:{vich}\nManage Channels:{mach}\nManage Roles:{marl}\nManage Emojis and Stickers:{meas}\nView Audit Log:{val}\nManage Webhooks:{mw}\nManage Server:{ms}")
gsperms.set_thumbnail(url=member.display_avatar)
mperms = discord.Embed(color=0x2f3136, title="", description=f"**Membership Permissions**\nCreate Invite:{ci}\nChange Nickname:{cn}\nManage Nicknames:{mn}\nKick Members:{km}\nBan Members:{bm}\n")
mperms.set_thumbnail(url=member.display_avatar)
tcperms = discord.Embed(color=0x2f3136, title="", description=f"**Text Channel Permissions**\nSend Messages:{sm}\nSend Messages In Threads:{it}\nCreate Public Threads:{cm}\nCreate Private Threads:{cpm}\nEmbed Links:{el}\nAttach Files:{af}\nAdd Reactions:{ar}\nUse External Emojis:{uee}\nUse External Stickers:{ues}\nMention Everyone:{me}\nManage Messages:{mm}\nManage Threads:{mt}\nRead Message History:{rmh}\nSend TTS Messages:{tts}\nUse Slash Commands:{usc}")
tcperms.set_thumbnail(url=member.display_avatar)
vcperms = discord.Embed(color=0x2f3136, title="", description=f"**Voice Channel Permissions**\nConnect:{con}\nSpeak:{sp}\nPriority Speaker:{ps}\nMute Members:{mute}\nDeafen Members:{dfm}\nMove Members:{move}")
vcperms.set_thumbnail(url=member.display_avatar)
aperms = discord.Embed(color=0x2f3136, title="", description=f"**Advanced Permissions**\nAdministrator:{adm}")
aperms.set_thumbnail(url=member.display_avatar)```
originally it was all in 1 description
before i paged it
alright so we want to do a couple of things. we wanna fetch the role, either by ID or name. we can use get_role(role-id) if you wanna do id. otherwise we can use utils.get(ctx.guild.roles, name="role-name") if you wanna get by name. then we can check the guild's members for that role and if they have the role dm them, if not pass. However depending on the member count of the server this might be abusive. so we could use a database store the IDs of members who have the role. and just use a for loop to go through that list of member get_member(stored-id) and then send the DM to the member we got.
now it doesnt work at all
you have ctx.author == user in there twice, although i don't think that has anything to do with it.
return user == ctx.author and str(reaction.emoji) in [":arrow_backward:", ":arrow_forward:"] and reaction.message == message```
there
ok get_role(role-id) i have the id what @ do i put this code under
like under @bot. commands()
yeah you want it to be a command right?
yea
bump
then yes under the command decorator.
is there a way I can get all the reactors of a message with discord ,oy
!d discord.Reaction.users
async for ... in users(*, limit=None, after=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") representing the users that have reacted to the message.
The `after` 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.
Examples
Usage
```py
# I do not actually recommend doing this.
async for user in reaction.users():
await channel.send(f'{user} has reacted with {reaction.emoji}!')
```...
Number of times this reaction was made
second is only one reaction though.
like this
no
This cog is still broken fml 🤦♂️
damn
im really bad at this thx for helping me tho
how do I do it with a specific channel Id though
does reaction.users take any params for channel id?
await reaction.users().flatten()
so you will need to define a function which will act as the command.
@bot.command()
async def startQuest(ctx):
role = ctx.guild.get_role(role-id)
from there you can loop through the servers members (you can get a guild instance from ctx) and check if the role is in each members roles.
channel id? how will it know which message then?
ok ill set this up
ill get back to you
sorry i meant message id
how do i make a server lock command, that locks all channels instead of just one?
ahh okay, you want to get the message from the channel instance. or just
message = await client.fetch_message(message-id) #not recommended if using alot as its an API call.
from there you can get the messages reactions. with message.reactions and go from there.
like this
u need to change the permission of channels
you will need to loop through the channels in the server and change the permissions for the select role to lock the channels. (again not recommand as its seen as api abuse) but do able.
api abuse?
At that point wouldn't it be better to just make a new role that has no send messages perm
You would still need to assign it to everyone though, wouldn't you? which is the same but just another way?
Ah yea I totatlly over looked that aspect
But either way discord.py should be handling the ratelimits so this is "safe" ish to do
quickly changing settings or better known as using the API for a use its not intended for. Discord servers aren't set up to be locked like that even though its possible.
wouldnt that just take a lot longer
true
it depends on the member count vs channel count as well.
If you really want to be in the clear, I'd just read the response headers grab the X-Ratelimit- headers and look for reset after
Sleep that amount and do it again
hmm
But, then again that's why discord.py does internally
oh that's smart.
Quite slow although as they have locks instead of semaphores
but what about raids happening?
ah
or has never been used
I imagine discord didn't plan for that eventuality until it happened which is why its part of their guidelines and not part of their platform as far as safety measures. I'm not saying don't do it, im just saying beware of ratelimits and code accordingly to handle them like Andy was saying.
alright so whats next? We need to loop through the members of the guild with a for loop correct?
ohh okay thank you
yes
ohh okay thank you
to dm every member with that role
that will be a bit further along. So firstly we know that ctx.guild has a members attribute and according to what we know about for loops we can do something like:
for member in ctx.guild.members:
... #check if role in member.roles
ok where do i set this up
right under getting the role. since it will be a part of the command
great, so now inside that for loop we want to check if role in member.roles
property members: List[Member]```
Returns all the members with this role.
ok so discord.Role.members
role.members
so you would do:
members = role.members
we would still need to loop through them though andy.
so i have to put that in the same command line
below where you get the role but above the for loop, and we will modify that for loop to incorporate this.
Pretty sure you can just... ```py
if member in role.members:
ok ill set that up
we want to send a DM to every member that has that role
yes
Ah ok, that's understandabe
Faster than iterating through guild.members
so now we will change that for loop to ```py
for member in members:
... # send message to member with member.send()
yeah, i can see what you mean with that, plus no need to check every member for the role.
now member objects have a send attribute you can use to send them a DM. You will want to put it in a try/except though as some members may have DM's for a server turned off.
ok wait my mind went blake say that again
you can send a DM to a member using the .send() method on the member object. so inside the for loop we can do something like:
try:
message = await member.send("my-message")
... other code waiting a reply
except discord.Forbidden:
pass
try: should be its own line with the message on the next line inside the try block
should look like:
try:
message = await member.send("Would you like to start the battle?")
except discord.Forbidden:
pass
what happened to the for loop? we need that
oh wait it got cut off while i way typeing ill fix it
there i fix it
i press enter and moved it up
my bad
How to invoke another command in a Command
Ctx.invoke iirc
!d discord.ext.commands.Context.invoke
await invoke(command, /, *args, **kwargs)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Calls a command with the arguments given.
This is useful if you want to just call the callback that a [`Command`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command") holds internally.
Note
This does not handle converters, checks, cooldowns, pre-invoke, or after-invoke hooks in any matter. It calls the internal callback directly as-if it was a regular function.
You must take care in passing the proper arguments when using this function.
alright so we've sent the message, we've handled if the member has DM's turned off for the server with a try/except. Now in the try portion of the try/except right below where we send the message we want to make a check so it will be something like this:
def check(m):
m.author != m.author.bot and m.channel == message.channel
next we will use that check in a wait for which will tell the bot to wait for a response from the member we sent the message to.
try:
msg = await bot.wait_for('message', check = check, timeout = 60)
if msg.content,lower() == "yes":
await ctx.send(f"{member.display_name} is ready to start")
elif msg.content.lower() === 'no':
await ctx.send(f"{member.display_name} is not ready to start")
else:
pass
except asyncio.timeoutError:
await ctx.send(f"No response from {member.display_name}")
What we are doing is creating the code that will handle the response. if you have any questions let me know and i can walk you through it.
ok
first thing first i have to put /def check(m):
m.author != m.author.bot and m.channel = message.channel
/ under the first tryand except
inside the try portion of the try / except right under where you send the message to the member. (right under member.send line)
You may need to import asyncio if you haven't already.
think i all ready have
add a return right before m.author != m.author.bot (sorry complete fudged that)
so should be:
def check(m):
return m.author != m.author.bot and m.channel == message.channel
sorry
how can i get a user object from an abc.Snowflake
!d discord.Client.get_user
get_user(id, /)```
Returns a user with the given ID.
np i greatful your even helping me
Perhaps you meant not m.author.bot instead of m.author != m.author.bot
could also do !m.author.bot too right? or im i confusing that with js
Author.bot is a bool
oh yea it is
thats js nevermind (haven't actually touched python in months :/ )
yea i havent in a year
great blind leading the blind 😂
guys how do i get a webhook from another server the tommy innit discord is being hacked by a web hook and i need to delete it
you can only get a webhook from a server the bot is in.
oh yeah i know the bot is in that server
!d discord.Guild.webhooks
await webhooks()```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Gets the list of webhooks from this guild.
Requires [`manage_webhooks`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_webhooks "discord.Permissions.manage_webhooks") permissions.
ok
um lemme think of how to modify that check to what andy is saying. I get what hes saying but is been a bit 😂
take your time i have time
m.author not m.author.bot i think?
yeah people are going crazy lol
that doesn't look like a webhook
instead of making a separate role for my verification command, how do edit the everyone role so when a user does the comand it gives them access to the rest of the server?
@commands.Cog.listener()
async def on_message(self, message):
if message.channel.id == 909671265864933406:
await message.delete()
if message.channel.id == 909671265864933406 and message.content.lower() == '*verify':
fullaccessrole = get(message.guild.roles, id=909670961115201537)
await message.author.add_roles(fullaccessrole)
oh well thats what admins were saying
you can't change channel names through a webhook, just go in the audit logs figure out which bot is doing it and ban them.
@brittle ingot i tried what we did earlier
but the hacker has full controll
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"] and reaction.message == message
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", timeout=10, check=check)
if str(reaction.emoji) == "▶️" and cur_page != pages:
cur_page += 1
await message.edit(embed=embed1)
await message.remove_reaction(reaction, user)
elif str(reaction.emoji) == "◀️" and cur_page > 1:
cur_page -= 1
await message.edit(embed=emb)
await message.remove_reaction(reaction, user)
else:
await message.remove_reaction(reaction, user)
except:
pass```
this didnt work, the reactions didnt even change the page
there are no more admins?
or server owner?
they all say in the picture they cant do anything
otherwise its sounds like the owners account was hacked.
alright, add print statements to see where its failing.
Either the owner or someone with perms
Dang token grabbers
all im asking for is a way to get in and get the id of the bot or webhook and delete it
im a member btw
yeah, which would mean the owner needs to figure who it is an ban them since they have absolute permissions. And as a member you can't access that unless your bot has admin permissions in that case i would say configure the bot to access the audit log yourself and find out who edited the channels or created channels that way.
kinda like im hacking in but in a good way
Webhooks don't have the power to change channel names lol, this is a selfbot
It's probably not a bot, to be honest. It might've been an admin's account that got token grabbed, and the nuker ran a script through that. Whatever account it was, admins can look through audit logs to figure out what account did it
You are gonna have to check the audit logs and remove that person manually
hmmmmm
Yeah, the nuker probably created that with their script as well
if its their bot they will want to regenerate their bots token on the developer portal
no its a new bot from the hacker
so ban the bot?
Check the profile of the bot , if it has a tag #0000 it's a webhook simpl
Unless you have admin powers, you cannot do anything
oh true.
Just sit back and wait
Or until discord API blacklists the bot
Although I'd doubt that would happen quickly
yeah
we can't react to messages anymore 😦
Webhooks won't have tags or anything else on them
wow what a unique name 😂
Looks more like a token lol
if c == "toggle":
anti = db.find_one({ "guild_id": ctx.guild.id })['toggled']
if anti == True:
await ctx.send("turned antinuke off since it was on")
db.update_one({
'toggled': False,
})
if anti == False:
db.update_one({
'toggled': True,
})
await ctx.send(f"toggled antinuke :thumbsup:")```
trying to toggle it off but but it only stays on true idek
giving me
Command raised an exception: TypeError: update_one() missing 1 required positional argument: 'update'```
just read some of the mods messages and they cant ban or kick anyone or do anything
Can anyone help me on why it’s not registering my cog?
what does that do?
pymongo error: filter must be an instance of dict, bson.son.SON, or other type that inherits from collections.Mapping
```whats this error
bson.son.SON 😂 sorry idk why but that killed me
its a type error, your filter isnt of type dict. what does your filter look like?
what should we do next
idk what that filter thing is, i just did ```py
userid = member.id
myCollection.find_one_and_delete({"userid", userid})
member is an arg btw
lol sorry got mega side tracked there. So next we want to add the next try/except which will handle the actual waiting part.
{"userid": userid} would be dict type as a dict contains a key and a value associated with the key.
so keep your current code and change the , to a :
and also in the db theres this thing py _id: ObjectId("someid") userid: someid reason: reasonbut reason is an arg and can be different at times so idk how i can delete it
right did not realiise it was a ,
try that and let me know.
alright, so underneath the check we want to add:
try:
msg = await bot.wait_for('message', check = check, timeout = 60)
if msg.content.lower() == "yes":
await ctx.send(f"{member.display_name} is ready to start")
elif msg.content.lower() === 'no':
await ctx.send(f"{member.display_name} is not ready to start")
else:
pass
except asyncio.timeoutError:
await ctx.send(f"No response from {member.display_name}")
This portion of code is telling the bot to wait for a message and checking the contents of the message for the acceptable responses. In this case acceptable responses are: yes or no
we chill now we have a discord staff
alr
oh good
You got a comma in there instead of a period
ignore the KeyError thats a seperate cmd
thank you
just noticed this
it keeps printing it for some reason, i think ive got a loop somewhere
could it be the timeout=10?
no, the timeout tells the bot to stop waiting after 10 seconds.
well, it keeps giving that 'working5' message
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"] and reaction.message == message
print(f'working1')
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", timeout=10, check=check)
print(f'working2')
if str(reaction.emoji) == "▶️" and cur_page != pages:
cur_page += 1
await message.edit(embed=embed1)
await message.remove_reaction(reaction, user)
print(f'working3')
elif str(reaction.emoji) == "◀️" and cur_page > 1:
cur_page -= 1
await message.edit(embed=emb)
await message.remove_reaction(reaction, user)
print(f'working4')
else:
await message.remove_reaction(reaction, user)
except:
print(f'working5')
pass```
Theres literally a while true loop
true
ANd working5 is in the except
it worked, tysm
also @brittle ingot do you know how to delete all documents in a collection?
You need to catch the exception
so ill put that under the m. author.bot
so how would i print the error
what would the attribute be
except exception as e?
yes but on the same indentation level as def check, not the return
Not the lowercased
Exception
i have noticed checking the current pages in the same if statement as the str(reaction.emoji) as always cause me issues. but we all know im a certified dumbo 😂
Raise the error instead of printing it
how do u raise errors? raise.error()?
i have truly no clue lol i never did those basics
No you use the raise statement
oh i did reply. im fried.
raise CommandInvokeError```?
@pliant gulch @brittle ingot did that, nothing happened
literally nothing
reactions were added, but the functions didnt work
do you have asyncio imported?
try doing:
except asyncio.timeoutError:
print("timed out")
and see if that triggers? Could be that the timeout is too low? at this point idk, just throwing ideas
k
went into exception for member being none
also make sure you indentations match. remember pep8 recommends one tab or 4 spaces for an indentation and they should be consistent througout
i use 4 spaces
not you sorry was speaking to forgot python person
oh lol no worries
member being none? or user?
sec ill send the rest
kk
the error and the portion of code it refers to
@brittle ingot if you know, what would the attribute be
@commands.command(name="userinfo", aliases=['ui', 'uinfo', 'whois'])
async def userinfo(self, ctx, member: Union[discord.Member, discord.User] = None):
try:
if member == None:
member = ctx.author
#200 lines of stuff that works
#stuff that doesnt work VV
br = " "
bot_owner = " "
bot_staff = ""
supporter = ""
bot_badges = 'None'
if member.id == 813989866236149770:
bot_badges = f'{bot_owner}{bot_staff}{br}{supporter}'
elif member.id == 689005922550284318:
bot_badges = f'{supporter}'
pages = 2
cur_page = 1
#embed stuff
await message.add_reaction("◀️")
await message.add_reaction("▶️")
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"] and reaction.message == message
print(f'working1')
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", timeout=10, check=check)
print(f'working2')
if str(reaction.emoji) == "▶️" and cur_page != pages:
cur_page += 1
await message.edit(embed=embed1)
await message.remove_reaction(reaction, user)
print(f'working3')
elif str(reaction.emoji) == "◀️" and cur_page > 1:
cur_page -= 1
await message.edit(embed=emb)
await message.remove_reaction(reaction, user)
print(f'working4')
else:
await message.remove_reaction(reaction, user)
except asyncio.timeoutError:
print("timed out")
#stuff that doesnt work^^
except:
fetchmember = await self.bot.fetch_user(member.id)
#100 lines of other stuff that works``` @brittle ingot there
i don't know, I rarely use Mongo with python its always been Sqlite for me.
oh alr
!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.
you could ask in #databases
i fix the code
oh okay
i know the code doesn't work, but you mention about an issue with member and receiving an error what is that error
it moves into its exception
so its only the pages bit that isnt working properly
looks done to me
it moved into the exception where you are fetching the member? at the very bottom?
mhm
ok now
Andy you still lurking? any ideas for Terrors issue?
how do i set it to work when i do ! startbattle
I'm having trouble gathering messages that my bot has sent in the past and even tested the runtime by having it send "a" but the bot doesn't send anything.
becuase this is not working
how can i use requests to delete a message
why are you defining it twice?
client = commands.Bot(command_prefix="!", intents=discord.Intents.all())
ok
@pliant gulch <3
i was trying to avoid pinging him incase he was busy 😂 lol but yeah
well if hes busy then he just wont reply lol
I’m still struck to find out why it’s not recognizing my cog I’ve rewrote it twice copying the video just to be sure
check the message.author.id, because message.author returns a dict that contains a lot of info
Am I missing something?
or just be consistent and use a bot variable with commands.Bot
?
It didn't work sadly
make a DELETE request to the proper endpoint. you can find the info in the documentation in the developer portal
like this
What's the current issue? You don't know the error that is happening?
I just need help with the link
the endpoint? and base url is in the developer portal user documentation. I don't know the base URL off hand as i don't make requests to the API directly, sorry.
Its not private so discord definitely has it in their documentation. Otherwise libs like discord.py wouldn't be a thing 😄
how do i change it
...
Question
nope
Is it possible to retrieve all messages that a user sent by using messages = await ctx.guild.history(limit = 100, check = check).flatten() ?
requests.delete(f"https://discord.com/api/v9/channels/{message.channel.id}/messages/{message.id}")
``` this doesnt work, any ideas?
Check is defined as def check(message): return message.author.id == 899002742989791273
For each try-except block can you catch the error and print print(repr(error))
will try
Is it possible to retrieve all messages that a user sent by using
```messages = await ctx.guild.history(limit = 100, check = check).flatten()``
?
'error' is not defined
You need to catch the error
except Exception as e?
this looks fine but it doesnt delete the message
As your putting it in e
hello i had a problem so i made a giveaway cmd
so i made def convert for convert like H is hour to seconds so my asyncio.sleep can work, but it doesnt convert it
TimeoutError()
nothing else happened, even when i tried using the reactions
Ok, so the error happening is the timeout is running out
but the reactions wont work either
!e
requests.delete(f"https://discord.com/api/v9/channels/{message.channel.id}/messages/{message.id}")
@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 | NameError: name 'requests' is not defined
Probably because it timed out??
duh
@commands.command(name="userinfo", aliases=['ui', 'uinfo', 'whois'])
async def userinfo(self, ctx, member: Union[discord.Member, discord.User] = None):
try:
if member == None:
member = ctx.author
#200 lines of stuff that works
#stuff that doesnt work VV
pages = 2
cur_page = 1
#embed stuff
await message.add_reaction("◀️")
await message.add_reaction("▶️")
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"] and reaction.message == message
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", timeout=10, check=check)
if str(reaction.emoji) == "▶️" and cur_page != pages:
cur_page += 1
await message.edit(embed=embed1)
await message.remove_reaction(reaction, user)
elif str(reaction.emoji) == "◀️" and cur_page > 1:
cur_page -= 1
await message.edit(embed=emb)
await message.remove_reaction(reaction, user)
else:
await message.remove_reaction(reaction, user)
except Exception as e:
print(repr(e))
#stuff that doesnt work^^
except:
fetchmember = await self.bot.fetch_user(member.id)
#100 lines of other stuff that works```
so do i remove timeout=10?
do i change the bot command to a client command
whoops moros sorry for ping i copied my last message
Doesn't seem like you are passing authorisation headers
Believe it or not, you need to actually authorise to delete messages
Crazy isn't it
its all good. Sorry im in and out as im trying to do some courses, clean house and work on projects :E
updated it
yes if you don't want to redefine it in your mainfile.
ok explain how to do that
change @bot.command() to @client.command()
or
where you define:
client = commands.Bot(command_prefix = "!", case_insensitive=True, intents = discord.Intents.all())
change client to bot.
If you do one of these you don't need to do the other. The second is recommended for consistency and ease of interpretation. If you come to get help and use client as your bot variable we may assume you are using discord.Client which wouldn't be accurate since you are actually using commands.Bot
ok ill test it
better to use bot btw, nothing will happen if you use client but bot is recommended
^
yea i change it to bot and i do !startbattle and nothing still happens
@pliant gulch this is what i have now and its not doing anything
i farted
errors?
@slate swan what is ur command
nope just nothing
send ur command
@slate swan i finally got antinuke to work 🤣
!paste it here and then save it and send the link in chat here so we can see it in its entirety.
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.
any help pls?
^^
isnt this from some bot tutorial lmao
from swastik 🙂
» args-kwargs
» async-await
» blocking
» botvar
» class
» classmethod
» codeblock
» comparison
» contribute
» customchecks
» customcooldown
» customhelp
» decorators
» defaultdict
» dict-get
!tag tutorials
do not use tutorials, outdated and dogshit
i use:
time_convert = {"s":1, "m":60, "h":3600,"d":86400}
newtime= int(time[0]) * time_convert[time[-1]]
oh yea it may can be used
me and @slate swan got banned from dpy because we were annoying people in general
!startbattle
lol
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.
the first part
that isnt relevant...
that was from before just wasn't removed yet
ah
possibly the timeouterror messing up? don't you have to define the timeout?
it is defined in the wait_for
await ctx.message.delete() ?
await ctx.message.delete()
you dont need the py else: passin try except btw
i can see that your indents are messed up, maybe thats why
or role = ctx.guild.get_role(id) since you arent using that for anything
^^, possibly indention errors that aren't occurring?
@slate swan does your bot have any global error handlers, if no are there any errors printed
how are they not using that? its needed to get the members that have that role? members = role.members
lol
i didnt see that
no it dose not
msg isnt in line with if
the only thing i can think of is indentation.
if not the line should be shown, is it just me?
also dont use replit, use some proper code editor/IDE
pretty sure
i would use https://github.dev
vsc in browser
@brittle ingot @slate swan thx for the help
you cant run the code in there tho
just use the vsc app
write it and then copy it over
how have i never known about this.
might be on a chrome book or something, cant tell
just came out recently
something new, just released recently
they are, we covered it already
yes, didn't know they could install VSC on cb
cant
can
did not even see that
wait what im so confused what are we saying
ill line them up
replit's indentations are screwed up, just use vsc/some other IDE
Why wouldn't you be able to install VSC On a chromebook? Not doing any research here but chromebook is using google os, which is just linux with changes
linux needs to be enabled
You can install VSC on a chromebook. That is how i learned to program, enabled linux 😄
most schools dont allow linux (third party stuff) for security reasons
wow im slow at typing
i've never used a chromebook but for school so i don't know, i had goguardian on that bitch and couldnt do anything

which is weird because its definitely being used.
dumb
nvm
😂
@bot.event
async def on_message(message):
if "discord.gg/" in message.content:
if message.author.id in anti.find_one({"_id": message.guild.id})["whitelisted"]:
return
else:
chan = anti.find_one({"_id": message.guild.id})["modlogs-id"]
channel = bot.get_channel(chan)
if channel is None:
return
else:
embed = discord.Embed(title="Mod-Logs | Invite Deleted", timestamp = message.created_at, color=discord.Color.from_rgb(255,250,250), description="Invite Message Deleted!")
embed.add_field(name=f"Author", value=message.author)
embed.add_field(name=f"Content", value=message.content)
await channel.send(embed=embed)
requests.delete(f"https://discord.com/api/v9/channels/{message.channel.id}/messages/{message.id}",headers=headers)
await message.channel.send(f"{message.author.mention} please don't send discord server invites",delete_after=5)
await bot.process_commands(message)
``` i have a feeling the error is the `timestamp`
what are the headers? are they defined?
mhm
the deleting message worked, untill i added the embed
why would you do a request to delete
thats why
the channel didnt set
cant you just do await message.delete()
@brittle ingot am i right or dumb again
hmmm
are you sure you are getting the channel? if there is no channel it returns without executing th rest of the code.
yes
wdym
@slate swan why are you doing a request to delete if you have the message object you can just call await message.delete()
that was for xy sorry
ok
im going to copy the code we worked on and put in . infront of the lines so you can see what we mean by indentation.
!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.
why do people think that is funny
idk but that is not discord-bots.
ok want me to dm you my code
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
:incoming_envelope: :ok_hand: applied mute to @slate swan until <t:1637116096:f> (9 minutes and 59 seconds) (reason: discord_emojis rule: sent 27 emojis in 10s).
bruh, wtf
yes but replace the . at the beginning with spaces. or if you follow the key 1-tab for every 4 spaces
Also on line 26 from your link you can change bot = to client = (that will be easier as you will only need to change one other thing to make its consistent.)
I can’t figure out what’s wrong with the syntax
no closing ) on the listener above it where you print its alive
… thanks lmfao
Still not registering the cog might just say f it and not organize it lol
also you can't just call send you need to send it somewhere. ctx has a channel attribute messages can be sent to, so the reply will be in the channel the command invokes from so instead do:
await ctx.send('pong')
Thanks
np
Fixed it
Also u r missing a bracket at print
yeah we grabbed that 😄
Now just gotta figure out why it won’t register the cog
all of your indents should be inline with the def __init__
well lemme explain that better
But def innit is so far in do i need to just scoot them all inwards?
class Moderation(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.Cog.listener()
async def on_ready(self):
print(f'{self.__class__.__name__} is alive!!')
@commands.command()
async def ping(self, ctx):
await ctx.send('Pong!')
def setup(client):
client.add_cog(Moderation(client))
Oh ok so move my commands in line with def
correct commands, listeners, etc
So just the @command part not the rest?
exactly as it appears in my example.
ok now theres a error
Sorry not trying to be rude. I don't know how to explain it in any way that doesn't over complicate it
just remove the m.author before the not
it should look like:
return not m.author.bot and m.channel == message.channel
It’s saying Indention error on line 11 bruh
show?
m
?
I fixed line 11 and it’s now 13 here’s pic
see now that is wrong
you have a random A in front of the elif.
you removed the A , but forgot to indent the elif
the lines guide you , it must be parallel with the 2nd line
that almost just lead me down a road of 15 minutes of confusion 😂
plus it still say this is not being used
should there be a while True? even if its not for reactions? i left it out but could be the issue.
How do you get a list of all roles?
property roles: List[discord.role.Role]```
Returns a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of the guild’s roles in hierarchy order.
The first element of this list will be the lowest role in the hierarchy.
np
it will. im sure. just i decided to help you and haven't touched python in forever. so yeah. we will figure it out.
@brittle ingot I got the cog to work how do I go about adding more commands to it?
kk
just copy what you have done for ping its the same as outside a cog, except you add self as the first param of the commands, there is the different decorator of course and anytime you access bot you do self.bot instead.
i just noticed something. you have an on_message event. You didn't process comands afterwards.
I figured it out thanks bro your a god send
failed
!d discord.ext.commands.Bot.process_commands
await process_commands(message)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.
By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.
This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").
This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
thank you
Is there a place where I can like vouch for you? Moros
@slate swan on line 70 add in:
await client.process_commands(message)
make sure that its in line with the if statements above it. essentially so its not a part of any of the if statements.
wdym?
Like say you give awesome help
so for example:
if message.content.startswith("$bossman"):
... some code
await client.process_commands(message)
Notice how they are lined up with each other.
oh lmao, nah its all good. I appreciate it though. I actually just enjoy helping and really just do it to learn more myself. 🤷♂️ 😄
logs = logs[0]
IndexError: list index out of range```
if self.db.find_one({ "guild_id": guild.id })['toggled'] == True:
logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.ban).flatten()
logs = logs[0]
reason = "culprit • triggered antinuke event • ban member"```
DUDE WHAT
Welcome bad _ObjectID don't do anything stupid again 😛
i have a sharex host and the url is literally just emotes i forgot
?!?!?!?/
@commands.Cog.listener()
async def on_member_ban(self, guild, member):
if self.db.find_one({ "guild_id": guild.id })['toggled'] == True:
logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.ban).flatten()
logs = logs[0]
reason = "culprit • triggered antinuke event • ban member"
whitelisted = self.db.find_one({ "guild_id": guild.id })['whitelisted']
if logs.user.id in whitelisted:
return
punishment = self.db.find_one({ "guild_id": guild.id })['punishment']
if punishment == 'ban':
try:
await logs.user.ban(reason=f"{reason}")
return
except:
pass
if punishment == 'kick':
try:
await logs.user.kick(reason=f"{reason}")
return
except:
pass
Ignoring exception in on_member_remove
Traceback (most recent call last): File "C:\Users\misery\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\misery\Desktop\alone\bot\cogs\anti.py", line 85, in on_member_remove
logs = logs[0]
IndexError: list index out of range
ohh u want me to print logs
Your awesome either way another quick question I can make another cog and just copy and paste the start of the cog I have now in it and it will work the same correct?
yes please, im going to assume you are either not getting a list or your list is empty
yes, just make sure you name it something differently
no lot using eval, acutally in your code right before you do log = logs[0]
invite me and ban me 😂
k got it
since you are limiting your search to one its only returning the one entry so its not a list. logs is your "log"
no need to index it
so just get rid of logs = logs[0]?
yup
ahhhh
and you can change your logs variable to log. or even name it entry for ease of reading later on
join back rq lets see if that fixed
Ignoring exception in on_member_join
Traceback (most recent call last):
File "C:\Users\misery\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "C:\Users\misery\Desktop\alone\bot\cogs\anti.py", line 228, in on_member_join
if logs.user.id in whitelisted:
AttributeError: 'list' object has no attribute 'user'
Ignoring exception in on_member_remove
Traceback (most recent call last):
File "C:\Users\misery\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event await coro(*args, **kwargs)
File "C:\Users\misery\Desktop\alone\bot\cogs\anti.py", line 87, in on_member_remove
if logs.user.id in whitelisted:
AttributeError: 'list' object has no attribute 'user```
getting that on startup
Ignoring exception in on_member_remove
Traceback (most recent call last): File "C:\Users\misery\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs) File "C:\Users\misery\Desktop\alone\bot\cogs\anti.py", line 87, in on_member_remove
if logs.user.id in whitelisted:
AttributeError: 'list' object has no attribute 'user'[<AuditLogEntry id=910365716211974185 action=AuditLogAction.ban user=<Member id=898420656725704705 name='1fc1fdf69a7f089aff28f65f0ab37984' discriminator='0001' bot=False nick=None guild=<Guild id=910278334263484416 name="1fc1fdf69a7f089aff28f65f0ab37984's server" shard_id=None chunked=True member_count=2>>>]
Ignoring exception in on_member_ban
Traceback (most recent call last):
File "C:\Users\misery\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs) File "C:\Users\misery\Desktop\alone\bot\cogs\anti.py", line 38, in on_member_ban if logs.user.id in whitelisted:
AttributeError: 'list' object has no attribute 'user'```
when i banned u
so it is a list? it wasn't before...
dude i have no clue what i made i just ran with it
first time trying to make a anti-nuke
for some reason its returning you as the banned one...
strange
going by whats printed out, you should be able to do log = logs[0] and do log.user.id to access the information.
logs = await guild.audit_logs(limit=1, action=discord.AuditLogAction.ban).flatten()
log = logs[0]
reason = "culprit • triggered antinuke event • ban member"
whitelisted = self.db.find_one({ "guild_id": guild.id })['whitelisted']
if log.user.id in whitelisted:
return
punishment = self.db.find_one({ "guild_id": guild.id })['punishment']
if punishment == 'ban':
try:
await log.user.ban(reason=f"{reason}")
return
except:
pass
if punishment == 'kick':
try:
await log.user.kick(reason=f"{reason}")
return
except:
pass
so like that?
@brittle ingot do you know in a db how do i get the var "modid" in the document py _id: ObjectId("someid") userid: someid reason: "reason" modid: modidbut the mod (ctx.author) can blacklist many users so idk how to find that for the specific user's document
once you find the doc by its userid as long as you assign it a variable you should be able to do varName.modid to access the modid
ive done that
idk how to find the doc by its id
all i do is py myCollection.find_one({"userid": userid})
so idk how to get the object id
assign this to a variable and you should be able to do for instance:
userDoc = await myCollection.find_one({"userid": userid})
modID = userDoc.modid
ohh
not sure if you have to await it in python, its required to await it in JS which is where i use mongo the most.
no need to await, ty i'll try it now
and have you restarted the bot and tried to run the command !startbattle?
yes even though that is exactly the original. I would say maybe add a check that checks the isinstance of logs whether its a list or not?
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"]
def check2(reaction, user):
return reaction.message == message
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", checks=[check, check2])```
are u still trying this
ok
can that work? with multiple checks
rip
mhm
no not that i know of.
how can i check for multiple checks
self.loop.create_task(check())
NameError: name 'self' is not defined
did anyone know what i need to change? i use cogs
self = self.bot
just add another and in the first def check or you can add an nested check in your wait for essentially an if statement that checks if msg.id == message.id
no, pretty sure that's not right
def __init__(self, bot):
self.bot = bot```
ok tq
swear thats right
that is yeah. but self = self.bot is not 😄
alr in my code but still error
show code? im sure i can't help but showing your code may help someone else understand whats wrong and ensure they're able to help you.
i want make auto leave if my bot stand alone
nope
Send your code as it actually is please
async def check(self, ctx):
voice_channel = ctx.voice_client.channel
member_count = len(voice_channel.members)
if member_count == 1:
await asyncio.sleep(90)
ctx.voice_state.stop()
del self.voice_states[ctx.guild.id]
if member_count == 2:
return member_count
self.bot.loop.create_task(check())```
oop
no code block 🤧
Ignoring exception in command blacklist status:
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\botmods.py", line 187, in _status_blacklist
mod = await self.bot.fetch_user(find_userid.modid)
AttributeError: 'dict' object has no attribute 'modid'
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 1448, in invoke
await ctx.invoked_subcommand.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: AttributeError: 'dict' object has no attribute 'modid'```
how ?
indentations 
I'll help when you show us the right code for your error. Your current code has indentation issues
mine?
yea
pulled it straight from my cog lol
here is fixed
find_userid["modid"] maybe?
still invalid, unless you want help with indents
try:
find_userid["modid"]
instead of dot notation
@ me when its right
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"]
def check2(reaction, user):
return reaction.message == message
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", checks=[check, check2])```how can i make this work? not sure how i can add the 2 checks to the same one
ohh
return user == ctx.author and str(reaction.emoji) in [":arrow_backward:", ":arrow_forward:"] and reaction.message == message
ok then its prolly discord's codeblock screwed up
@brittle ingot you free to help me rq?
yeah
games = {}
set_aid = set()
#!r command -> Randomly sorts players into teams
@bot.command()
async def r(ctx):
if ctx.channel.id in allowed_channels: #and ctx.author.id in games.values():
ggid = settings.find_one({"guild_id": ctx.guild.id})
qsize = ggid["qsize"]
game_id = ggid["game_id"]
tally = ggid["tally"]
set_aid.add(ctx.author.id)
for x in set_aid:
if x in games[game_id-1]:
settings.update_one({"guild_id": ctx.guild.id}, {"$inc": {'tally': 1}})
if tally >= (qsize/2):
settings.update_one({"guild_id": ctx.guild.id}, {"$set": {'tally': 0}})
Hi guys anyone know how I can fix this? I'm trying to make it so when 3 people use the command !r, who's id's are also stored as values in a dictionary named games, something will happen.
I can’t figure out how to fix the indention error
doesnt do anything, i still cant scroll through the pages
screenshot it?
Although Ill guess for you. Your only gonna have self in methods n propertiies so define the loop there
how bout that?
indent both your awaits by 1
@commands.command(name="userinfo", aliases=['ui', 'uinfo', 'whois'])
async def userinfo(self, ctx, member: Union[discord.Member, discord.User] = None):
try:
if member == None:
member = ctx.author
#200 lines of stuff that works
#stuff that doesnt work VV
pages = 2
cur_page = 1
#embed stuff
await message.add_reaction("◀️")
await message.add_reaction("▶️")
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"] and reaction.message == message
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", timeout=10, check=check)
if str(reaction.emoji) == "▶️" and cur_page != pages:
cur_page += 1
await message.edit(embed=embed1)
await message.remove_reaction(reaction, user)
elif str(reaction.emoji) == "◀️" and cur_page > 1:
cur_page -= 1
await message.edit(embed=emb)
await message.remove_reaction(reaction, user)
else:
await message.remove_reaction(reaction, user)
except Exception as e:
print(repr(e))
#stuff that doesnt work^^
except:
fetchmember = await self.bot.fetch_user(member.id)
#100 lines of other stuff that works```
the center bit is what matters
Although Ill guess for you. Your only gonna have self in methods n propertiies so define the loop there
resize the console to the code is expanded more, that is exceptionally hard to read 😄
Did that now syntax error on ‘await’
between pages and print(repr(e))
I got you
I mentioned wrong person. Whats the issue with this now..?
doesnt scroll through pages
and when it used to, it would change the embeds for the messages that previously sent
but i had like ensuring_vc on last lines but it work , btw thanks for info
Taking a pic through laptop rq
do u need a pic of what i sent? this?
oh so you mean i need to put in on @vapid spade?
indentssss
worked, tysm
I’m trying I don’t know what to indent
Wel I know what
But when I indent it leads to more problems lol
we are gonna need to work on teaching proper indentation 😄
Nope. Staticmethods don't have self and class methods have cls. You need an actual method. Likely __init__
!indents
Indentation
Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.
Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.
Example
def foo():
bar = 'baz' # indented one level
if bar == 'baz':
print('ham') # indented two levels
return bar # indented one level
The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.
Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines
More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation
xx
try:
#stuff
if stuff is stuff:
#stuff
else:
#stuff
except:
#stuff``` @regal shell indent example
OH MY WORD! THAT IS A THING? i've been trying to explain it all day 😂
so i need to make new class with init?
Your cog already has an init method 🤷
But each to there own I guess
And another class wouldn't have access to your classes instance. But meh
so can ANYONE help with this? i even provided a video
yeah i do
yup still nothing
Care to add some print statements and see what runs, what doesnt, etc. Kinda at work so can't be bothered debugging more then just sending emssages sorry
Ok I fixed one part
ill try
i think u better screenshot it and crop the unused parts
huh
no, just dont use replit 

pages = 2
cur_page = 1
await message.add_reaction("◀️")
await message.add_reaction("▶️")
print("reactions got added")
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"] and reaction.message == message
print("check worked")
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", check=check)
print('try statement worked')
if str(reaction.emoji) == "▶️" and cur_page != pages:
cur_page += 1
await message.edit(embed=embed1)
await message.remove_reaction(reaction, user)
print('page up worked')
elif str(reaction.emoji) == "◀️" and cur_page > 1:
cur_page -= 1
await message.edit(embed=emb)
await message.remove_reaction(reaction, user)
print('page down worked')
else:
await message.remove_reaction(reaction, user)
except:
pass```ima test this
like discord and pastebin
4 spaces is recommended right?
yeah
idk i feel 4 spaces makes the code look more organized
idek where you would only use two spaces. tbh
@valid perch nothing, literally nothing

the reactions were added and nothing was printed 
Sure your running the latest code?
restart your bot
alright, im out. have a good one.
Ugh I hate this
no lol
More print statements, and its likely the check isn't returning true so print those checks
I am lmfao
nah thats not replit
id rather localhost lmao
anyways
alright
you shouldnt use it to develop your bot as well
What should I use then?
I’m this far in lmfao
Is there a way to transfer everything
@valid perch here
What should I use to code then
"and its likely the check isn't returning true so print those checks"
Code locally if possible. Generally only use online if you have no other options
now would i do that
I have vsc but don’t know how to use it
Hint, you have a function called check. Put prints inside it printing the statements
Is vsc good?
Its a nice editor yea
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"] print('1') and reaction.message == message print('2')``` 
I have the mobile version
ive never done things like that
Do you return print statements...
I’m trying to download actual version
Think
Or do you put a print on there own line
Can’t it’s not supported will mobile version work?
Dunno, I try avoiding coding on phones
It’s not on phone it’s on a chrome book
I’ll send pic in dms can you tell me good ones?
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"] and reaction.message == message or print('this failed')``` like this??
No. Cmon, look at your other print statements.
Hint, its something todo with them having there own lines
This is fairly basic stuff, so I might recommend a python refresher to make future bot development easier on ya
ohhh i see
Do you. Thats great to hear
def check(reaction, user):
user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"]
print('this worked')
reaction.message == message
print('that worked')
return
print('all worked')```
WAIT
ok there
Code after return isn't run. Fun fact, return returns
Print the result of the check...
There always gonna 'work'
that good?
What
You also now don't return anything from your check so gl with that
Your second == isn't assigned to anything
..
🤦♂️
message = await ctx.send(embed=emb)
await message.add_reaction("◀️")
await message.add_reaction("▶️")
print("reactions got added")
def check(reaction, user):
user == ctx.author and str(reaction.emoji) in ["◀️", "▶️"]
print('this worked')
reaction.message == message
print('that worked')
return
print('all worked')```
I'm gonna get back to work. But you've got this
Try actually printing the results of your conditions and then return the result. Hint you can print variables by doing print(variable)
Your check will always retuyrn None but whatever
yup still say its unused
How would I kick the user if they didn’t do this command after 24 hours of joining?
@client.event
async def on_message(message):
if message.channel.id == 909671265864933406:
await message.delete()
if message.channel.id == 909671265864933406 and message.content.lower() == '*verify':
fullaccessrole = get(message.guild.roles, id=909670961115201537)
await message.author.add_roles(fullaccessrole)```
How to use button without dpy 2.0?
Anyone?
You need to use any 3rd party lib
Like dislash or discord_components
Hey does anyone know how I can see if a command is used 3 times, by only by people that their id’s are stored in a certain key in a dictionary
e.g.
!q (player id as value in dict)
!q (player id as value in dict)
!q (player id not in dict)
!q (player id as value in dict)
Then command goes through
Thank you.
hunter = True
def thankyou():
print("Thank you hunter")
if hunter:
thankyou()
@dusk pumice :white_check_mark: Your eval job has completed with return code 0.
Thank you hunter
hello
i have a doubt
i wanna display the users using my bot
and i use the code len(self.client.users) and the intents are enabled
and with 21 servers it shows 13k users
so is that the accurate amount of users using the bots or its showing the total number of members in each server where the bot is present
if u have a solution pls ping me and reply
yes
that means the bot is being used by that amount of members on a regular basis
I mean that its the amount of users that the amount of guilds ur bot is in
np
so thats basically not the amount of users using the bot
so is there a way to get the users using the bot
this?
im using this rn and as u said its showing the number of members in the guilds the bot is in
maybe there is no way
!d discord.ext.commands.Bot.get_all_members
for ... in get_all_members()```
Returns a generator with every [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") the client can see.
This is equivalent to:
```py
for guild in client.guilds:
for member in guild.members:
yield member
@boreal ravine mind helping me with this? :D
thats basically the same
a bit lower down u can see a video on what happens
its gonna show all the members the bot will see
Well that's the point isn't it
essentially i need it to only edit the new message and not the old ones
well i m trying this rn and i will update back to you
can someone help me?
class music(commands.Cog)
def_init_(self, client):
self.client=client
``` it says the cog is invalid syntax
then get the message instance of ur "new" message
how can i do that?
cringe copied code, and it's __init__
(:
by setting a variable to the message you sent?
I an init with a single underscore 🤤
I am init with a double underscore 🤤
ight thanks
look at the link in his about me 😭
Makes sense
what link
Pretty accurate
"/skids"
The first line
Sooo?
dunder methods with 1 underscore 😏
ik, just ironic
Don't y'all think it's OT....?
Bruh
thanks ig?
thats not something to be proud of but u do u 🤧
Wouldn't say 'thanks' without knowing what it means but sure
Hey does anyone know how I can see if a command is used 3 times, by only by people that their id’s are stored in a certain key in a dictionary
e.g.
!q (player id as value in dict)
!q (player id as value in dict)
!q (player id not in dict)
!q (player id as value in dict)
Then command goes through
await message.channel.send(embed=embed)
await message.add_reaction("👍") #adding reaction
await message.add_reaction("👎") #adding reaction```
How come this doesn't work?
your adding the reaction to the message instance not the "embed" message if thats what your talking about
How would I add it to the embed?
I’ve hit a brick wall 😩
set a variable to the send function
No need to
yes
adding a reaction is a coroutine
hm
dont forget that
ty
👍
Alright I think i’ve found a solution to my answer
first run a check for my command to see if players issuing the command are in the dictionary
if they are add them to a new list, then check if the length of the list is == 3
This better work 
🙂
How can my bot know what roles the user have?
ping to awnser plz

