#discord-bots

1 messages · Page 836 of 1

uneven pasture
#

I have a discord bot that is using chatterbot model to achieve auto response, but for some reasons, the bot seems taking longer to response than expected, is it my hardware problem or can I use some method to speed it up?

trainer = ListTrainer(chatbot)
file = open('message.txt', 'r')
conversation = [line.strip() for line in file]
trainer.train(conversation)
client = discord.Client()

@client.event
async def on_ready():
    print(f'Who wants some pizza!?')

@client.event
async def on_message(message):

    if message.author == client.user:
        return

    response = chatbot.get_response(message.content)
    print(f'{message.channel}, {message.author.name}: {message.content} response: {response}')
    await message.channel.send(response)

client.run(TOKEN)
cedar stream
#

On vps

slate swan
#

i gived them full perms too

manic wing
#

no error?

slate swan
#

nope

manic wing
#

odd

slate swan
#

if i type ?stock nothing happing

manic wing
#

do other commands work?

slate swan
#

?info

#

or ?help

manic wing
pliant gulch
#

!d discord.utils.format_dt you could also just use this

unkempt canyonBOT
#

discord.utils.format_dt(dt, /, style=None)```
A helper function to format a [`datetime.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime "(in Python v3.9)") for presentation within Discord.

This allows for a locale-independent way of presenting data using Discord specific Markdown...
full lily
#

I dont understand what you're asking

manic wing
#

interesting way to learn :)

full lily
#

What's with the attitude? I've told you about 3 times what to write. If you have a question, ask away...

sick birch
#

round it or int it

full lily
#

sorry the method is .timestamp() not epoch

manic wing
# slate swan

strange…very strange. Do you have an error handler that is silencing your errors? try adding multiple prints to see where it stops working

full lily
#

yes, do it to both, assuming both are returning datetime.datetime

neat pagoda
#

Ayo, how do you get the manufacture cooldown time to be in 00.00 format not 0.0000000000000 format lol, here's the code:

async def timecalc(a):
    if a<0:
        text="Ready"    
    if a<60 and a>0:
        text="{} Seconds".format(a)
    if a<3600 and a>60:
        a=round(a/60)
        text="{} Minutes".format(a)
    if a>3600:
        a=round(a/3600)
        text="{} Hours".format(a)
    return text
async def cooldown_cmd(ctx):
  cool = 86400
  users3 = await get_cooldown()
  man = users3[str(ctx.author.id)]['manufacture_cd']
  dd = users3[str(ctx.author.id)]['daily']
  dr=users3[str(ctx.author.id)]['rank_cd']
  v=users3[str(ctx.author.id)]['vote']
  ds = datetime.now()
  ds = ds.timestamp()
  a = cool - (ds-dd)
  time= await timecalc(a)
  text="**Daily:**\n:stopwatch: {}".format(time)   

  b=cool-(ds-dr)
  time1=await timecalc(b)
  text+="\n**Rankup:**\n:stopwatch: {}".format(time1)
    
  c=cool-(ds-v)
  time2=await timecalc(c)
  text+="\n**Vote:**\n:stopwatch: {}".format(time2)
  
  d=15.00-(ds-man)
  if d == "0":
    text+="\n**Manufacture:**\n:stopwatch: {}".format(round(d,2))
  
  else:
    time3=await timecalc(d)
    text+="\n**Manufacture:**\n:stopwatch: {}".format(time3)
full lily
neat pagoda
full lily
#

tried it and it didn't work?

neat pagoda
#

yes

full lily
#

what was the problem

#

oh it must be a string

neat pagoda
full lily
#

you could slice it I wonder

sick birch
#

.timestamp() will return the UNIX timestamp of a datetime

manic wing
royal meteor
#

How would I access command.name and command.description inside this for loop?

full lily
#

don't use epoch at all, that was my mistake. Use .timestamp()

manic wing
#

and do “./Accounts

sick birch
#

it works with both .created_at and .joined_at

pliant gulch
manic wing
manic wing
#

np

slate swan
#

i did /Accounts only

manic wing
#

ok

#

if it works it works

full lily
final iron
full lily
#

remove epoch. There is no epoch. Use .timestamp()

sick birch
#

Frontogenesis said that was a mistake, use timestamp() and not epoch()

pliant gulch
#

Ok lol, you do you. Not sure why you wouldn't use the already created helper for you

tacit storm
#

if you’re having such little knowledge to try anything with any of this,
im sorry to break it to you but you’re never gonna be able to successfully make a bot.

stop@giving attitude to people just trying to help

pliant gulch
#

It's like re-inventing the wheel

full lily
sick birch
#

We said repeatedly it's .timestamp() and not .epoch(), why are you mixing the 2?

#
  • member.joined_at.timestamp() - unix timestamp of the time a user joined
  • member.created_at.timestamp() - unix timestamp of the time a user created their account
#

You int the resulting .timestamp(), not the datetime.datetime object

royal meteor
#

How would I access command.name and command.description in the for loop since I need it as part of my help_embed.

sick birch
#

since the resulting timestamp returns a float

#

If you did that you would get an invalid timestamp

rotund creek
#

Why tf are my commands not working

#

Its been 1 hour

#

I debugged everything

sick birch
#

int() the resulting member.*_at.timestamp() function

rotund creek
#

No command is invoking

sick birch
#

