#discord-bots
1 messages ยท Page 496 of 1
big oof
btw just reading the example. Unfortunately it doesn't limit it to 2 specific players
Cya @dusk pumice
Cya
cya
Cya
IQ 100 :stare:
lol
then u can use interaction_check
See the base url haha
LMAO
but whats wrong there
see the BASE_URL
did you need self there
nvm
BASE_URL = BASE_URL
whats wrong with that
drakeyeah
๐คฃ dude
no i literally have no idea
your nickname suits u @slate swan
yeah i was thinking of __init__
Is it possible to send videos inside of embeds
@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 'discord' is not defined
set_image(*, url)```
Sets the image for the embed content.
This function returns the class instance to allow for fluent-style chaining.
Changed in version 1.4: Passing [`Empty`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed.Empty "discord.Embed.Empty") removes the image.
can we set videos tho
U can try
ok brb
What else to add to my AI Bot
Add VC support (voice commands in vc) ๐ณ
๐
No voice receive sadly
impossible
voice commands?
unless you make a fork with voice receiving
you cannot , but can acess it if a embed has one
djs has it
how to check if a user is mentioned
How can I block all another links without allowed? I tried but with no result
not dpy
!d discord.Member.mentioned_in
mentioned_in(message)```
Checks if the member is mentioned in the specified message.
yep
hm
nope
bro
I'm getting this error now
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "c:\Users\user\OneDrive\Desktop\Profanity Blocker\main.py", line 924, in on_message
embed.add_field(name="Content count", value = {word: message(word) for word in test2 if regex_match_true.search(message.content) and regex_match_none.search(message.content) != 0})
File "c:\Users\user\OneDrive\Desktop\Profanity Blocker\main.py", line 924, in <dictcomp>
embed.add_field(name="Content count", value = {word: message(word) for word in test2 if regex_match_true.search(message.content) and regex_match_none.search(message.content) != 0})
TypeError: 'Message' object is not callable```
then?
how many times do we have to say
replace discord.Member with an instance
of discord.Member
message(word)
why do u have that???
ah yes calling a message instance
I don't need it?
it's more like what exactly are you trying to achieve here
u don't have ctx
word: message(word)
oops
value = {word: message(word) for word in test2}
^^^
makes no sense to me already
message.author.mentioned_in(message.content) ??
you're making the variable word, which you're typehinting to a call of a message instance with the argument word
I'm trying to make my bot count the amount of bad words per message and send it in logs
it's just the biggest mess ever
Ohhh
k
yes i want to use it in if
@slate swan
I'm just getting the word the user sent
well you are in fact not
Oh
been sent here from a help channel, want to build a similar function to the help system on here just scaled to a couple of channels, how would i do thart
if message.author.mentioned_in(message.content):
(stuff)
this?
it will work?
yes
So how should I fix it?
how can i make it so only admins can see a channel?
if I do @slate swan it works
configure your channel settings?
no
What does ```py
Command raised an exception: HTTPException: 413 Payload Too Large (error code: 40005): Request entity too large
in discord
get the role and set a channel's permissions for that role
!d discord.TextChannel.set_permissions
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.
The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.
If the `overwrite` parameter is `None`, then the permission overwrites are deleted.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
if u willl ping someone else then?
then you will have to get another member
instead of message.author
so what you're doing here is making a dictionary with a key word and an invalid value of message(word), which is invalid because message is an instance of discord.Message and not a fuction, for every word in the variable test to if the regex_match_true finds anything in message.content
anyone?
yes i am not using message.author i used it for asking from u
then good job I guess?
Ohh, got it. So could I remove word: message(word) for word in test2 ?
it will only work with the person that you put instead of message.author
this is what @unkempt canyon does
i'm just saying what you are doing and what part is invalid
Oh okay
i just looked at it just way above my level
How do i check if someones a bot or not
!d discord.Member.bot returns true if a member is bot
property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
or discord.User.bot
thanks
hello
i want ask a question
i want to make an like upgrade for my bot
i want to do like this !id @hollow mortar and i want it to give me my id anyone know how i can make it ?
it take the mention and give me the id of that guy
and send me the id in chat
use discord.Member typehint , and use .id attribute
property id```
Equivalent to [`User.id`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.id "discord.User.id")
how to fix this ?
What is mention_everyone?
How did you come up with it?
i made a afk command
it is working fine
but the problem is if someone ping a afk member
bot is not telling him that he is afk
:/
what's a cd
lol
tell me
:stare: Stop
ohhk
@cloud dawn can u stop trolling please?
they asked what a cd was, not what the cd command was
:stare: I mean, a person won't ask what is a CD in discord bots channel lol

Hey what happened to discord.py? I heard it was going down
read the pins
has gone down*
lol everything seems to be working for me
I know
It will work for some time
till a breaking change comes
and RIP discord.py
like member.avatar.url instead of member.avatar_url
What are you talking about
that is a breaking change in 2.0
It'll work fine till discord api changes
u cannot do member.avatar_url in dpy 2.0
u have to do member.avatar.url
This is an example of breaking change
My whole computer science project is on this module lmao
What he's tryna say is dpy is perfectly fine until discord changes
i might be fucked
Yes ^^^
Or until something changes discord side
Yea
Despite him not saying that haha
lol
there are many forks
That makes sense
breaking change
Yea
Then gives an example of a dpy change, not discord haha
Oh, I thought member.avatar.url was a discord change 
hey i have question
if i do this does it work
await ticket_channel.set_permissions(payload.member, read_messages=True, send_messages=True)```
i replace payload.member with the id of that member
does it give him the perms ?
Forks are like copies of the project but altered not to be mistaken with a branch.
!d discord.abc.GuildChannel.set_permissions
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.
The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.
If the `overwrite` parameter is `None`, then the permission overwrites are deleted.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
this is how you set permissions
what he mean with member ? member id ?
hello, so my bot needs to run .addaccess to add a user to the ticket, but the coding is trying to add a role instead.
That's just discord.py changing code, a discord change is actual routes changing that'll break it
A discord.Member or discord.User
so the thing i said wont work right ?
this one
wont work if i replace the payload.member with the id of the member
but it will work if i do this right ?
memmber = "member id "
await ticket_channel.set_permissions(memmber.member, read_messages=True, send_messages=True)
does this work ?
when user runs command .new it creates a ticket,
and adds the user that entered command to ticket
no it will not
read the documentation
but as soon as i run my .addaccess (userid) command
it says "invalid role" which shows its attempting to add roles instead of users
why ?
because you didn't read the documentation and don't supply correct arguments
!d discord.abc.GuildChannel.set_permissions
await set_permissions(target, *, overwrite=see - below, reason=None, **permissions)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Sets the channel specific permission overwrites for a target in the channel.
The `target` parameter should either be a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") or a [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that belongs to guild.
The `overwrite` parameter, if given, must either be `None` or [`PermissionOverwrite`](https://discordpy.readthedocs.io/en/master/api.html#discord.PermissionOverwrite "discord.PermissionOverwrite"). For convenience, you can pass in keyword arguments denoting [`Permissions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions "discord.Permissions") attributes. If this is done, then you cannot mix the keyword arguments with the `overwrite` parameter.
If the `overwrite` parameter is `None`, then the permission overwrites are deleted.
You must have the [`manage_roles`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.manage_roles "discord.Permissions.manage_roles") permission to use this...
whai not working
then make it add users and not roles if you need users
yes but idk the coding for add user, which is what im trying to find out.
because modules isn't a valid library
these imports panic
Also not using halve
got it thanks man i understand it now thanks alot
then how do i add it
?
๐ฉ Plis tell me
you're trying to import a subfolder in your project folder, if you import a folder it needs a valid __init__.py like a real library
see
that's an __init__ method of a class
ohh
what i said is if you want to import a folder the folder needs to contain a valid __init__.py
what does and init.py contai
__init .py contain
@client.command()
async def addaccess(ctx, role_id=None):
with open('data.json') as f:
data = json.load(f)
valid_user = False
for role_id in data["verified-roles"]:
try:
if ctx.guild.get_role(role_id) in ctx.author.roles:
valid_user = True
except:
pass
if valid_user or ctx.author.guild_permissions.administrator:
role_id = int(role_id)
if role_id not in data["valid-roles"]:
try:
role = ctx.guild.get_role(role_id)
with open("data.json") as f:
data = json.load(f)
data["valid-roles"].append(role_id)
with open('data.json', 'w') as f:
json.dump(data, f)
em = discord.Embed(title="Jayys", description="You have successfully added `{}` to the list of roles with access to tickets.".format(role.name), color=000000)
await ctx.send(embed=em)
except:
em = discord.Embed(title="Jayys Tickets", description="That isn't a valid role ID. Please try again with a valid role ID.")
await ctx.send(embed=em)
else:
em = discord.Embed(title="Jayys Tickets", description="That role already has access to tickets!", color=000000)
await ctx.send(embed=em)
else:
em = discord.Embed(title="Jayys Tickets", description="Sorry, you don't have permission to run that command.", color=000000)
await ctx.send(embed=em)
nothing
ohk
is the current code thats adding roles, i need it changed to adding users.
not much
but it makes a folder a valid library
you can either import a file which just works
if you import a folder containing multiple .py files, and you want to import that folder, python needs to know what to import and how, so you need a valid __init__.py to tell it how and what to import
how do i make the confirmation embed only send once and then the messages that come after that, it would add a check mark reaction? https://hastebin.com/nurizexogi.properties
@valid niche
clean up your imports wtf
do u know anything abt changing this code to add users instead of role?
@client.command()
async def addaccess(ctx, role_id=None):
with open('data.json') as f:
data = json.load(f)
valid_user = False
for role_id in data["verified-roles"]:
try:
if ctx.guild.get_role(role_id) in ctx.author.roles:
valid_user = True
except:
pass
if valid_user or ctx.author.guild_permissions.administrator:
role_id = int(role_id)
if role_id not in data["valid-roles"]:
try:
role = ctx.guild.get_role(role_id)
with open("data.json") as f:
data = json.load(f)
data["valid-roles"].append(role_id)
with open('data.json', 'w') as f:
json.dump(data, f)
em = discord.Embed(title="Jayys", description="You have successfully added `{}` to the list of roles with access to tickets.".format(role.name), color=000000)
await ctx.send(embed=em)
except:
em = discord.Embed(title="Jayys Tickets", description="That isn't a valid role ID. Please try again with a valid role ID.")
await ctx.send(embed=em)
else:
em = discord.Embed(title="Jayys Tickets", description="That role already has access to tickets!", color=000000)
await ctx.send(embed=em)
else:
em = discord.Embed(title="Jayys Tickets", description="Sorry, you don't have permission to run that command.", color=000000)
await ctx.send(embed=em)
because your __init__.py isn't correct
it's not in the right location
and i have a feeling it isn't structured well either
hey i need help here any one know how i can get channel id
bro init.py doesn.t have anything right
well you're doing pretty much EVERYTHING with roles so not sure what you want to do
bro right click channel scroll down and channel id copy
doesn't mean you can just put it in 1 folder and expect it to work.
change the roles to user
an empty __init__.py doesn't do anything, you need to do things
okay then change it
then change the roles to users?
if you wrote that code and you cant even edit it that means its just copied
not like this
i want my bot to get me the id of the channel that the msg sent on
wont work i tried it
this one should work
that's the way so you did something else wrong
yes
thanks
it's literally channel.id
try ctx.channel.id
ok?
its should work
src:
@bot.command()
async def afk(ctx, reason="No reason provided"):
if "@" in reason:
return await ctx.send("Please don't include mentions in your AFK reason.")
with open("afk.json", "r") as f:
load = json.load(f)
load[str(ctx.author.id)] = reason
with open("afk.json", "w") as f:
json.dump(load, f, indent=4)
await ctx.send(f"I set your AFK to: {reason}")
@bot.event
async def on_message(message):
with open("afk.json", "r") as f:
load = json.load(f)
if str(message.author.id) in load.keys():
load.pop(str(message.author.id))
with open("afk.json", "w") as f:
json.dump(load, f, indent=4)
await message.channel.send(f"Welcome back {message.author.mention}! I removed your AFK.")
return
if len(message.mentions) > 0:
target = message.mentions[0]
try:
msg = load[str(target.id)]
except KeyError:
return
await message.reply(f"**{target}** is AFK: {msg}")```
`json src`
{
}```
can anyone help? sry for flood
dont use json
its ohk ur bot is spamming right
any ideas what i should do?
yes use mysql or pymongo
how would i do that exactly? cuz json files and db files arent exactly my specialty
newest one
send ss = screenshot
you're using json AND you're storing IDs as string?
like why
now i still have anther problem
how do i make a code that give a member a perm and i have the channel id and the member id
json will waste your time if you're planning to use it like this
yes it will cause it can break also many times
get_channel and then abc.GuildChannel.edit with the overwrites kwarg
and get_member to get the member
i have all that
Guild.get_member*
i have the channel id and the member id
ok
did it work ctx.channel.id
yes
ye prints is only for debug testing
it worked
i know you do, i just told you how to use them
man we good frnd XD
$roles
someone can help me?
roles u need roles
1 sec
!d discord.TextChannel.edit
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the 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 use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
overwrites kwarg
bro its blurred
nope i dont want to make a role for him
what?
i all ready have the id of everything i want to do i only didnt understand this
this channel edit not channel perm add and leave
you pass in a mapping of Role or Member and PermissionOverwrite to the overwrites kwarg
it edits the permissions
like i said idk the codes for it
perms = @slate swan_permissions(manage_roles=True,administrator=True,manage_channel=True) @hollow mortar
like i said idk the coding for that
this wont work
Literally some guy named has has been pinged WTF lol XD
cause you didnt give the channel id there
whai
ur making a private bot or personal bot
what do you mean
is it even your code? if you don't know how to edit your own code that's rather concerning
man i told you three times how to do it
its not getting delted right when we press the X button
friend made it for me but got off for a few days nd never fixed for me :/
bro i didnt understand what you saying
its too op for me lol
no i am starting to spoonfeed XD
!d discord.Client.get_channel
get_channel(id, /)```
Returns a channel or thread with the given ID.
lol
await edit(*, reason=None, **options)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Edits the 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 use this.
Changed in version 1.3: The `overwrites` keyword-only parameter was added.
Changed in version 1.4: The `type` keyword-only parameter was added.
Changed in version 2.0: Edits are no longer in-place, the newly edited channel is returned instead.
pass in the overwrites kwarg
yes and i don't know why
dpy is extremely complex, we are not going to spoonfeed and you'll need extensive knowledge of what you are doing and have a good base knowledge to write bots
whats kwarg ?
if you don't have that i'm sorry but you'll have to wait for that friend who made that code
keyword argument
bro im beginner not advance
refer to this then
discord.py is not for beginners
bruh everyone learned from scratch even you its okay if i didnt understand and asked
bro he also calls me the same so i renamed myself as Learning python first
so someone can help me?
yes, its okay for you to ask something, but you're a beginner and trying to use dpy which is something you aren't supposed to do
bro ur just demotivating people
i am?
yes
hahahha you are a good guy go sleep and if you dont want help ppl dont answear them ูุฑุญูุณู
How much Python do I need to know?
discord.py is ultimately a complicated Python library for beginners. There are many concepts in there that can trip a beginner up and could be confusing. The design of the library is to be easy to use -- however the target audience for the library is not complete beginners of Python.
With that being said, beginners tend to use this library quite liberally anyway and while I appreciate the endeavour and tenacity it should be noted that asking for help here does take up the valuable time of volunteers. As a result certain knowledge is required before you can actively participate in the help channels:
- The difference between instances and class attributes.
- e.g. guild.name vs discord.Guild.name or any variation of these.
- How to use data structures in the language.
- dict/tuple/list/str/...
- How to solve NameError or SyntaxError exceptions.
- How to read and understand tracebacks.
This list is not exhaustive
If these concepts are confusing -- please feel free to complete a smaller and simpler project first before diving into the complexities that is asynchronous programming in Python. The Python help channel (python-help) or the Python server (https://discord.gg/python) could also be a place to go for basic Python help.
he only want him self in discord.py bruh
read that
really bro lol
its ok just don't be hard or harsh on ppl just kindly tell them to learn d.py
slowly step by step
they need to learn python not dpy
and thats what im doing and when i get problem i try to find help
its ohk bro
it's like trying to run before even walking
and thats what i did and he doesnt want help and dont want me to learn it bruh
true
?????
!resources @hollow mortar this is useful for learning python
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
nyc 1ne Diabolical
u help lol
import discord
import datetime
import asyncpg
from datetime import datetime
from discord.ext import commands
class afk(commands.Cog, name="afk"):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def afk(self, ctx, *, note=None):
print("executed")
data = await self.bot.db.fetchrow("SELECT * FROM afknote WHERE guild_id = $1 AND user_id = $2",
(ctx.guild.id, ctx.author.id))
if note == None:
note = "No reason provided"
if data is None:
await self.bot.db.execute("INSERT INTO afknote(guild_id, user_id, note) VALUES ($1,$2,$3)",
(ctx.guild.id, f"[{ctx.author.id}]", note))
em = discord.Embed(
title=f"**MEMBER AFK**",
description=f"""{ctx.author.name} has gone afk\nAFK Note: {note}""",
timestamp=datetime.now(),
color=discord.Color.blurple()
)
em.set_thumbnail(url=ctx.author.avatar_url)
await ctx.send(embed=em)
name = f"[AFK]{ctx.author.name}"
await ctx.author.edit(nick=name)
print("something went wrong")
def setup(bot):
bot.add_cog(afk(bot))
error: data = await self.bot.db.fetchrow("SELECT * FROM afknote WHERE guild_id = $1 AND user_id = $2", AttributeError: 'Bot' object has no attribute 'db'
can anyone help me with this?
@hollow mortar bro have a look at it broo
kk
werent you the one who just said you didnt know how to use databases
sh
and now you have a full code about afk that requires you to have postgres
@slate swan have you done bot.db = in your main file under bot construction?
ok
nope
my bot's role is higher then my alts, and my alt is still able to ban someone higher then it
he must have copied lol
or self.db?
then stop copying code
bro perms and hierarchy
learn it
nope
Then i'm following blanket
could u invite me maybe so i can help u lol
dms
ys
You never defined bot.db
thats just bot.db = ('file name.db') basically, right?
no
maybe a pro in discord.py
And yes it'd be better if you ask for references here instead or copying code where you don't know what you are doing
how do i make the confirmation embed only send once and then the messages that come after that, it would add a check mark reaction? can anyone help? https://hastebin.com/nurizexogi.properties
you need to: install postgresql -> setup postgesql -> setup afknote table -> connect to the db with asyncpg
can i direct a user to a category of channels
ctx.add_reaction("emoji")
where do i put that?
oh
!d discord.Message.add_reaction
await add_reaction(emoji)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Add a reaction to the message.
The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/master/api.html#discord.Emoji "discord.Emoji").
You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.
above ur code
Define msg as what message you want the bot to react to
And then do await msg.add_reaction(emoji)
@slate swan its wrong.
await ctx.add_reaction("emoji")
No
this guy lol
Read the error? It is when you invoke a command without the proper argument needed
also datetime objects are not callable iirc
yes you cant do utils.utcnow()(...)
create a timedelta and substract it from the current time
but you dont even use end so idk why you need it
!d discord.ext.commands.Context.message
The message that triggered the command being executed.
^^
it works
btw man thanks for the PR
hello
any one know what this problem mean
raise InvalidArgument('target parameter must be either Member or Role')
discord.errors.InvalidArgument: target parameter must be either Member or Role
c:\Users\Mohamed_Zeton\Desktop\JOB 1\job.py:83: RuntimeWarning: coroutine 'GuildChannel.set_permissions' was never awaited
ctx.channel.set_permissions(user, read_messages=True, send_messages=True)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback```
i use this code
you didnt await it
thanks
@spring flax
ctx.message.add_reaction isnt ctx.add_reaction
yes i am sorry
lol sorry
hello, does discord.FFmpegOpusAudio.from_probe have better audio quality than FFmpegPCMAudio ?
what do i put if i want the bot to react to the messages after the confirmation message was sent?
hello
await ctx.channel.set_permissions(user, read_messages=True, read_messages_history=True, send_messages=True)```
got it working
error?
ty
k gr8
indents?
whats wrong with them
Hi
the command has to be in the class
Guys
lol
cog
I want a system bot project
ok
Ahh anyone have it?
someone can help me?
I don't think anyone would give out code
just like this
Where i can find one?
no
import discord
from discord.ext import commands
import json
import pathlib
afk_path = pathlib.Path(__file__).parent / "afk.json"
class afk(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=['afk'])
async def Afk(self, ctx, *, reason):
await ctx.message.delete()
if reason == None:
reason2 = 'I set your AFK'
reason = ''
else:
reason2 = f'I set your AFK, status: {reason}'
with open(afk_path, "r") as f:
data = json.load(f)
if ctx.author.id in (data[str(ctx.guild.id)]['AFK']):
await ctx.channel.send('You\'re a little to quick here', delete_after=5)
return
data[str(ctx.guild.id)]['AFK'][str(ctx.author.id)] = reason
await ctx.channel.send(f'{ctx.author.mention} {reason2}', delete_after=15)
with open(afk_path, "w") as f:
json.dump(data,f, indent = 4)
try:
await ctx.author.edit(nick='[AFK]'+ctx.author.name)
except:
pass
def setup(bot):
bot.add_cog(afk(bot))```
main file: ```py
#imports blah blah blah
bot.load_extension('cogs.afk')
#src here blah blah blah```
error: `discord.ext.commands.errors.CommandNotFound: Command "afk" is not found
`
anyone know how to fix?
indents
re-look at them
its the whole command
how to get animated emoji from another server?
i have no nitro so i cant use the :emoji: thing
Anyone using on_ย message ?
we all do-
this is gonna be worded abysmally but uhm can someone help like uh
ctx.guilds would be for guild in bot.guilds
guild being the key word
can i get the value to be number of letters in an embeds description?
how can i wait_for a message from members in a member list in any order?
msg = await self.bot.wait_for('message', check=lambda message: message.author == member1)
r u asking how to wait for message or wait for message from a specific user?-
and i thought my question made no sense lmao
for a message but from a list of users
if any of users input wrong answer in any order
ohh
i have found something like this
pending_tasks = [self.bot.wait_for('message',check= lambda message: message.author == member1), self.bot.wait_for('message',check= lambda message: message.author == member2)]
couldnt you do like an if statement before the wait for message saying
if member in listname:
the wait for function
and how check should look like
check = lambda message: message.author == ????
member from if maybe
ctx.author
apple = await bot.wait_for("message",
check=lambda m: m.channel == ctx.channel and ctx.author == user, timeout=50.0)
ctx.author == user?
user would be defined as ctx.author already when he checks the author before the wait for
import discord
from discord.ext import commands
import json
import pathlib
afk_path = pathlib.Path(__file__).parent / "afk.json"
class afk(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(aliases=['afk'])
async def Afk(self, ctx, *, reason):
await ctx.message.delete()
if reason == None:
reason2 = 'I set your AFK'
reason = ''
else:
reason2 = f'I set your AFK, status: {reason}'
with open(afk_path, "r") as f:
data = json.load(f)
if ctx.author.id in (data[str(ctx.guild.id)]['AFK']):
await ctx.channel.send('You\'re a little to quick here', delete_after=5)
return
data[str(ctx.guild.id)]['AFK'][str(ctx.author.id)] = reason
await ctx.channel.send(f'{ctx.author.mention} {reason2}', delete_after=15)
with open(afk_path, "w") as f:
json.dump(data,f, indent = 4)
try:
await ctx.author.edit(nick='[AFK]'+ctx.author.name)
except:
pass
def setup(bot):
bot.add_cog(afk(bot))```
main file: ```py
#imports blah blah blah
bot.load_extension('cogs.afk')
#src here blah blah blah```
error: ```Ignoring exception in command Afk:
Traceback (most recent call last):
if ctx.author.id in (data[str(ctx.guild.id)]['AFK']):
KeyError: '821722608767598663'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: '821722608767598663'
can anyone help?
how to i make it not display as a link?
@cloud dawn
names = {"yes", "kid"}
if ctx.author.display_name in names:
user = ctx.author
apple = await bot.wait_for("message",
check=lambda m: m.channel == ctx.channel and ctx.author == user, timeout=50.0)
else:
pass
set it as the image embed not description / feild value
emb.set_image?
so ctx.author == ctx.author?
embed.set_image(url=member.avatar_url)
kinda useless
lol
embed.set_image(url="")
user = ctx.author* my bad
member = ctx.author if not member else member
:D
Edit it? I still don't really understand.
wait what? i never said ctx.author == ctx.author
You did
where?
member is highlighted with yellow
OH you mean in the function
This in the check ctx.author == user
and user is defined as ctx.author
@cloud dawn
names = {"yes", "kid"}
if ctx.author.display_name in names:
user = ctx.author
apple = await bot.wait_for("message",
check=lambda m: m.channel == ctx.channel and m.author == user, timeout=50.0)
else:
pass
better?
put the url in " "
๐
lol my bad im not on my pc rn
No worries i was curious.
like this?
emb.set_image(url=f"{member.avatar_url}")
you should be able to just do this, i can, idk why you cant
Note:
If it is only a variable you can also just input the variable since the url returns as a string.
yeah ik thats why i said
import discord
from discord.ext import commands
import os
class Events(commands.Cog):
def __init__(self, client):
self.client = client
@self.client.event
async def on_ready():
print('Bot is now online!')
def setup(client):
client.add_cog(Events(client))
this
Why am I getting error
but he said it didnt work for him
@commands.Cog.listener()
ty
try that instead of @self.client.event
abboutta say
Works now lol
glad to hear lmao
Why ๐ณ
he wants u bro
xD cuz its nice having more friends
or she we never know
i identity as 100% blue wall
I identify as a f16 missile ready
lmao
seal
@twin thicket you friend me too if you want
@cloud dawn HOW OLD ARE YOU-
ur acc is like older than my sister
;-;
speak of the devil, my family is home
lmao
where you defined client
how do I get the descriptions, usages and that kinda shit tho
do , help_command=None
How old is the account?
like I have my categories and stuff
one sec ill say lemme load the website up again ;-;
I'm 18 though
client = commands.bot(command_prefix="dbakndns", help_commands=None)
i probably got the commands.Bot wrong
commands.Bot()
capital ;)
Yeah but like, I wanna make it an embed and get all my categories, description and shit
you know what I mean
do what i said then make a command called help
so I dont have to manually add the commands to the help command
I just did
dosent ctx.commands or smth exist
huh
It does
lol i was abt to ping you
But you can also just subclass the help command. <- i recommend this
how do I do tht
yes but thats boring
lol how
How dehel do I subclass
Still waiting on an answer btw
classes and shite
lemme know when the internet is back on
my bad it loaded a while ago
1992 days (my time zone)
plus classes are more annoying than a simple 4 lined command XD
yes
!e ```py
print(1992/365)
@cloud dawn :white_check_mark: Your eval job has completed with return code 0.
5.457534246575342
nice
lol
bit young for my taste but she'll get there
!e
print("a")
@wanton pebble :white_check_mark: Your eval job has completed with return code 0.
a
;)
hey i have question do i can make a bot that can check the channels in the category if the name of t he channel all ready exsist send a msg saying its there ?
sorry but i didnt understand a word you just said
if you're asking if a bot can scan a category for channels, idk if it can do category but it can do server
class Utility(commands.Cog):
def __init__(self, client):
self.client = client
#Commands
@commands.command()
async def ping(self, ctx):
"""Pings the bot"""
await ctx.send('Pong!')
@commands.command()
async def load(ctx, extension):
self.client.load_extension(f'cogs.{extension}')
@commands.command()
async def unload(ctx, extension):
self.client.unload_extension(f'cogs.{extension}')
!d discord.CategoryChannel.channels
property channels: List[GuildChannelType]```
Returns the channels that are under this category.
These are sorted by the official Discord UI, which places voice channels below the text channels.
anyone know why self.client is not defined?
you did it out of the class
nvm I just didnt add self as a parameter
Naming it client but using it as a bot 
fr plus client is just more letters smh
exactly
@twin thicket you not gonna make it owner only command?
ye I am
find and replace all tool exists
CTRL+H
Replace all
lol
or that
keys depend on the application
alt+f4 always works
nono it dosent work unless you click alt+f4 and enter, fast
||save menu always spoils it otheriwse||
ahem-
i wonder if eval can do a whole command
I don't see why not if it can import all modules
!e
import discord
from discord.ext import commands
bot=commands.Bot(command_prefix="a.")
@bot.event
async def on_ready():
print("e")
@wanton pebble :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'discord'
rip
Hate to break it but someone already made a bot inside a bot inside a bot inside a bot inside a bot ...
XD
Hey guys, does anyone know how i can ask the user for input in discord from a bot please?
I can't wait for the day my discord account exists 18 years then i can verify myself instantly on any 18+ server.
!d discord.ext.commands.Bot.wait_for
wait_for(event, *, check=None, timeout=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).
Waits for a WebSocket event to be dispatched.
This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.
The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.9)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.9)") for you in case of timeout and is provided for ease of use.
In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.9)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/master/api.html#discord-api-events) for a list of events and their parameters.
This function returns the **first event that meets the requirements**...
this is just lazy smh
The docs explain it much more detailed than us
Don't you spoonfeed the guy
yes but its more effort reading
id love to :3
How else will they learn?
by this
xD
people say giving someone something instead of making them work for it wont make them learn, its a misconception, think of it like this, if you do it enough, they'll remember ;)
anyway imma go make dinner/tea/food/whatever lmao
No...?
I like to make people learn and take the effort to read, if you click on the link you instantly see an example, if they know how to read the docs a lot of these questions will not be asked.
Thank you i appreciate it
Np i also got a small example on github if it is still unclear.
ig but that would leave me with nothing to do if everyone knew how to just look it up
I think i've done it now, just tested and everything looks good
I mean there could still be coding errors/problems even with someone who knows how to read the docs.
How do I make my bot add a reaction to a message does anyone know. Also does anyone know how I can make certain commands to only work for certain roles?
a=ctx.send("apple")
await a.add_reaction(":thumbsup:")
ok
from discord.app import option
Idk then
how do i host my discord bots to never go offline
Leave your pc on 24/7
How @ a role in an embed.
Lol
What software are you using to code?
Oh you used replit
I think you have to just play the code and it should stay up?
How do I @ a role in an embed.
Please dm me on how to do it.
<@& role id >
dont add the spaces , its just to demonstrate
ok
hello ! , does anyone know any nsfw api i could use ?
Will this work on an embed?
try embed.add_reaction
embed is whatever ur embed var is
does ctx.author.mention not work in embeds?
oh
which includes the embed
ok
yes , in anything beside the title
yuppp
title can just do name anywayz or set_author so it isnt really needed
after the _reaction do I put the reaction or what do i do?
add_reaction("EMOJI")
yeah
ok thanks
no await = discordpy intensely screams
lmao 
o
SIR-
can we see ?
U want a good api?
@bot.command(name='gamerules')
async def Gamerules(context):
embed = discord.Embed(title="SSU VOTE", description="SSU VOTE", color=0x26C3E4 )
embed.add_field(name="Vote for an ssu",value="@cyan sealโโโ", inline=False)
embed.add_reaction("")
await context.send(embed=embed)
yes pleaseee
Thatโs allowed if itโs in nsfw channel
its not for me , my server is horny and i figured out it would fit them perfectly
ik lol
Lmao
its & not !
await embed.add_reaction*
also put it after the send
you cant react to a mssage that dosent exist
He using context ahhhhh
ok
LMFAO
i think discordpy is always screaming with that type of code 
ctx > everything
use ctx instead 
^^
ok
discordpy screams at alot of things
Discord should have an api key system
and normal java screams for not having a capital S in print LMAO
it says ctx is not defined.
.....
he replaced the part where he used context , not where he defined context 
@bot.command()
async def apple(ctx):
^
lmfao
!code
@bot.command(name='gamerules')
async def Gamerules(context):
embed = discord.Embed(title="SSU VOTE", description="SSU VOTE", color=0x26C3E4 )
embed.add_field(name="Vote for an ssu",value="@cyan sealโโโ", inline=False)
await cxt.send(embed=embed)
await embed.add_reaction("")
So that should work
no
i feel bad for laughing
also if you wanna make embed easier
at the top
from discord import Embed
and do
embed=Embed(title="yes",
description="no")
ok
@bot.command(name='gamerules')
async def Gamerules(ctx):
embed = discord.Embed(title="SSU VOTE", description="SSU VOTE", color=0x26C3E4 )
embed.add_field(name="Vote for an ssu",value="@cyan sealโโโ", inline=False)
await ctx.send(embed=embed)
await embed.add_reaction("")
idm This is my first bot.
so let me explain you are defining something the decorator passes which you know as context , its defined in the parameters / brackets of a function , you change its name , it would change the whole context name and would give you a not defined error
uh spoon feeding him would make him return to here more often
i was abt to explain it lmao
explaining it and checking his understanding is a better way i guess
@slate swan line 2, you said (context), ctx is what you need. always do ctx instead of context.
name isnt really needed imo
you misspelled ctx.send you said cxt.send
Ah ok
@slate swan tbf at least hes using bot and not client
why are you doing embed.add_reaction
i could agree on that one
yeah correct
@bot.command(name='gamerules')
async def Gamerules(ctx):
embed = discord.Embed(title="SSU VOTE", description="SSU VOTE", color=0x26C3E4 )
embed.add_field(name="Vote for an ssu",value="<@&880070377840201778>โโโ", inline=False)
x = await ctx.send(embed=embed)
await x.add_reaction("")```
kira the first answer you sent was the correct one
oops thats my fault i said to use embed not thinking hed axtually use embed variable
i said that first and assumed when i said embed he'd knew to make embed into a diff var as it was sending
so this is what I should be using?
yes use that
ok
what would be cool is if they added it so each field could have a different embed colour on the side of the field
lmao
now for me i think I should have started by just making it say hello world in a message.
lmfao
at least pushing yourself gives you room to learn ig but yeah try not to jump too far
@slate swan are you familiar with OOP ? or python basics ?
decorators etc
for me I went
steep 1. make the bot
step 2. download everything I need
step 3. Don't follow the tutorial and just go into it
step 4. realise I know nothing about python.
hey i want to ask do i can make a bot that triger if a channel named snkrs is in the category and if yes it doesnt make ppl create it again
like a bot that triger if a channel called snkrs is in category nike a guy cant make new snkrs channel using the bot untile he close the first one
do i can make that happen with discord.py
already answered
fair enough , when you find yourself stuck about anything search it up and learn it , would help you code
Ok will do.
yeah i saw that but i didnt understnad it to be honest
you could loop over the guild channels as an example
for i in ctx.guild.channels:
print(i)```
stack overflow is literally my lifes saviour
you really need to learn how to read docs before you code lmao
i recommend asking a yt vid how to understand docs cuz if not it'll only get harder
lmao thats not a normal dock right
you mean docs is a programing thing ?
like i need to learn it first ?>
it is the docs for discordpy
yeah i know but i dont understnad the discord.py ones cuz its not a code and kinda hard
to understand
stack overflow destroyed my life , they share terrible code , not all the time , but most let me show you a example, look at this code here https://stackoverflow.com/questions/55742719/is-there-a-way-i-can-unban-using-my-discord-py-rewrite-bot
and what i wrote
its a unban command
@commands.command()
@commands.has_permissions(ban_members=True)
@commands.cooldown(1,5,BucketType.member)
async def unban(self,ctx,* , member: typing.Union[discord.Object,discord.User]):
await ctx.guild.unban(member)
embed = discord.Embed(title=f"",description=f'{member} have been unbanned for\n CHEERS !')
await ctx.send(embed=embed)``` 
How do i make an unban command in Discord.py Rewrite i wanted to clear my question because there is no bot.unban command (maybe it is) and the player is not in the list so i can mention the user
E...
what do you mean "not a code"
do you expect them to just give you code
thats not how documentation works
like how do i can make of docs ?
can you explain your question again ?
like i dont understand how you can make a code out of doc
you search the methods you need
i know its a stupid one lmao
look at the arguments, return type, etc
the errors it can raise
you dont make a code out of documentation
itโs a reference
i dont see the issue?-
still didnt understnad but i will try to look videos that might help
i get sometimes the code can be untrustworthy but thats why you should know python basics before so you can gauge what the code would do before using it
videos that are related to dpy are a no-go
most of them are bad vids that teach bad practices
that one doesnt take a user id , and only checks the tag , also it using a for loop which will takes more time , and checking it that user matches the statement which is more time , and finally its fetching the bans which is even more time 
just use member converters?-
i know some basics and how code works but i dont understnad docs
ah yes, unbanning a member, the classic
well , thats not the best way out there , could work for a bit , but what i did is better ig
how are you going to get the member if theyโre not even in the guild
converters are effective, short and get the job done
learn about OOP and you should make sure to know stuff names like instances objects etc , this would help
and also euclid is using the User converter which works just fine
kk thanks alot i will look in to it
yeah ik , but the basic converter is kinda ugly 
and still works
what is the "basic converter"
typehinting as discord.User is the same as doing commands.UserConverter
How do I make it so that only specific roles can use a command?
ok.
role works too for singular
!d discord.ext.commands.has_role
@discord.ext.commands.has_role(item)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has the role specified via the name or ID specified.
If a string is specified, you must give the exact name of the role, including caps and spelling.
If an integer is specified, you must give the exact snowflake ID of the role.
If the message is invoked in a private message context then the check will return `False`.
This check raises one of two special exceptions, [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") if the user is missing a role, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingRole "discord.ext.commands.MissingRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
but most likley if the bot doesnt share any servers with the banned victim it woulndt be able to unban it with discord.User , thats were discord.Object saves us
breh ok
see lmao
where*
UserConverter calls the api if the user isnโt in cache
so it basically never fails
@high flame
!d discord.ext.commands.has_any_role
@discord.ext.commands.has_any_role(*items)```
A [`check()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.check "discord.ext.commands.check") that is added that checks if the member invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return True.
Similar to [`has_role()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.has_role "discord.ext.commands.has_role"), the names or IDs passed in must be exact.
This check raises one of two special exceptions, [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") if the user is missing all roles, or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") if it is used in a private message. Both inherit from [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure").
Changed in version 1.1: Raise [`MissingAnyRole`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.MissingAnyRole "discord.ext.commands.MissingAnyRole") or [`NoPrivateMessage`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.NoPrivateMessage "discord.ext.commands.NoPrivateMessage") instead of generic [`CheckFailure`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.CheckFailure "discord.ext.commands.CheckFailure")
who deleted-
hmm?
there isnโt an event for that
no event
you need to track the serverโs activness yourself
@slate swan
Yes?
look at that
ok
an event isnโt a command
i'd use on_message and some other stuff
you can list guilds its in i think but not event and idk abt most active
and a database
you can use db to count messages, joins, ect.. and define it as the guild username then order by size
it seems he mentioned that already
!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.
can you get the user that banned another user from a guild
I don't really think so.
!d discord.BanEntry
class discord.BanEntry```
A namedtuple which represents a ban returned from [`bans()`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild.bans "discord.Guild.bans").
It only returns the reason and the banned user.
Actually, you can.
!d discord.Guild.audit_logs yields a discord.AuditLogEntry which has user attribute (who did the action), action attribute (the action done), target attribute (the user/channel/etc.. whom the action was done to).
async for ... in audit_logs(*, limit=100, before=None, after=None, oldest_first=None, user=None, action=None)```
Returns an [`AsyncIterator`](https://discordpy.readthedocs.io/en/master/api.html#discord.AsyncIterator "discord.AsyncIterator") that enables receiving the guildโs audit logs.
You must have the [`view_audit_log`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.view_audit_log "discord.Permissions.view_audit_log") permission to use this.
Examples
Getting the first 100 entries:
```py
async for entry in guild.audit_logs(limit=100):
print(f'{entry.user} did {entry.action} to {entry.target}')
```...
How do i specify how many messages can be cached at once?
Context?
to limit how much ram is being used, etc
max_messages
Hi! I am current making a discord bot and am working on an auto moderation system. I am including an "alias letter" detectopn system to prevent people from being creative and bypassing the filter using lookalike letters/characters. Is there a chance anyone here has a large dictionary of these that i could use?
You can set it when making an instance of bot
alr ty
Saved me about 150mb so far, thanks
Np
this code ```py
async def updateLoop():
print(f"\n", end='')
print(f"\nStarting update loop...", end='')
await bot.wait_until_ready()
channel = bot.get_channel(STREAMER_CHANNEL)
while(True):
today = datetime.datetime.today()
weekday = today.weekday()
now = datetime.datetime.now()
value = MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1]
if (value != "" and value != None):
await channel.purge()
sleep(1)
await channel.send(f"{value} is now live!\nhttps://www.twitch.tv/{value}")
MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1] = ""
writeToFile()
await updateImage()
updatestreamerweb()
channel = bot.get_channel(878637135337492502)
await channel.send('@everyone Make sure to check out our awesome website and watch our featured streamers on it to earn points so you can unlock the request feature role on discord by buying it with the points you earn https://www.so-network.blackbullstudio.eu')
else:
print("randomfeature")
future = datetime.datetime(today.year, today.month, today.day, today.hour, 0)
await asyncio.sleep( (future-today).total_seconds() )
returns this
how can i execute this only once but reactivate it when its false again
can you show your code, and maybe the full traceback
if result['card_amount'] > 1:
await self.client.pg_db.execute("UPDATE pokesetspc SET card_amount = card_amount - 1 WHERE user_id = $1 AND cardid = $2",ctx.author.id,id)
if result['card_amount'] == 1:
await self.client.pg_db.execute("DELETE FROM pokesetspc WHERE user_id = $1 AND cardid = $2",ctx.author.id,id)
if result3['card_amount'] is None or result3 is None:
await self.client.pg_db.execute("INSERT INTO pokesetspc(user_id,cardid,pc,card_rarity_card_set_name) VALUES($1,$2,$3,$4,$5)",ctx.author.id,id2,result2[0],result2[3],result2[4])
if result3['card_amount'] > 1:
await self.client.pg_db.execute("UPDATE pokesetspc SET card_amount = card_amount + 1 WHERE user_id = $1 AND cardid = $2",ctx.author.id,id2)
if result2['card_amount'] > 1:
await self.client.pg_db.execute("UPDATE pokesetspc SET card_amount = card_amount - 1 WHERE user_id = $1 AND cardid = $2",member.id,id2)
if result2['card_amount'] == 1:
await self.client.pg_db.execute("DELETE FROM pokesetspc WHERE user_id = $1 AND cardid = $2",member.id,id2)
if result4['card_amount'] is None or result4 is None:
await self.client.pg_db.execute("INSERT INTO pokesetspc(user_id,cardid,pc,card_rarity,card_set_name) VALUES($1,$2,$3,$4,$5)",member.id,id,result[0],result[3],result[4])
if result4['card_amount'] > 1:
await self.client.pg_db.execute("UPDATE pokesetspc SET card_amount = card_amount + 1 WHERE user_id = $1 AND cardid = $2",member.id,id)
that means result3 is None, also you have an await outside of an async function
yea ik about the await outside async function
but am i not handling that already?
can you show where your defining result3
result = await self.client.pg_db.fetchrow("SELECT pc,cardid,card_amount,card_rarity,card_set_name FROM pokesetspc WHERE user_id = $1 AND cardid = $2",ctx.author.id,id)
result2 = await self.client.pg_db.fetchrow("SELECT pc,cardid,card_amount,card_rarity,card_set_name FROM pokesetspc WHERE user_id = $1 AND cardid = $2",member.id,id2)
result3 = await self.client.pg_db.fetchrow("SELECT pc,cardid,card_amount,card_rarity,card_set_name FROM pokesetspc WHERE user_id = $1 AND cardid = $2",ctx.author.id,id2)
result4 = await self.client.pg_db.fetchrow("SELECT pc,cardid,card_amount,card_rarity,card_set_name FROM pokesetspc WHERE user_id = $1 AND cardid = $2",member.id,id)
dont mind the indents
@little ether
is there someone who can help me out by any chance ?
to check if result3 is None, put this at the top of your if stack if result3 is None
yea i think because its a help channel?
Xd okey
ok ill try that
this code ```py
async def updateLoop():
print(f"\n", end='')
print(f"\nStarting update loop...", end='')
await bot.wait_until_ready()
channel = bot.get_channel(STREAMER_CHANNEL)
while(True):
today = datetime.datetime.today()
weekday = today.weekday()
now = datetime.datetime.now()
value = MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1]
if (value != "" and value != None):
await channel.purge()
sleep(1)
await channel.send(f"{value} is now live!\nhttps://www.twitch.tv/{value}")
MATRIX[TIMES.index(f"{now.hour}:00")+1][weekday+1] = ""
writeToFile()
await updateImage()
updatestreamerweb()
channel = bot.get_channel(878637135337492502)
await channel.send('@everyone Make sure to check out our awesome website and watch our featured streamers on it to earn points so you can unlock the request feature role on discord by buying it with the points you earn https://www.so-network.blackbullstudio.eu')
else:
print("randomfeature")
future = datetime.datetime(today.year, today.month, today.day, today.hour, 0)
await asyncio.sleep( (future-today).total_seconds() )
returns this
how can i execute this only once but reactivate it when its false again
instead of it spamming randomfeature i want it to execute it only once if the function is called
no no one knows Xd
i made a buttons calculator command and was hoping that it'll work but then i got this error and now idk what to do
this is the current code https://hastebin.com/gujehoyini.py
wait nvm i fixed it
uh why are you pinging random staff members
i need help
you never broke out of the loop.
look
how do i make a warn system
help
Please don't ping random people for help.
okay i need help again
well lol
now its saying this
that's like asking as to make a bot for you
and whenever i try the command, it returns with this
please help https://hastebin.com/qucuvusoxi.py
!eval {len(self.client.commands)}
@stoic galleon :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 'self' is not defined
if you said you wanna learn discord.py, the tutorial's here https://vcokltfre.dev/
A tutorial on how to use discord.py to create your own Discord bot in Python, written to fix the flaws of many other popular tutorials.

i know but i need to use the if and when false do a action
can someone help .-.
whta
what
why are you in a hurry
with this
what are your imports?
import discord
from discord.ext import commands
import googletrans
from discord_components import *
from datetime import datetime
think youre missing some
is that for the cogs file? or the main one as well