i.e int(member.created_at.timestamp()

#

No, you're doing int(member.created_at).timestamp()

hoary cargo
sick birch
#

It should be very simple

#

there you are

#

Which error did it cause?

#

The problem is you have everything on one line so it's hard to tell where in that line that error is

#

It would make it simpler on your and help you fix errors if you seperated it in a logical manner

#

I know, you can still seperate it out into multiple variables

final iron
#

🍿

#

How are you guys still talking about this

hoary cargo
#

lmao

sick birch
#
joined_at = int(member.joined_at.timestamp())
created_at = int(member.created_at.timestamp())
discord.Embed(..., description=f'Joined at: {joined_at} created at {created_at}', ...)
slim ibex
#

🗿

sick birch
#

it's really that simple

slim ibex
#

what?

tidal hawk
#

How to set embed value empty

pliant gulch
sick birch
#

forgot the int

pliant gulch
#

But an empty string will not work

slim ibex
#

Andy 🗿

pliant gulch
#

binds 🗿

hoary cargo
slim ibex
#

\u200b

#

?

tidal hawk
#

Can you send multiple embeds at once?

pliant gulch
#

Yea, 10 max at a time

royal meteor
#

How would I access command and its name and description attributes in this for loop?

final iron
unkempt canyonBOT
#

await send(content=None, *, tts=None, embed=None, embeds=None, file=None, files=None, stickers=None, delete_after=None, nonce=None, allowed_mentions=None, reference=None, mention_author=None, view=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Sends a message to the destination with the content given.

The content must be a type that can convert to a string through `str(content)`. If the content is set to `None` (the default), then the `embed` parameter must be provided.

To upload a single file, the `file` parameter should be used with a single [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") object. To upload multiple files, the `files` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`File`](https://discordpy.readthedocs.io/en/master/api.html#discord.File "discord.File") objects. **Specifying both parameters will lead to an exception**.

To upload a single embed, the `embed` parameter should be used with a single [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") object. To upload multiple embeds, the `embeds` parameter should be used with a [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Embed`](https://discordpy.readthedocs.io/en/master/api.html#discord.Embed "discord.Embed") objects. **Specifying both parameters will lead to an exception**.
final iron
#

embeds kwarg

rotund creek
#

Omfg its my 5th time asking

#

Why is none of my commands working?!?!!??!?

final iron
#

You've given no information

rotund creek
#

Give me tips on why it couldnt?

final iron
#

Imagine someone goes up to you and asks why their car isn't working

#

How would you respond to that?

rotund creek
#

It litterary was working yesterday and today I wake up and its not working

rotund creek
#

And itll be just like you saying on_message as its a simple fix to commands not working?

plain onyx
#

member.roles gives you a list of the member's roles

final iron
#

It would be pointless for me to list off the hundreds of reasons your commands could not be working

plain onyx
#

You have to select a role to be able to use the mention property

rotund creek
rotund creek
#

You literary arent making any sense

royal meteor
full lily
#

It's true, you need to give some context to your problem. We have nothing to work from

plain onyx
#

So you want to put all the roles a user has in an embed? Or just one role

rotund creek
royal meteor
rotund creek
#

If he doesnt specify why his car doesnt work there are so many possibilities

#

His analogy litterary done the opposite

fast vortex
#

You're demanding help without giving us any info

rotund creek
#

Yall dont understand

#

Just shut up now

#

Lets stop this bickering

royal meteor
rotund creek
royal meteor
#

How to specify in paginator that you want a specific number of embeds per page?

iron sorrel
#

[c for c in comms]
is same as just comms

royal meteor
iron sorrel
#
" ".join([role.mention for role in member.roles])```
final iron
#

!d discord.Member.roles

unkempt canyonBOT
#

property roles: List[Role]```
A [`list`](https://docs.python.org/3/library/stdtypes.html#list "(in Python v3.9)") of [`Role`](https://discordpy.readthedocs.io/en/master/api.html#discord.Role "discord.Role") that the member belongs to. Note that the first element of this list is always the default [‘@everyone](mailto:'%40everyone)’ role.

These roles are sorted by their position in the role hierarchy.
final iron
#

Then loop through the list, mentioning them

royal meteor
#

Does this take a page = arg?

final iron
plain onyx
#
@client.command()
async def get_roles(ctx: commands.Context):
    print(ctx.author.roles) # for debugging purposes
    embed = discord.Embed()
    roles = [r.name for r in ctx.author.roles]
    embed.add_field(name='Roles', value='\n'.join(roles))
    await ctx.channel.send(embed=embed)
royal meteor
plain onyx
final iron
#

!pypi disputils

unkempt canyonBOT
final iron
#

Then mention them

#

!d discord.Role.mention

unkempt canyonBOT
plain onyx
#

I don't think you can use an embed then. You'll just have to mention them

final iron
#

Send the code

#

We cannot read that

royal meteor
final iron
#

Not going to help then

plain onyx
#

😂

final iron
royal meteor
final iron
final iron
#

Strange it wasn't listed in their pypi

plain onyx
#

@slate swan so as you can see here, an embed won't actually mention the roles, but a regular message will.

#

The code is " ".join([role.mention for role in member.roles]), as pep8 officer already mentioned

full lily
#

They are clickable, you won't get a ping from them though

#

no "mention"

plain onyx
full lily
#

OKidoke

plain onyx
#

Assuming you want to put them in the description, you could put a line above the description line like:
roles = [r.mention for r in ctx.author.roles][1:]

#

And then just add the roles variable to your description

#

You don't, it's only used in that list comprehension statement

#

r is defined in the for loop there

#

Show your current code please

#

Oh sorry, forgot to mention the " ".join() part

#

roles = " ".join([r.mention for r in ctx.author.roles][1:])

#

Now, if you don't have any roles besides everyone, no roles will show

#

Change ctx.author.roles to member.roles

#

Since I see there is a member arg in your command

#

Add the fix I just posted too

#

How are you running the command?

#

What are you expecting to happen if no user is mentioned?

#

ok one sec

#
if member:
    author = member
else:
    author = ctx.author
roles = [r.mention for r in author.roles][1:]
#

you can do that too

#

no, author is the person who sent the command. member is an optional argument you have specified that goes after the command

#

member could be you or anyone you mentioned

pliant gulch
plain onyx
#

No, the NoneType error means that no member was mentioned, and the default value for member is None, as you have set it.

#

So just use the code I posted?

#

Or use a ternary condition like andy mentioned?

#
  @commands.command()
  async def userinfo(self, ctx, member : discord.Member = None):
    member = member if member is not None else ctx.author
    roles = [r.mention for r in member.roles][1:]
    uiEmbed = discord.Embed(
      description=f"**Created**\n<t:{int(member.created_at.timestamp())}:f>\n\n**Joined**\n<t:{int(member.joined_at.timestamp())}:f>\n\n{roles}",
      color=colors.colors
    )
slate swan
#

how do i make a bot like @novel apex

#

ping me

#

if you can help

plain onyx
#

See, you have to define member before you get the roles, since member.roles is accessed in the next line.

plain onyx
#

You could probably use an async ping library

oblique laurel
#

I dont think you can get ips like that lol

rare saddle
#

What features must be present in the bot in order to approve the Privileged Gateway Intents?

In particular, PRESENCE INTENT and SERVER MEMBERS INTENT.

plain onyx
#

@slate swan I just tested it with aioping. Works pretty well

#
import aioping

@client.command()
async def ping(ctx, ip):
    try:
        delay = await aioping.ping(ip) * 1000
        await ctx.reply(f"Ping response in {delay} ms")
    except TimeoutError:
        await ctx.reply("Ping timed out!")
    except Exception as e:
        await ctx.reply(repr(e))
slate swan
#

why do u need a command like that?

#

why not

#

good email provider ngl

#

it is tho

plain onyx
#

Do you know which bot that's from? Maybe you can find the source code

slate swan
#

ah, that shouldnt be too hard

#

pretty sure i saw something like that on github the other day, similar but not the same

#

sec

slate swan
#

can't find it rn, try using pythonping or icmplib

#

@slate swan

#

look into the libs i sent, they can do that and it's not hard

plain onyx
#

I'll spoonfeed u froge

#

not u, ares

royal meteor
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'list' object has no attribute 'name'```
plain onyx
#

🤷 worked for me

#

Oh are you on a mac or linux or something?

#

Might be why

sick birch
#

Isn’t there icmpv4 and icmpv6?

plain onyx
slate swan
plain onyx
#

👍

hollow urchin
#

hey can someone help me with my bot

sick birch
hollow urchin
#

ok

plain onyx
#

Serving up some tasty d.py meals

hollow urchin
#

Okay, so basically I paid someone (in another server) to make me an discord bot that can get information on an tiktok account using a tiktok api it worked fine for them but when they sent me the source code and i tried setting it up by my self everything is working and I can run the bot with no problems, but the / commands arent working and my bot is ran by / commands here is my whole project. https://github.com/riooncrack/swm

GitHub

Contribute to riooncrack/swm development by creating an account on GitHub.

slim ibex
hollow urchin
#

heres an example of them using it.

final iron
hollow urchin
#

@sick birch your an helper can u help me

slim ibex
#

does the bot not respond to your invocation attempt?

hollow urchin
final iron
#

How long have you waited?

hollow urchin
#

ughm i mean i made the bot today.

final iron
#

The commands need to get registered

#

This can take up to an hour

hollow urchin
#

does my bot need to be online?

final iron
#

Ask Andy

pliant gulch
#

You also need to make sure your bot has the application.commands scope, otherwise it just won't work

hollow urchin
#

how do i do that lol

cloud dawn
pliant gulch
#

When you make the invite link, you can select scopes

#

You add the application.commands scope

hollow urchin
#

it wasnt selected is that why.

hollow urchin
#

ok

royal meteor
#

Anybody?

hollow urchin
#

im not on my pc right now is their any other available host options?

slate swan
#

For free on GitHub

royal meteor
cloud dawn
royal meteor
cloud dawn
# hollow urchin it was $8 idc

Im glad it was only 8$ since this code is not very good. If you bought this and it isn't working you can also contact the seller. What exactly "isn't working"?

cloud dawn
hollow urchin
#

I did he is sleeping

slate swan
#

A lot of unnecessary stuff for just one command

hollow urchin
#

well is their anyone willing to host for an hour so I can get the commands

slate swan
#

Use replit or something

hollow urchin
#

i dont know hwo

#

im on mobile rn can i still use it?

slate swan
#

Yes

royal meteor
oblique laurel
#

Replit is online

hollow urchin
#

can someone teach me in dms

cloud dawn
pliant gulch
#

Pretty sure your bot doesn't need to be online after you made the request to register the command

hollow urchin
#

i dont know how to modify it

oblique laurel
pliant gulch
#

Within that 1 hour time-frame it should register by then without needing the bot online

slate swan
#

?rule 11

hollow urchin
#

i did

#

?rule 11

#

?rule 1

oblique laurel
#

Its ! I think

slate swan
#

Oh this isn’t discord py serber

oblique laurel
#

Indeed

slate swan
oblique laurel
#

Not sure if replit would support the tiktok api thp. It might

slate swan
#

it would

#

It can import stuff

cloud dawn
cloud dawn
oblique laurel
#

Replit is notoriously bad at life, so my expectations are low lol

slate swan
pliant gulch
#

Repl.it is a good on-the-go IDE I agree it isn't good for discord bots though

#

It's not all that bad, people just use it wrong

final iron
royal meteor
slate swan
final iron
slate swan
#

A lot better free sources on GitHub

oblique laurel
pliant gulch
slate swan
final iron
#

Why not use the Oracle free tier?

oblique laurel
cloud dawn
oblique laurel
#

What is the best option for online free bot hosting tho? Ik not replit, but what else?

pliant gulch
#

They usually offer up times of 2 months or so, orcale also just has a flat out free tier apparently

hollow urchin
final iron
oblique laurel
pliant gulch
#

At this point some bots can also be hosted via cloudflare pages completely free. That is if you make your bot REST only, and do everything via slash commands

cloud dawn
royal meteor
pliant gulch
cloud dawn
#

On a webhosting and coding the bot in PHP.

pliant gulch
#

php lmao

hollow urchin
#

i could backcharge if i rly want

final iron
cloud dawn
final iron
#

Something that at least follows pep8

slate swan
#

whats the difference between hosting on replit and hosting on IBM Lite?

cloud dawn
slate swan
#

what about this then

hoary cargo
hollow urchin
cloud dawn
final iron
cloud dawn
slate swan
#

then whys it say you dont need a credit card 💀

cloud dawn
#

Prob to avoid a lot of people that only wants the free stuff.

slate swan
#

oh

pliant gulch
#

Oh you can add attachments to slash commands now

final iron
#

Cool

pliant gulch
#

I will be attempting to add modals to rin 2night

final iron
#

Excited to see the implementation

vocal snow
#

It's going to involve a context manager

pliant gulch
vocal snow
#
with rin.ModalBuilder() as builder:
    with builder.new() as new:
        with new.add_field() as field:
            with field.set_text() as text:
pliant gulch
#

😔

sick birch
#

Do a lil method chaining

pliant gulch
#

I'll make an infix chain

final iron
#

What's that

slate swan
#

Anyone know a way to wait for a message after a command is run?

#

Does ‘message’ have to be the content of th message

left crater
tepid swallow
#

when on_invite_delete is called, the invite.max_age returns None

hollow urchin
#

my discord bot is ran by / commands only i still haven’t received them do I have to leave the bot running to receive them?

slate swan
#

You can just maintain a local cache of these invites as they are created if you need to have that data available later on when the invite is deleted.

jovial plover
#

Is it possible for a bot to join a guild by itself

final iron
#

No

maiden fable
#

BTW did y'all know that our discord IDs are also bots lol

pliant gulch
#

I don't know about you, but my User ID points to my user 😳

maiden fable
#

Lmao

pliant gulch
#

Modals are pretty cool

#

For some reason I can't just press enter and have it submit and instead I have to click the danm button

#

😩

maiden fable
#

😂

pliant gulch
#

Push modals to git 😼 They are quite ugly rn cause I was rushing but I'll prob do a refactor soon

maiden fable
#

another refractor

pliant gulch
#

I don’t even do that many rewrites or refactors

#

Actually, while saying that I had to urge to rewrite gateway to use websockets lib and the entire rest part to use httpx

#

😖

maiden fable
#

Bruh...

pliant gulch
#

It’s worth it I hate aiohttp

#

Expect the rewrite soon 😏

#

I’ll prob break my concurrent ratelimiter in the process though

maiden fable
#

Haha

slim ibex
#

🗿

slate swan
#

Wdym

#

How is a snowflake a bot

jovial plover
#

anyone know why

#

I did not have that in my code 😛

slate swan
#

did you modify channel.guild?

jovial plover
#

no, what do you mean by that?

slate swan
#

can you replicate this error again?

jovial plover
#

Im getting the error..

final iron
#

!d discord.ext.commands.Bot.guilds

unkempt canyonBOT
final iron
#

Don't you mean guilds?

jovial plover
#

That is not in my code.

final iron
#

!tb

#

They removed the tag

#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

final iron
#

@jovial plover

#

Send the full traceback

jovial plover
#
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(args, **kwargs)
  File "C:\Users\Administrator\Downloads\vgp.py", line 2501, in test
    embed.add_field(name="Participants",value='\n'.join([f"<@{m.id}>" for m in ctx.channel.members if m.bot!='True']))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\channel.py", line 157, in members
    return [m for m in self.guild.members if self.permissions_for(m).read_messages]
AttributeError: 'str' object has no attribute 'members'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(ctx.args, **ctx.kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'members'```
hollow urchin
final iron
#

It's saying that ctx.channel is a string object

#

Why are you doing 'True'

#

!d discord.Member.bot

unkempt canyonBOT
#

property bot```
Equivalent to [`User.bot`](https://discordpy.readthedocs.io/en/master/api.html#discord.User.bot "discord.User.bot")
final iron
#

This returns a bool

#

Either True or False

#

Not 'True'

jovial plover
#

Well the code is working on my Mac, but not in Windows 🤔

final iron
#

Same dpy version?

jovial plover
#

how to check

final iron
#

print(discord.__version__)

#

!d discord.version

unkempt canyonBOT
#

discord.__version__```
A string representation of the version. e.g. `'1.0.0rc1'`. This is based off of [**PEP 440**](https://www.python.org/dev/peps/pep-0440).
jovial plover
#

same version

#

1.7.3

final iron
jovial plover
#
################ CLOSE TICKET COMMAND ##################
@bot.command(name="close")

async def test(ctx):
    
        channel = ctx.channel        
        embed = Embed(color=discord.Color.green(),title="Request from {}".format(ctx.author),
                  description=''' Do you want to close <#{}> ?\nPress :white_check_mark: to confirm. '''.format(channel.id))
        delMessage = await ctx.send(embed=embed)
        await delMessage.add_reaction(':white_check_mark:')
        def check(reaction, user):
            return user == ctx.author and str(reaction.emoji) == ':white_check_mark:' and reaction.message.id == delMessage.id
       
        try:
            reaction, user = await bot.wait_for('reaction_add', timeout=600.0, check=check)
            
        except asyncio.TimeoutError:
            await delMessage.delete()
        else:
            deleted_messages = await ctx.channel.purge()
            transcript = await chat_exporter.raw_export(ctx.channel, deleted_messages, 'US/Pacific')
            if transcript is None:
                return
            transcript_file = discord.File(io.BytesIO(transcript.encode()),filename=f"VGP Ticket Transcript-{ctx.channel.name[7:]}.html")
            transcriptLink = await ctx.guild.get_channel(ticketlogID).send(file=transcript_file)
            embed = Embed(color=discord.Color.green(),title=f":ticket: Ticket Closed by {ctx.author}",description=f'''**Ticket:** #{channel.name}\n**Transcript Link:** [Click Here]({transcriptLink.jump_url})''')
            embed.add_field(name="Participants",value='\n'.join([f"<@{m.id}>" for m in ctx.channel.members if m.bot!='True']))
            embed.set_footer(text="Opened at: "+ datetime.now(timezone('US/Pacific')).strftime('%B %d %Y - %H:%M')+' PST')
            await ctx.guild.get_channel(ticketlogID).send(embed=embed)
            

            await channel.delete()```
#

Failing to get "Participants"

#

Works on Mac, but not windows 😩

#

dpy version 1.7.3 on both

#

python version on mac 3.8.8
windows 3.10.1

slate swan
slate swan
jovial plover
#

I will use from now

final iron
#

So why is ctx.channel returning a string object and not a channel object

hushed galleon
#

your code has reassigned the guild attribute of the channel somewhere else

jovial plover
#

oh

hushed galleon
#

maybe in chat_exporter.raw_export or even in another command

jovial plover
#

Works now

#

I overlooked at it

#

it was the first line , channel = ctx.channel

#

dumb

#

Sorry for the trouble, thanks everyone

hushed galleon
#

uh

#

that doesnt reassign the guild attr though

brittle axle
#

not ctx.channel

slate swan
#

!d discord.ext.commands.Context.channel

unkempt canyonBOT
brittle axle
# slate swan No

i have used ctx.guild.channel for locking channels and it worked like a charm

slate swan
#

Are these Context Menus?

#

I dont remember

#

Ikr

hushed galleon
hushed galleon
boreal ravine
small igloo
#
@bot.command()
async def top(ctx):
    users = []
    async with ctx.typing():
        lb = discord.Embed(title="leaderboard", description="top salcash players", color=ctx.author.color)
        l = database.length()
        for i in range (int(l)):
            s = database.get(i)
            user = await bot.fetch_user(s)
            level = database.check_level(s)
            o = user.display_name
            users.append((o, level))
        users.sort(key=lambda a: a[1], reverse=True)
        leaderboard = map(lambda user: user[0] + " level: " + str(user[1]), users)
        g = list(leaderboard)
        ln = len(g)
        # for i in range (ln):
            # lb.add_field(name=i+1, value=g[i], inline=False)
        lb.add_field(name="page 1", value="\n".join(g), inline=False)
        await ctx.send(embed=lb)```

i want the result like
  1. [name] level: [level]
  2. [name] level: [level]
  3. [name] level: [level]
    ....```

any idea how?

jovial plover
jovial plover
fervent shard
#

how do i make it tag the channel the message was sent in?
my current code:py @bot.listen() async def on_message_delete(message): embed=discord.Embed(description=f"content channel: <#{943385924052602880}>\ndeleted message: {message.content}", colour=0x2F3136, timestamp = datetime.utcnow()) embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url) channel=bot.get_channel(943385924052602880) await channel.send(embed=embed)

fervent shard
hardy yoke
#

{} yes

fervent shard
scarlet rune
#

why do bots fail to load gifs in dms? it works with still images though.
just a simple dmmessage.set_image(url=imagelink)

slate swan
scarlet rune
slate swan
scarlet rune
slate swan
scarlet rune
fervent shard
#
@bot.listen()
async def on_message_edited(message):
  embed=discord.Embed(description=f"channel: {message.channel.mention}\nbefore: {message_before.content}\nafter: {message_after.content}", colour=0x2F3136, timestamp = datetime.utcnow())
  embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url)
  channel=bot.get_channel(943385924052602880)
  await channel.send(embed=embed)``` is it `on_message_edited` or `on_message_edit`?
unkempt canyonBOT
#

discord.on_message_edit(before, after)```
Called when a [`Message`](https://discordpy.readthedocs.io/en/master/api.html#discord.Message "discord.Message") receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the [`max_messages`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") parameter or use the [`on_raw_message_edit()`](https://discordpy.readthedocs.io/en/master/api.html#discord.on_raw_message_edit "discord.on_raw_message_edit") event instead.

The following non-exhaustive cases trigger this event...
fervent shard
slate swan
fervent shard
fervent shard
spring flax
#

When a button is clicked, how do I make it edit the message the button is associated with?

slate swan
fervent shard
# slate swan ```py async def on_message_edit(before, after): pass '''The before arg is ...

code:py @bot.listen() async def on_message_edit(message, before, after): pass embed=discord.Embed(description=f"channel: {message.channel.mention}\nbefore: {message_before.content}\nafter: {message_after.content}", colour=0x2F3136, timestamp = datetime.utcnow()) embed.set_author(name=f'{message.author} ({message.author.id})', icon_url=message.author.avatar_url) channel=bot.get_channel(943385924052602880) await channel.send(embed=embed)error:TypeError: on_message_edit() missing 1 required positional argument: 'after'

slate swan
#

Remove it

fervent shard
# slate swan There is no message argument
    embed=discord.Embed(description=f"channel: {message.channel.mention}\nbefore: {message_before.content}\nafter: {message_after.content}", colour=0x2F3136, timestamp = datetime.utcnow())
NameError: name 'message' is not defined```
slate swan
#

message_before will change to before

fervent shard
fervent shard
slate swan
#

Its alright

vast gale
#

wheeees updated my error handler

#

just slapped interactions on top of my existing error handler... what can go wrong sadCryingEyesOpen

fervent shard
# slate swan Its alright

i removed "message" from that code, this is now my code and i have an error :D
code:py @bot.listen() async def on_message_edit(before, after): pass embed=discord.Embed(description=f"channel: {channel.mention}\nbefore: {before.content}\nafter: {after.content}", colour=0x2F3136, timestamp = datetime.utcnow()) embed.set_author(name=f'{author} ({author.id})', icon_url=author.avatar_url) channel=bot.get_channel(943385924052602880) await channel.send(embed=embed)error: File "main.py", line 42, in on_message_edit embed=discord.Embed(description=f"channel: {channel.mention}\nbefore: {before.content}\nafter: {after.content}", colour=0x2F3136, timestamp = datetime.utcnow()) UnboundLocalError: local variable 'channel' referenced before assignment

fervent shard
slate swan
#

after.channel

fervent shard
slate swan
vast gale
fervent shard
# slate swan Yeah try
    embed.set_author(name=f'{author} ({author.id})', icon_url=author.avatar_url)
NameError: name 'author' is not defined```
grim oar
#

define author

fervent shard
fervent shard
slate swan
slate swan
spring flax
#

ashley are you familiar with working with buttons?

vast gale
slate swan
slate swan
fervent shard
# slate swan Wdym

for example it was name=f'{author} ({author.id})', icon_url=author.avatar_url) now will it be name=f'{after.author} ({after.author.id})', icon_url=after.author.avatar_url)

vast gale
spring flax
#

you're suggesting reactions?

fervent shard
slate swan
#

after.author

spring flax
#

disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Confirm' object has no attribute 'value'

class Confirm(disnake.ui.View):
    def __init__(self):
        super().__init__()
        self.vaue = None
#making a button
self.value = True
uneven apex
#

im using pycord
and ctx.respond(embed=embed) is not returning a response
while ctx.send(embed=embed) is sending a response

i think ctx.respond is geting timeout; what is should i do?

uneven apex
#

yep ctx.respond

#

im using pycord

slate swan
uneven apex
#

sends a response to interaction

slate swan
#

Oh you are using interactions i see

uneven apex
#

this is an example of ctx.respond

spring flax
#
class Confirm(disnake.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None
        
    @disnake.ui.button(label="Confirm", style=disnake.ButtonStyle.green)
    async def confirm(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
        await interaction.response.send_message('Thank you for letting the staff team know', ephemeral=True)
        self.value = True
-----

@bot.command()
@commands.cooldown(1, 15, commands.BucketType.member)
async def test(ctx):
    confirming_embed = disnake.Embed(description='something', color=disnake.Color.blurple())
    view= Confirm()
    await ctx.send(embed=confirming_embed, view=view)
    await view.wait()
    if view.value:
        embed=disnake.Embed(description='this is a mod ping')
        await ctx.send(embed=embed)     

Why doesn't this send the this is a mod ping embed?

cedar stream
#

Are you trying to access elements rendered by JavaScript

#

You are web scraping ight?

#

The content you are getting with requests library is unmodified by JavaScript

slate swan
#

Lmao

placid skiff
#

lol

cedar stream
#

That means that if there is any text that is added to the website by JavaScript you wont get it

#

Do yk what I mean 😂

slate swan
#

Cry about it

cedar stream
#

You need to render JavaScript elements

#

A library called requests_html does it

placid skiff
#

i think that bs can't do that, you have to study a bit xD

cedar stream
#

Use that instead of requests, It’ s blocking tho

#

Ok but to get the html that you parse with bs4 you use requests ight?

placid skiff
cedar stream
#

instead of requests use requests_html

#

I think it supports asynchronous calls and you can render JavaScript with it

#

Bro

#

I just told u

#

U try to access some text

#

But there is no text

#

Cus it needs to be rendered by js

placid skiff
#

let's try making a dumb example

cedar stream
placid skiff
#

assume that you have a txt file in your pc

#

and your code read that file

#

as far as the file has the same name is all good

#

but if someone can change the name of that file

#

your code brokes

#

essentially, it is what is happenin' here

#

to workaround this, you have to read the name of the file in your directory and then access to it by doin' this

cedar stream
#

Not rly, It’ s just that you get the dom that is missing certain elements because JavaScript didnt come yet and bring them

#

Mby the page makes an ajax request to get the followers etc.

#

It probably does

placid skiff
#

doesn't tiktok have API's?

#

it should be more simple to access data by API

cedar stream
#

It has but is it public?

placid skiff
#

dunno, i don't even use tiktok lol

cedar stream
#

Mby you can reverse engineer the api

#

Or mby someone alr did

placid skiff
#

i think that someone did it yet xD

#

You just have to search for it

cedar stream
#

@slate swan see if there is an api

#

Lmfao

#

Nice

#

Also use non blocking library to get the page

#

aiohttp instead of requests

slate swan
#

Hi guys

placid skiff
#

should we report this? D_D

slate swan
#

Oh ok sorry

#

D_D

placid skiff
slate swan
#

Yooo

#

What

#

100$

#

Same error btw

#

Just 2 different ide

maiden fable
#

Seems like u don't have the application.commands scope

bitter depot
#

!warn 932220748968382516 Please do not advertise for your youtube channel, as per our #rules

unkempt canyonBOT
#

:incoming_envelope: :ok_hand: applied warning to @slate swan.

slate swan
#

@maiden fable how do you setup application.commands scrope

#

From dev portal?

maiden fable
#

Just add %20application.commands at the end of the invite URL

maiden fable
#

Yea

slate swan
#

Still same error

maiden fable
#

Weird

slate swan
#

See I’m using /commands

#
import os
import discord
from discord.ext import commands
from discord_slash import SlashCommand, SlashContext
from discord_slash.utils.manage_commands import create_option
client = commands.Bot(command_prefix="!", intents=discord.Intents.all())
slash = SlashCommand(client, sync_commands=True)

@slash.slash(name="user", description="Find info about tiktok user", guild_ids=[874272454258851878, 921831664328540181], options=[create_option(name="username", description="The username of the user u wanna check", required=True, option_type=3)])```
#

@maiden fable

maiden fable
#

Never used that lib, sorry

slate swan
#

Ok

vale wing
#

@slate swan

  1. There are way better libraries for implementing slash commands. Examples: disnake, nextcord, pycord
  2. It is not recommended to use requests in async applications, as it might cause blocking. Use aiohttp instead
vale wing
#

Same for other libraries

#

In disnake you have to change nothing, it only adds features afaik

slate swan
#

O

#

I’ll prolly use that

nimble plume
#

Heyo 👋

slate swan
#

Hi

vale wing
#

Hi

quick gust
maiden fable
quick gust
#

shim isn't recommended

#

and most people dont use shim

slate swan
vale wing
#

Just find-replace

quick gust
#

Yes

slate swan
#

Lol

vale wing
#

Yes unless you have situations where discord is in a string or smth

slate swan
quick gust
#

not even your bot invite/support server URLs?

quick gust
#

nice

vale wing
#

Where tf do you store those strings

quick gust
#

makes an http request 💀

#

jk

vale wing
#

Xml values or smth

unkempt canyonBOT
#

Attempt to circumvent filter detected. Moderator team has been alerted.

#

@slate swan Per Rule 6, your invite link has been removed. If you believe this was a mistake, please let staff know!

Our server rules can be found here: https://pythondiscord.com/pages/rules

slate swan
#

Lmaoo

vale wing
#

I find it kinda inconvenient, as I have to go to another file, create the tag, name it and then only return to the main code 💀

bitter depot
#

Let's not circumvent filters lol

vale wing
#

How did it even happen 😳

slate swan
bitter depot
#

Well maybe run code that doesn't have an invite in it next time

slate swan
#

The invite had an uwu route, maybe the bot's against it too 😭

bitter depot
#

It's still an invite 🤷

slate swan
#

Yeah lol

slate swan
#

How do you get message content after command and prefix

#

Like !test lol

#

@bot.command()
async def alex(ctx, *, reason=None):
user = reason.split(':')

async def user(ctx, *, reason=None, username:str):

#

doesnt seem to work

potent spear
slate swan
#

o

potent spear
#

*, takes everything after the previous argument, so obviously, you can't use any extra positional args

#

solution: be smart and use a username FIRST

#

ctx, username: str, *, reason: str=None

slate swan
#

ok

cerulean olive
potent spear
cerulean olive
#

2 sec

slate swan
#

doesnt work

potent spear
slate swan
#

i think im just stupid

#

mb

kindred drum
#

how do I get a channel id easily with ctx?

manic wing
#

yes

manic oyster
manic wing
#

python

manic oyster
#

There is the same error i am using replit

#

It says python not found sussy

potent spear
slate swan
#

why tf im getting a warning lol

maiden fable
#

See the error

#

Required options must be placed before non required once

slate swan
#

im using this formatt from one week now
i even tried removing all the arguments but this keeps giving this error

brittle axle
slate swan
#

am i correct?

nimble plume
maiden fable
#

Embed?

slate swan
maiden fable
#

imagine 👀

slate swan
# manic oyster

since ur most likey forking from github it doesnt work w python only node so copy and paste the github

maiden fable
#

Mind giving the GitHub link? @manic oyster

slate swan
#

am i the only one who favours coding on phone then pc

slate swan
maiden fable
#

I hardly code on my PC nowadays haha

slate swan
slate swan
maiden fable
#

They do

slate swan
maiden fable
#

I also remember someone, idr the name tho

slate swan
slate swan
unkempt canyonBOT
slate swan
maiden fable
#

S. M. H.

nimble plume
slate swan
nimble plume
slate swan
unkempt canyonBOT
maiden fable
#

Smh ot command

nimble plume
#

any mobile apps framework pls

maiden fable
#

Kivy, also off topic

slate swan
nimble plume
#

i want best

slate swan
#

kivy

nimble plume
#

u can say from all

slate swan
#

oh god

nimble plume
#

not only python

maiden fable
#

There is PyQT5 too, but I don't remember if it packages for android

#

!pypi python-for-android

unkempt canyonBOT
maiden fable
#

!pypi pyjnius

unkempt canyonBOT
#

A Python module to access Java classes as Python classes using JNI.

nimble plume
#

i want best android frontend

maiden fable
#

!pypi kivymd

unkempt canyonBOT
maiden fable
slate swan
pliant gulch
#

If you are using andriod you'd probably want to use koltin

maiden fable
manic oyster
slate swan
manic oyster
maiden fable
#

Smh my head

nimble plume
#

ded chat therre

maiden fable
#

Soo?

nimble plume
brittle axle
nimble plume
brittle axle
#

I am

slate swan
#

@manic oyster you should just copy main py

manic oyster
#

The other repl works fine idk why my don't.everything is same

slate swan
#

And all necessary

nimble plume
#

disnake is best

manic oyster
slate swan
slate swan
#

The guy you forked used GitHub fork

slate swan
nimble plume
slate swan
slate swan
slate swan
verbal tiger
#

hi I'm having this how can I fix it?

potent spear
verbal tiger
potent spear
maiden fable
#

this is a Python server...

verbal tiger
potent spear
slate swan
#

.gg/djs

slow fog
slate swan
slow fog
slate swan
slow fog
#

youre sus

slate swan
#

@manic wing cof cof

slate swan
manic wing
#

dicts/

#

its a sin but i cba to switch to sqlite

#

make a pr for me

#

change everything to sqlite 🥺

slate swan
manic wing
slate swan
nimble plume
#

poook

manic wing
#

change all json to sqlite for me and ill give you bot admin 🥺

pliant gulch
#

🤨

manic wing
slate swan
#

xD

manic oyster
nimble plume
#

ok

maiden fable
boreal ravine
#

which one do you guys prefer for making channels py await guild.create_channel(type=cord.ChannelType.text, nmme=...) or just ```py
await guild.create_text_channel(...)

cedar stream
slate swan
maiden fable
cedar stream
maiden fable
slate swan
maiden fable
#

Okay

boreal ravine
#

why not just one method

maiden fable
#

U making a wrapper?

boreal ravine
#

why make multiple methods for multiple channels

boreal ravine
#

just joking, no

maiden fable
#

andy

#

A suggestion

pliant gulch
#

If I were to make a generic builder I would use the above, if I only make text channels I'd use the second one

maiden fable
#

Add a method to return the raw JSON, so that people can store the whole objects in the DB, so that they don't need to fetch them (like in the case of invites)

pliant gulch
#

I already had that lol

maiden fable
#

Oh

pliant gulch
#

All of my objects are serialisable with how they are designed

maiden fable
#

Cool

pliant gulch
#

Static data that is, the other stuff is constructed when that model is constructed

#

Since how the base model works as a factory

maiden fable
#

So people can use SQL DBs and save those directly or they will be needing the JSON?

maiden fable
pliant gulch
#

Yea, they just need to save the data of the model, then call GatewayClient.unserialize(...) which just constructs the model again

#

But on construction other state is given due to this

maiden fable
#

Damn cool

pliant gulch
maiden fable
#

Cool

pliant gulch
#

Oh it isn't deleted, yep I still have it

slate swan
#

@manic wing first of all you have json files for your bot and you even have this wtf

maiden fable
#

Doesn't literally every bot got a file with the name like that lmao

#

Well not every but ¯_(ツ)_/¯

manic wing
nimble plume
slate swan
#

even the command error (inside commands) handling is bad

maiden fable
slate swan
maiden fable
#

Lmao

pliant gulch
#

👁️ 👁️ all the data is on github?

slate swan
pliant gulch
#

That could potentially be breaking some privacy laws, depends on the country

maiden fable
#

Yea

#

JesterBot on his GitHub

slate swan
slim ibex
manic wing
#

ashley

#

sorry for the ping in the help channel;

manic wing
slate swan
pliant gulch
#

Depends on the data you store mostly though

manic wing
#

its all useless

#

if i remove all json ill have to make a schema.sql

#

jsons a bitch but easy as fuck

pliant gulch
#

Harder to navigate lmao

#

Plus schemas are easy to write

manic wing
#

just saying

pliant gulch
#

If you want to go over-kill on the schemas you could also use prisma

manic wing
#

nah

maiden fable
slate swan
maiden fable
#

Uh no thanks

manic wing
maiden fable
#

Uh no

pliant gulch
#

this windows users trying to get some privacy from microsoft

maiden fable
#

Ikrrr

slate swan
manic wing
#

imagine being a window user

slate swan
#

lol

slim ibex
#

I use windows

pliant gulch
manic wing
pliant gulch
#

Arch 😼

manic wing
#

you tell me first so i can choose the rigth answer

#

ok well

pliant gulch
slim ibex
#

RTX 2060

manic wing
#

andy im on fedora

pliant gulch
#

👁️ 👁️

manic wing
#

ive used literally every single linux distro at one point

#

dont quote me on that

pliant gulch
#

Because they literally take so much telemetry on users

#

The danm OS even has a built-in keylogger LMAOO

slim ibex
#

they do though

manic wing
#

bro's gonna get muted

slim ibex
#

but I don’t think the OS itself is bad

sage otter
#

You can literally change how much telemetry they take on you

pliant gulch
slate swan
pliant gulch
slim ibex
pliant gulch
#

You know I'm right

slim ibex
#

nah u ain’t

pliant gulch
#

😔

manic wing
#

windows is just a bit of a pain in the ass and restricting

slim ibex
#

I’m using w11 and I miss some w10 dearures

bitter depot
#

Let's get back on topic please guys

manic wing
#

how tf did tyler not get muted

sage otter
#

Because you know.

#

I caught myself

boreal ravine
#

tiggy always lurking

final iron
#

It's cause we had some shit go down yesterday

#

Chat got silenced 2 times and 7 people were punished

#

4 at the same time

kindred drum
#

how do I make a command have a specific prefix?

slate swan
kindred drum
#

like

#

wait, i can't just do

#

prefix = "+" for a command?

slate swan
final iron
#

Wait

#

!d discord.ext.commands.Context.command

unkempt canyonBOT
final iron
#

You can

#

Nvm

kindred drum
#

please say i can

#

ug

final iron
#

You can't

kindred drum
#

so toxic

final iron
#

get_prefix only takes in bot and message

slim ibex
#

🗿

final iron
#

I forgor and thought it took in context

vocal snow
#

why would that matter 🤔

final iron
#

With Context you have access to the command name

#

Then you can put in a dict so commands can have different prefixes

vocal snow
final iron
#

How?

#

You dont know the length of the prefix

grim oar
#

He forgor 💀

vocal snow
#

how are you supposed to parse commands without knowing the prefix?

pliant gulch
#

You can use StringView from the commands parser

#

You can also just use get_context and ctx.command

final iron
#

I forgot about get_context

boreal ravine
final iron
boreal ravine
#

cord.ChannelType.private in the type kwarg idk

fervent shard
#

how can i make it so that if a member goes offline a role will be given to them?

fervent shard
slate swan
boreal ravine
unkempt canyonBOT
#

discord.on_member_update(before, after)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") updates their profile.

This is called when one or more of the following things change:

• nickname

• roles

• pending...
boreal ravine
#

wait no

slate swan
#

yes it is right

boreal ravine
#

on_presence_update*

boreal ravine
slate swan
boreal ravine
steady berry
#

sry bad channel

slate swan
potent spear
slate swan
potent spear
#

right

maiden fable
#

For a second there, I thought u were referring to Discord API version 2 lmao

surreal ledge
#

Yes

slate swan
boreal ravine
#

your missing the @ at on_message

tall walrus
#

Hello guys, what is the problem ?

#

Hello guys, i have a problem, when i start my bot.py, i have this error :

RuntimeError: Cannot close a running event loop
slim ibex
#

the event loop is already running

tall walrus
#

How can I fix this problem?

slim ibex
#

can you show some code because it seems like the event loop starts, and you try to close it somehow but you can’t

tall walrus
#

Ok

shadow wraith
#

is there an event on when a message is deleted

slim ibex
#

!d asyncio.get_event_loop

unkempt canyonBOT
#

asyncio.get_event_loop()```
Get the current event loop.

If there is no current event loop set in the current OS thread, the OS thread is main, and [`set_event_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.set_event_loop "asyncio.set_event_loop") has not yet been called, asyncio will create a new event loop and set it as the current one.

Because this function has rather complex behavior (especially when custom event loop policies are in use), using the [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop") function is preferred to [`get_event_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop "asyncio.get_event_loop") in coroutines and callbacks.

Consider also using the [`asyncio.run()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.run "asyncio.run") function instead of using lower level functions to manually create and close an event loop.

Deprecated since version 3.10: Deprecation warning is emitted if there is no running event loop. In future Python releases, this function will be an alias of [`get_running_loop()`](https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_running_loop "asyncio.get_running_loop").
slim ibex
#

you could maybe print this out or

#

!d asyncio.get_running_loop

unkempt canyonBOT
#

asyncio.get_running_loop()```
Return the running event loop in the current OS thread.

If there is no running event loop a [`RuntimeError`](https://docs.python.org/3/library/exceptions.html#RuntimeError "RuntimeError") is raised. This function can only be called from a coroutine or a callback.

New in version 3.7.
slim ibex
#

!paste

unkempt canyonBOT
#

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.

languid jungle
#

hello @tall walrus, remove the invite from your code before sending it

tall walrus
#

Okay sorry

slim ibex
#

obi wan kenobi 🗿

tall walrus
#

import discord

#@markdown Créez un bot sur ce site. Une fois ceci fait, rendez vous dans la catégorie bot et créez un bot. Copier son token et coller-le ci dessous.
Token = '' #@param {type:"raw"}
Salon = 0 #@param {type:"number"}
#@markdown Cocher la case ci dessous pour afficher l'ID du serveur et de l'auteur du message.
AffID = False #@param {type:"boolean"}

class MyClient(discord.Client):
async def on_ready(self):
print('Connecté sur ', self.user)

async def on_message(self, message):
    if message.author == self.user:
        return
    else:
        channel = client.get_channel(Salon)
        if AffID == True:
          await channel.send(f"**{message.author}** ({message.author.id}) dans **{message.guild}** ({message.guild.id}) :```\n{message.content}```")
        else:
          await channel.send(f"**{message.author}** dans **{message.guild}** :```\n{message.content}```")

client = discord.Client()
client.run("token")

Discord Developer Portal

Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.

slim ibex
#

!code

unkempt canyonBOT
#

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.

slim ibex
#

pls subclass commands.Bot instead of Client

#

it derives from Client

#

!d discord.ext.commands.Bot

unkempt canyonBOT
#

class discord.ext.commands.Bot(command_prefix, help_command=<default-help-command>, description=None, **options)```
Represents a discord bot.

This class is a subclass of [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") and as a result anything that you can do with a [`discord.Client`](https://discordpy.readthedocs.io/en/master/api.html#discord.Client "discord.Client") you can do with this bot.

This class also subclasses [`GroupMixin`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.GroupMixin "discord.ext.commands.GroupMixin") to provide the functionality to manage commands.
tall walrus
#

okay

pliant gulch
#

This error looks like discord.py was unable to handle SIGINT correctly

#

Thus the loop never stops, but then discord.py tries to close it

tall walrus
#

Maybe it's because I use Colaboratory?

pliant gulch
#

What operating system are you on?