#discord-bots

1 messages Β· Page 789 of 1

visual island
#

commands.Context and commands.CommandError

#

"how", do this ctx: Context. Same with error

#

error type

#

actually error would return CommandError, you can get the original error with the .original attribute

#

ah yea, my bad, that's an attribute of CommandInvokeError which can often raised

#

should work

boreal ravine
#

typehint it to Exception

visual island
#

error (CommandError derived) – The error that was raised.

novel sky
#

One message removed from a suspended account.

green bluff
#

doesnt await ctx.message.delete() delete the authors message

#

doesnt await ctx.message.delete() delete the authors message

polar ice
green bluff
#

delete the message

polar ice
#

Show the code

green bluff
#

that the person sent when he runs the command

#
#suggest command
@client.command()
async def suggest(ctx, *, reason=None):
    role = discord.utils.get(ctx.guild.roles, name='suggest')
    embed = discord.Embed(title='Suggestion not sent.', description='You need to wait till your previous suggestion gets accepted or denied.')
    if reason is None:
        await ctx.reply("Please enter a suggestion.")
    else:
        
        if role in ctx.author.roles:
            await ctx.author.send(embed=embed)
        else:
            embed = discord.Embed(title="",
            description=f"**Suggestion** : {reason}",
            colour=discord.Colour.orange())
            embed.set_author(name=f'{ctx.author}s Suggestion.', icon_url=ctx.author.avatar_url)
            channel = client.get_channel(928950254798258196)
            
            await channel.send(embed=embed)
            embed = discord.Embed(title="**Suggestion sent!**: ",
            description=f"**{reason}** | You will be dmed once a decision is made.",
            colour=0xFFFFFF)
            await ctx.message.delete()
            await ctx.author.send(embed=embed)
            await ctx.author.add_roles(role)```
slate swan
green bluff
#

right

polar ice
#

are you trying to delete the embed?

green bluff
#

ohh

#

and do we add the ()

slate swan
green bluff
polar ice
#

if so do py ctx.author.send(embed=embed, delete_after=5)

slate swan
green bluff
slate swan
green bluff
#

ty tho

wide barn
#

Anyone have a good github project link for a super basic discord bot?
Want to learn by reviewing an existing bots code.

slate swan
polar ice
slate swan
#
@client.command()
async def ban(ctx, member : discord.Member, * ,reason=None):
  await member.ban(reason=reason)
  print(f' {member} was banned')

@client.command()
async def unban(ctx, *, member):
  banned_users = await ctx.guild.bans()
  member_name, member_discriminator = member.split('#')

  for ban_entry in banned_users:
    user = ban_entry.user



    if (user.name, user.discriminator) == (member_name, member_discriminator):
      await ctx.guild.unban(user)
      await ctx.send(f'Unbanned {user.mention}!')```
#

ohhhh i read that wrong

wide barn
#

Essentially yes. I guess youtube's probably the best place to start from scratch

polar ice
green bluff
#

it doesnt work?

slate swan
# slate swan ```py @client.command() async def ban(ctx, member : discord.Member, * ,reason=No...
Ignoring exception in command unban:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 48, in unban
    member_name, member_discriminator = member.split('#')
ValueError: not enough values to unpack (expected 2, got 1)

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/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: ValueError: not enough values to unpack (expected 2, got 1)```
slate swan
polar ice
wide barn
#

Thanks, I'll take a look.

green bluff
#

okimii said ctx.delete.message() and i already tried ctx.message.delete()

#

nvm i didnt save last time

green bluff
#

nvm

#

u didnt oops

#

mb it was poochingto

slate swan
#

lol

final iron
#

Hello chat

slate swan
#

hi

green bluff
slate swan
#

hes my enemy

#

a dogπŸ‘οΈ πŸ‘οΈ

#

cats are better thoyert

steel void
#

how do I check if the time is negative ```py
hours, remainder = divmod(int(war.end_time.seconds_until), 3600)
minutes, seconds = divmod(remainder, 60)

        await CLIENT.get_channel(937229714098110504).edit(name=f'TG-WAR: {hours}h{minutes}m{seconds}s')
#

because if the time is negative I want to change the channel name to something else

velvet tinsel
tiny ibex
#

So there is a mp4 file in my bot folder and I want my bot to send it to me on discord is it possible using jsk?

boreal ravine
#

wait

#

send?

#

why do you want your bot to send instead of play it

slate swan
tiny ibex
boreal ravine
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**.
tiny ibex
boreal ravine
tiny ibex
#

Ik how to send something

tiny ibex
boreal ravine
#

!jsk py

file = discord.File(fp, filename)
await ctx.send(file=file)
#

not that hard

tiny ibex
#

No direct method?

boreal ravine
tiny ibex
#

Oof

boreal ravine
#

you always have to use discord.File to send files local or non-local

#

could be another way but idk

tiny ibex
#

Oof

tiny ibex
# boreal ravine could be another way but idk
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.9/site-packages/jishaku/features/python.py", line 149, in jsk_python
    async for send, result in AsyncSender(executor):
  File "/app/.heroku/python/lib/python3.9/site-packages/jishaku/functools.py", line 109, in _internal
    value = await base.asend(self.send_value)
  File "/app/.heroku/python/lib/python3.9/site-packages/jishaku/repl/compilation.py", line 140, in traverse
    async for send, result in AsyncSender(func(*self.args)):
  File "/app/.heroku/python/lib/python3.9/site-packages/jishaku/functools.py", line 109, in _internal
    value = await base.asend(self.send_value)
  File "<repl>", line 1, in _repl_coroutine
    file = disnake.File(fp, "videooftheday/images/video-bg.jpg")
NameError: name 'fp' is not definedβ€Š
#

Β―\_(ツ)_/Β―

tender estuary
#

fp is an identifier here?

#

what it is saying is there is nothing with an 'fp' identifier

velvet tinsel
#

morning

slate swan
#

morning

maiden fable
#

You know

unkempt canyonBOT
warm forum
#

Can anyone help me in dm with my discord bot. I am trying to add a feature to it but unable to do it. Your help would be appreciated.

fresh orchid
#

I have this code

def __init__(self, client):
        self.client = client
             
        schedule.every().day.at("09:35").do(self.lrs_stats)

But when I run it I get this error

RuntimeWarning: coroutine 'levelroles.lrs_stats' was never awaited

But I dont get where I have to await this

slate swan
#

you need to await self.lrs_stats

#

but you won't be able to do it since it's a normal function

fresh orchid
#

is there any other solution to dot it?

#

when I do it like that

def __init__(self, client):
        self.client = client
             
    schedule.every().day.at("09:35").do(self.lrs_stats)  ```
self is not defined
slate swan
fresh orchid
#

how to?

Everything I try ends in an error

maiden fable
#

Totally not spoonfeeding

fresh orchid
warm forum
#

can I call this in another async method? ---- "async def on_member_update(before,after):"

quasi stag
maiden fable
#

Idk, it's yr code.

#

Hmm idrk...

fresh orchid
#

ok but thanks for the help

warm forum
maiden fable
quasi stag
maiden fable
#

Wait no

#

Better is to use bot.dispatch()

#

Not documented

warm forum
quasi stag
#

you guys should go to discord.py's official discord server

#

it has better help there

maiden fable
quasi stag
maiden fable
maiden fable
quasi stag
#

im just saying theres better support there

visual island
maiden fable
maiden fable
#

Just because it's the official support server doesn't mean it got better helpers all the time pithink

quasi stag
#

well not ALL the time

maiden fable
#

And then there's toxicity too. You can't ignore that Β―_(ツ)_/Β―

fresh orchid
#

Is it possible to use

schedule.every().day.at("09:35").do(self.lrs_stats)

In my main code but leave lrs_stats in the cog
So the thing from the main code activates the function in cog

The problem is when I try it lrs_stats is not defined

quasi stag
#

you dont say theres no toxicity too here

maiden fable
green bluff
#

first two lines of the function should not be in the function at all

#

and yea ik u meant it as a joke

#

but if its an actual user pls help him

#

good

#

yeh

#

im also kinda new

#

but hey everyone has to start somewher

#

also off topic but i like playing hypixel aswell

#

nope nothing

#

bridge main

#

im a bridge master

#

r u iron prestige orrr

#

oh cool

#

ahh i c

slate swan
#
    @commands.command()
    async def verifynow(self, member : discord.Member=None):
        print("--------------------- Working on it.")
        role = "Verified"
        guild = self.get_guild(756504534897000528)
        for member in guild.members:
            if role in member.roles:
                print(f"{member} AVAILABLE")
                pass
            else:
                print(f"{member} NONE")
#

Why this isn't working?

#

stay to topic please!

green bluff
#

sorry

#

also i recommend using a different variable name

#

instead of commands use client or bot

#

oh

tidal hawk
#

Does discord bot rate limiter reset after restarting the bot? Asking that because, returning guild.invites() stopped working after running for 30 minutes, but after restart it worked flawlessly for about 30 minutes.

slate swan
#

I am

#

I know it wasnt working πŸ€¦β€β™‚οΈ

green bluff
slate swan
#

I was using the same class

#

and the class already exists

#

And I changed it to another class

#

And now it's still not working πŸ€¦β€β™‚οΈ

#
    @commands.command()
    async def verifynow(self, member : discord.Member=None):
        print("--------------------- Working on it.")
        guild = self.get_guild(756504534897000528)
        for member in guild.members:
            print(member)
tidal hawk
#

Does discord bot rate limiter reset after restarting the bot? Asking that because, returning guild.invites() stopped working after running for 30 minutes, but after restart it worked flawlessly for about 30 minutes.

slate swan
#

It works for my other cogs

slate swan
tidal hawk
slate swan
slate swan
slate swan
#

doesnt change it.

tidal hawk
#

context is still needed

#

even in cogs

slate swan
#

what?

slate swan
#
    @commands.command()
    async def verifynow(ctx, self, member : discord.Member=None):
        print("--------------------- Working on it.")
        guild = self.get_guild(756504534897000528)
        for member in guild.members:
            print(member)
#

omfg

tidal hawk
#

ctx goes infront self

slate swan
#

OH NO!!!

tidal hawk
#

self is always first param

slate swan
#
member : discord.Member=None
#

omfg im so dumbbbbbbbbbbbbbbbbbb

#

Why nobody see that

#

bruh im so dumb πŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈπŸ€¦β€β™‚οΈ

tidal hawk
#

and now it works?

slate swan
#

it wont.

tidal hawk
#

ctx is usually required

slate swan
#
  @command()
  async def _command(self , ctx : Context):
     ...
``` is the basic syntax for a command in cog
#
    @commands.command()
    async def verifynow(self, member : discord.Member):
        print("--------------------- Working on it.")
        guild = self.get_guild(756504534897000528)
        for member in guild.members:
            print(member)
#

it still doesnt work

#

I will be back in 10 mins...

tidal hawk
#

Because you do not have ctx inside bruh

slate swan
#
    @commands.command()
    async def verifynow(self, member : discord.Member=None):
        print("--------------------- Working on it.")
        for member in self.guild.members:
            print(member)

this?

tidal hawk
#
@commands.command()
async def verifynow(self, ctx, member : discord.Member):
    print("--------------------- Working on it.")
    guild = self.get_guild(756504534897000528)
    for member in guild.members:
        print(member)```
slate swan
#

no, that doesnt matter.

#

it doesn't even print the working on it now

#

i gtg eat brb in 10 mins ❀️

#

do you have member intents?

tidal hawk
#

None part doesn't matter

green bluff
#

none means if the member arg isnt given it just resorts to the member being none (I think)

tidal hawk
#

it's not connected with guild.members

slate swan
#

guild.members would just be an empty list [] if you dont have member intents

tidal hawk
#

guild.members just returns list which your starting to iterate

slate swan
#

ctx.guild returns the current guild , not the guild with the id they provided

green bluff
#

I should really start using cogs

#

my bot is very very messy

slate swan
#

guild = self.get_guild(756504534897000528)

#

they are trying to get it with an id

#

idk if its the id of same server or other

green bluff
slate swan
green bluff
#

damn

velvet tinsel
#

I got ghost pinged?

slate swan
#

yo

#

not working :'(

slate swan
#

oh, didnt know

unkempt silo
#

cant read msgs from threads in current v. of discord.py 😦 anything ?

slate swan
unkempt silo
#

buttons not gonna work

#

its says interaction failed

slate swan
#

the master branch already has buttons.

#

it just works differently

unkempt silo
#

if i upgraded

#

the button codes

slate swan
#

ofcourse, thats why 3rd party libs are not recommended

unkempt silo
slate swan
#

and they will stop working with time

unkempt silo
#

lmao i cant grumpchib

#

imagine rewriting

slate swan
#

im rewriting my bot for the 4th time :)

unkempt silo
#

n i dnt know where else gonna mess

#

omg same here

#

is only affect for buttons or

slate swan
slate swan
#

yep, and you can always ask about the problems you face here

unkempt silo
#

thanks for ur help, ill try thn n hve to check from first

slate swan
#

Β―_(ツ)_/Β―

unkempt silo
#

ツ

slate swan
#

Why doesnt this add the image to the embed?

embed.set_image(url=f"attachment://./cogs/qr/qrcode{str(inter.author.id)}.png")
slate swan
#

no need to specify the full path

slate swan
visual island
#

attachment:// doesn't support absolute path

slate swan
#

nice

slate swan
#

leaves

#

f"attachment://{str(inter.author.id)}.png" this doesnt work? you need to send it as discord.File too

#

oh wao

#

I forgot to do that

#

!local-image ez

#

rip

visual island
#

!local-image

#

!tags

unkempt canyonBOT
#
Available tags

Β» functions-are-objects
Β» global
Β» guilds
Β» identity
Β» if-name-main
Β» indent
Β» inline
Β» intents
Β» iterate-dict
Β» kindling-projects
Β» listcomps
Β» local-file
Β» microsoft-build-tools
Β» modmail
Β» mutability

velvet tinsel
visual island
#

!local-file

unkempt canyonBOT
#

Thanks to discord.py, sending local files as embed images is simple. You have to create an instance of discord.File class:

# When you know the file exact path, you can pass it.
file = discord.File("/this/is/path/to/my/file.png", filename="file.png")

# When you have the file-like object, then you can pass this instead path.
with open("/this/is/path/to/my/file.png", "rb") as f:
    file = discord.File(f)

When using the file-like object, you have to open it in rb mode. Also, in this case, passing filename to it is not necessary.
Please note that filename can't contain underscores. This is a Discord limitation.

discord.Embed instances have a set_image method which can be used to set an attachment as an image:

embed = discord.Embed()
# Set other fields
embed.set_image(url="attachment://file.png")  # Filename here must be exactly same as attachment filename.

After this, you can send an embed with an attachment to Discord:

await channel.send(file=file, embed=embed)

This example uses discord.TextChannel for sending, but any instance of discord.abc.Messageable can be used for sending.

slate swan
#

ah

visual island
#

yeah that..

boreal ravine
#

whats nice about it

velvet tinsel
boreal ravine
#

yeah

slate swan
#

"bolb" spoils the fun

boreal ravine
#

nextcord meme

velvet tinsel
#

Remove bolb

boreal ravine
#

send pr

velvet tinsel
#

just put the hhhhhhh

velvet tinsel
boreal ravine
#

wut

velvet tinsel
#

what is your GitHub

#

sifte

boreal ravine
cedar stream
#

@boreal ravine u should make ur website go forever

boreal ravine
#

i did

#

but gitub doesn't allow files bigger than 25mb

cedar stream
#

Oh

#

Damm

green bluff
#

doesnt allow files bigger than 25mb?

boreal ravine
#

a dungeon*

green bluff
#

oh kk

visual island
boreal ravine
slate swan
boreal ravine
#

why do you save the image

slate swan
boreal ravine
#

well

#

idk

#

are you using an api? or did you just make that image somewhere

slate swan
#

umm....okay

#

the file after being uploaded on discord has nothing to do with its path

#

oh 1 sec

#

hm

velvet tinsel
boreal ravine
#

πŸ™‚

oblique adder
#

Is there a ratelimit on how many time a discord bot can publish an announcement per second ?

nimble plume
velvet tinsel
boreal ravine
#

πŸ˜„

velvet tinsel
#

😐

cursive spindle
#

like
!command_name @winged charm1 @winged charm2 @winged charm3 ?

boreal ravine
#

no

#

if you wanna do that

slate swan
#

!d discord.ext.commands.Greedy

unkempt canyonBOT
#

class discord.ext.commands.Greedy```
A special converter that greedily consumes arguments until it can’t. As a consequence of this behaviour, most input errors are silently discarded, since it is used as an indicator of when to stop parsing.

When a parser error is met the greedy converter stops converting, undoes the internal string parsing routine, and continues parsing regularly.

For example, in the following code:

```py
@commands.command()
async def test(ctx, numbers: Greedy[int], reason: str):
    await ctx.send("numbers: {}, reason: {}".format(numbers, reason))
```  An invocation of `[p]test 1 2 3 4 5 6 hello` would pass `numbers` with `[1, 2, 3, 4, 5, 6]` and `reason` with `hello`...
boreal ravine
#

use commands.Greedy or *

cursive spindle
#

thanks

boreal ravine
#

both do the same thing

maiden fable
boreal ravine
#

yes?

maiden fable
# boreal ravine yes?

commands.Greedy consumes only one type of args, but * can consume args of any type

boreal ravine
#

*member: discord.Member why wouldn't this work exactly

maiden fable
boreal ravine
#

yes

#

that is what they want?

maiden fable
#

But commands.Greedy[int] will only consume that 123

boreal ravine
#

o

velvet tinsel
#

How greedy

boreal ravine
#

not funny

velvet tinsel
#

I’m sorry

shrewd bronze
maiden fable
shrewd bronze
#

ok

violet nymph
slate swan
shrewd bronze
#

I cant run it 24/7

violet nymph
#

raspberry pi

slate swan
nimble plume
#

im making music bot i want library

slate swan
#

As Mr. Hunter said

slate swan
unkempt canyonBOT
#

Per Python Discord's Rule 5, we are unable to assist with questions related to youtube-dl, pytube, or other YouTube video downloaders, as their usage violates YouTube's Terms of Service.

For reference, this usage is covered by the following clauses in YouTube's TOS, as of 2021-03-17:

The following restrictions apply to your use of the Service. You are not allowed to:

1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as specifically permitted by the Service;  (b) with prior written permission from YouTube and, if applicable, the respective rights holders; or (c) as permitted by applicable law;

3. access the Service using any automated means (such as robots, botnets or scrapers) except: (a) in the case of public search engines, in accordance with YouTube’s robots.txt file; (b) with YouTube’s prior written permission; or (c) as permitted by applicable law;

9. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service)
slate swan
#

it will break youtube's TOS

nimble plume
slate swan
nimble plume
#

any other

#

any that can be available

slate swan
nimble plume
#

i want i library

slate swan
boreal ravine
#

Well you can stil make your own without assistance

nimble plume
boreal ravine
#

but it's still against ToS ⁉️

nimble plume
slate swan
#

kinda

nimble plume
#

..

boreal ravine
nimble plume
#

what if we create our own list of songs..

#

music/music.mp3

slate swan
slate swan
#

waste of resources

nimble plume
#

collecting more than 10000 music

nimble plume
#

😦

slate swan
nimble plume
#

ya but

slate swan
#

lmfao

nimble plume
slate swan
nimble plume
#

and also

#

mostly ppl who listen music in dc they already know the music..

nimble plume
#

or listened it

nimble plume
slate swan
#

just make a command .play which says "go to Spotify"

nimble plume
slate swan
nimble plume
#

suggest a command

slate swan
#

opens spotify
opens discord to search for the song's link by the name of the song

#

cool command

nimble plume
#

cool..

unkempt canyonBOT
#

Hey @silk lynx!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

nimble plume
#

umm

slate swan
nimble plume
#

ya

#

dictionary

#

good idea

slate swan
#

mhm

nimble plume
#

@slate swan is there any translator smh avaialbe

#

available*

slate swan
nimble plume
#

direct link..

#

!translate english bruh

slate swan
#

!pypi google-cloud-translate

unkempt canyonBOT
slate swan
#

official library

nimble plume
#

alr

slate swan
#

and keep this channel on topic now

nimble plume
#

..

#

discord bots are fun

#

Β―_(ツ)_/Β―

slate swan
nimble plume
desert cosmos
#

is there a way i can change the cog while bot running ?

desert cosmos
#

so that i don't have to run bot again and again

slate swan
nimble plume
#

old style

desert cosmos
oblique adder
#

Is there a ratelimit on how many time a discord bot can publish an announcement per second ?

slate swan
nimble plume
#

@slate swan i have a problem in getting user roles

slate swan
#

Or just use jishaku

#

!PyPi jishaku

unkempt canyonBOT
slate swan
#

You can do .jishaku reload cog

#

it will reload the cog

nimble plume
#

hikari..

slate swan
nimble plume
#

huh Β―_(ツ)_/Β―

nimble plume
nimble plume
#

Β―_(ツ)_/Β―

slate swan
nimble plume
#

i use member.roles

slate swan
#

it returns a list

#

and its not ugly

nimble plume
#

no

slate swan
#

show your code

#

!paste if it's "ugly"

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.

nimble plume
#

ctx.author.roles

#

Β―_(ツ)_/Β―

slate swan
#

was the command used in dms?

nimble plume
#

no

slate swan
#

How do I check if a member has a certain role?

slate swan
slate swan
#

!d discord.Guild.get_role

unkempt canyonBOT
nimble plume
#
[<Role id=852911589061558332 name='@everyone'>]
honest shoal
slate swan
slate swan
nimble plume
#

yes

desert cosmos
void mist
#

How do i change my bots activity (Playing)

nimble plume
#

if there is not role

slate swan
#
@tasks.loop(seconds=60)
async def verifynow():
    guild = client.get_guild(756504534897000528)
    roled = guild.get_role(936340927713259621)
    for member in guild.members:
        if roled in member.roles:
            pass
        else:
            print(member)
slate swan
unkempt canyonBOT
#

await change_presence(*, activity=None, status=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Changes the client’s presence.

Example

```py
game = discord.Game("with the API")
await client.change_presence(status=discord.Status.idle, activity=game)
```   Changed in version 2.0: Removed the `afk` keyword-only parameter.
slate swan
#

will this work?!

slate swan
void mist
#

i'll try

slate swan
#

lol

desert cosmos
slate swan
slate swan
#

it worked guys, Ty <3

slate swan
#

Ash, I read it

slate swan
desert cosmos
#

is hikari better than pycord 2.00?

slate swan
#

hikari is not a fork. And yes it's better maintained and is faster

#

If you want to use a fork, go for Disnake or nextcord

slate swan
desert cosmos
#

why does it matter if it's forked :/

slate swan
#

If you use forks, you don't need to rewrite your bot
If you use hikari, welcome to the rewrite gang

desert cosmos
slate swan
#

Hikari is harder

#

!pypi disnake

desert cosmos
#

i never changed my code

#

so far atleast

slate swan
#

ahrixjam Mhm so you may like to try hikari, for the command handler you might prefer hikari-lightbulb

#

!pip hikari

unkempt canyonBOT
slate swan
#

!pip hikari-lightbulb

unkempt canyonBOT
desert cosmos
#

does it have UI support ?

slate swan
slate swan
#

if you mean components

#

and slashes

heavy scroll
#

i wanna ask this can you make a discord bot implementing two different languages ?
using a tool or smth . eg python + javascript

slate swan
#

that too

desert cosmos
#

buttons and views stuff i mean

unkempt canyonBOT
#

kakashi/plugins/botmiscs.py lines 29 to 36


@botmisc.command
@add_cooldown(10, 2, bucket=UserBucket)
@command(name="ping", description="Sends bot's latency", aliases=["latency"])
@implements(PrefixCommand, SlashCommand)
async def ping(ctx: Context):
    """Bot's Latency"""
    await ctx.respond(f"πŸ“ Pong `​{round(ctx.bot.heartbeat_latency *1000 , 2)}`​ ms !")```
slate swan
#

Easier and better

heavy scroll
#

but how do we do it

slate swan
#

But why do you want to use 2 langauges

desert cosmos
heavy scroll
#

ah ok

slate swan
heavy scroll
#

but i cant find it anywhere

slate swan
#

Prefer using one language

#

That would be too messy tbh, your choice anyways

heavy scroll
#

yes true

heavy scroll
slate swan
#

It will not allow you to use many features like the command handler ,dynamic HelpCommand and more

slate swan
#

How do I make a command to send custom messages (e.g: ?msg @amber beaconrrrr Hello) [sorry for the mention it was accident]

slate swan
slate swan
#

And how do I tell the bot that my message is Hello?

slate swan
unkempt canyonBOT
#

class discord.Member```
Represents a Discord member to a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

This implements a lot of the functionality of [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User").

x == y Checks if two members are equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

x != y Checks if two members are not equal. Note that this works with [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") instances too.

hash(x) Returns the member’s hash.

str(x) Returns the member’s name with the discriminator.
slate swan
#

Hello

#

hi

#

@bot.command()
async def vouches(ctx, arg):
tag = arg

Tag = arg has indent block anyone know why

#

Eh?

#

!indent

unkempt canyonBOT
#

Indentation

Indentation is leading whitespace (spaces and tabs) at the beginning of a line of code. In the case of Python, they are used to determine the grouping of statements.

Spaces should be preferred over tabs. To be clear, this is in reference to the character itself, not the keys on a keyboard. Your editor/IDE should be configured to insert spaces when the TAB key is pressed. The amount of spaces should be a multiple of 4, except optionally in the case of continuation lines.

Example

def foo():
    bar = 'baz'  # indented one level
    if bar == 'baz':
        print('ham')  # indented two levels
    return bar  # indented one level

The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the if statement, and will only run if the if statement evaluates to True. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the if statement above as no more lines can be inside the if statement below that line.

Indentation is used after:
1. Compound statements (eg. if, while, for, try, with, def, class, and their counterparts)
2. Continuation lines

More Info
1. Indentation style guide
2. Tabs or Spaces?
3. Official docs on indentation

slate swan
#

and most importantly, learn python

#

I have decent grasp it’s just I can’t find reason for error

#

"decent"

#

Yes

cold sonnet
slim ibex
#

πŸ—Ώ

slate swan
cold sonnet
#

hi

slate swan
cold sonnet
#

is there a button type to pick dates

#

like january 1st

#

or any kind of number picker button

slate swan
#

You could use the built in version

#

I can’t think of name

cold sonnet
#

oh, I see, select menus

slate swan
cold sonnet
#

yeah prolly

slate swan
#

orait

cold sonnet
#

do I have to add every number to the menu like this

        options = [
            disnake.SelectOption(
                label="Red", description="Your favourite colour is red", emoji="πŸŸ₯"
            ),
            disnake.SelectOption(
                label="Green", description="Your favourite colour is green", emoji="🟩"
            ),
            disnake.SelectOption(
                label="Blue", description="Your favourite colour is blue", emoji="🟦"
            ),
        ]
slate swan
#

if thats okay with you

cold sonnet
#

genius

slate swan
#

xD

cold sonnet
#

and it's gonna add the second button once the person chose a month

#

cuz like

cold sonnet
#

different months different amount of days

slate swan
#

yeah

cold sonnet
#

nice

slate swan
#
@client.command()
async def msg(ctx, member, message):
    await member.send(message)

Why this isn't working?

cold sonnet
#

make sure to add a * in the parameters

#

and provide more information the next time you bring an issue

slate swan
#

I want to send custom messages to members as the bot

cold sonnet
#

what isn't working?

slate swan
cold sonnet
#

is there an error?

slate swan
#

nope

#
@client.command()
async def msg(ctx, member, *, message):
    await member.send(message)

Current code

cold sonnet
#

does the command run?

slim ibex
#

print something to see if the command even works

slate swan
#

ok lets see

#

it's not working πŸ€¦β€β™‚οΈ

slim ibex
#

so nothing printed then (if you did put a print)

slate swan
#
@client.command()
async def msg(ctx, member, *, message):
    print("It's working")
    await member.send(message)

#

It didn't print, Yes

slim ibex
#

are you trying to send in dms

slate swan
#

yes

slim ibex
#

open a dm channel lol

slate swan
#

no...

slate swan
#

^

#

the send method on the member/user object creates the dm for you

slim ibex
#

ah k

slate swan
#

So can someone help plz :'(

slate swan
slim ibex
#

the command doesn't even work in the first place

#

it won't print or send a message to the member

slate swan
#

it does now

#

But it doesn't send the message

slate swan
slate swan
#

you know what a typehint is?

boreal ravine
#

typehint

slate swan
#

@client.command()
@commands.check(is_it_me)
async def msg(ctx, member : discord.Member, *, message):
    print("It's working")
    await member.send(message)
boreal ravine
#

yes

slate swan
#

like this?

#

Yep

boreal ravine
slate swan
#

It's working... :)

slim ibex
slate swan
#

they don't know what typehint is so I don't think Lambda would be a good suggestion got them

boreal ravine
#

lmao

slate swan
#

:'(

#

that hurt

#

Didn't meant to be rude,

#

:'(

boreal ravine
slate swan
#

But lambda is confusing at times

slate swan
boreal ravine
#

lambda is not confusing for me

slate swan
#

Cause you're a genius, unlike me

boreal ravine
slate swan
slim ibex
#

πŸ—Ώ

slate swan
#

I wish

maiden fable
slate swan
slate swan
#

It's still shit

maiden fable
slate swan
#

Yea

void mist
#

How do I make my bot send an embed?
I already have the embed ready:

embed=discord.Embed(title="Commands", url="https://replit.com/@Albi2/Utilities", description="this shows all the Utilities bot commands!")
embed.set_author(name="Utilities")
embed.add_field(name="Best", value="u!bot", inline=False)
embed.set_footer(text="u!help, u!mute")
await ctx.send(embed=embed)
#

but it doesn't seem to work

slim ibex
#

send the whole command it is in

void mist
#

okay

#
   if message.content.startswith('u!help'):
        await message.channel.send('There are not much commands, but you can do these ones:')
        embed=discord.Embed(title="Commands", url="https://replit.com/@Albi2/Utilities", description="this shows all the Utilities bot commands!")
        embed.set_author(name="Utilities")
        embed.add_field(name="Best", value="u!bot", inline=False)
        embed.set_footer(text="u!help, u!mute")
        await ctx.send(embed=embed)
#

at py @client.event async def on_message(message):

slim ibex
#

replace ctx.send to message.channel.send

void mist
#

okay thanks

slim ibex
#

and fyi

#

make actual commands, don't do everything in an on_message listener

void mist
#

ok

#

thanks for the help

slim ibex
#

np

honest shoal
#

I use disnake and only have application commands in my bot. How do I convert it to Interaction only bot instead of bot user?

steel void
#

how do I check if the time is negative ```py
hours, remainder = divmod(int(war.end_time.seconds_until), 3600)
minutes, seconds = divmod(remainder, 60)

        await CLIENT.get_channel(937229714098110504).edit(name=f'TG-WAR: {hours}h{minutes}m{seconds}s')
#

Because if the time is negative I want to do something else

oblique cobalt
steel void
#

ooooooooh thanks I will try it

boreal ravine
#

pro bot developer recommends forks/libs

#

😳

oblique cobalt
#

you did ```
whatever you do with Pag

```py
Pag = ...
void mist
#

How do I change bot status (idle, online, do not disturb)?

cold sonnet
#

!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.
cold sonnet
#

has a status kwarg

void mist
#

okay i'll try

wanton cipher
#

could someone help me, how do I make a select menu that waits for an option to be selected?

wanton cipher
#

disnake

steel void
#

Hey guys I got an issue using py-cord

#
@CLIENT.event
async def on_member_join(ctx, member): 
    try:
        connection = sqlite3.connect('clan_link.db')
        cursor = connection.cursor()

        try:
            cursor.execute(
                f"SELECT clan_welcome_message FROM '{ctx.guild.id}' WHERE clan_welcome_message IS NOT NULL")

            msg = str(cursor.fetchall()[0][0]).encode(
                'utf-8').decode('unicode_escape')

            cursor.execute(
                f"SELECT clan_welcome_channel FROM '{ctx.guild.id}' WHERE clan_welcome_message IS NOT NULL")

            channel = cursor.fetchall()[0][0]

        except Exception:
            channel = CLIENT.get_channel(936133472311971861)
            await channel.send(str(traceback.format_exc()))

        template_base = Image.open("transparent.png").convert('RGBA')
        template = Image.open("template.png").convert('RGBA')
        asset = member.avatar_url_as(size=128)
        data = BytesIO(await asset.read())
        avatar = Image.open(data).convert('RGBA')

        avatar = avatar.resize((256, 256))

        template_base.paste(avatar, (425, 60), mask=avatar)
        template_base.paste(template, (0, 0), mask=template)

        template_base.save("welcome.png")

        await CLIENT.get_channel(channel).send("".join(msg.encode('utf-8').decode('unicode_escape')).format(mention=ctx.author.mention, server=ctx.guild.name), file=discord.File('welcome.png'))

    except Exception:
        channel = CLIENT.get_channel(936133472311971861)
        await channel.send(str(traceback.format_exc()))

    finally:
        connection.close()```
#

i get this error TypeError: on_member_join() missing 1 required positional argument: 'member'

oblique cobalt
#

ur missing definition of "Pag" still

spring flax
oblique cobalt
#

also pro tip: dont try to copy codes, try to write on ur own first

wanton cipher
steel void
#

aanyone got any idea about my issue im lost ngl

spring flax
steel void
#

no

wanton cipher
honest shoal
#

How do I switch to InteractionBot from a bot user, I use disnake

low marlin
#

is disnake the recommended fork rn?

spring flax
quaint epoch
spring flax
honest shoal
low marlin
#

thx^^

cold sonnet
#

so what could be the reason for an interaction failed error on discord?

#

what raises it

wanton cipher
#

I just am not sure what to make the callback or how to get the value

cold sonnet
#

I send a dropdown menu with a command, the callback of that menu should remove itself from the view, set another view's options and add it to the view, then edit the message, tho all I get is "this interaction failed"

wanton cipher
cold sonnet
#

k but I do

wanton cipher
#

then I am not too sure, kinda in the same boat as you rn xD

honest shoal
cold sonnet
#

I read somewhere that I should use ctx.defer(), but that's not available in a dropdown menu, so I replaced it with await interaction.response.defer()

#

not sure if it's the same

wanton cipher
#

is it the first line of the callback?

cold sonnet
#

yes

wanton cipher
#

then I have no idea, sorry

void mist
#

How do I make my bot so it doesn't execute commands if on channels other than bot commands?

wanton cipher
cold sonnet
#

it fails somewhere here

        async def callback(self, interaction: disnake.MessageInteraction):
            await interaction.response.defer()
            if self.values[0] == "January" or self.values[0] == "March" or self.values[0] == "May" or self.values[0] == "July" or self.values[0] == "August" or self.values[0] == "October" or self.values[0] == "December":
                days = 31
            elif self.values[0] == "April" or self.values[0] == "June" or self.values[0] == "September" or self.values[0] == "November":
                days = 30
            else: 
                days = 28
            Day.options = [
                SelectOption(
                    label=str(day)
                ) for day in range(days)
            ]
            View.add_item(Day(self.values[0]))
            View.remove_item(Month())
            interaction.edit_original_message("Your birthday is...", view=View())
#

wait

#

could an in-code error not raise an error but respond with this interaction failed?

wanton cipher
#

maybe, but not sure

cold sonnet
#

no, it's not because of the await at the end

wanton cipher
#

I am sure that it would raise an error though

cold sonnet
#

great

slate swan
#

and do you have a error handler?

cold sonnet
#

no

wanton cipher
cold sonnet
#

new bot, new start

slate swan
#

since its a coro

void mist
slate swan
wanton cipher
boreal ravine
cold sonnet
#

it didn't print a single number

#

it doesn't even call the callback function

#

MY CALLBACK IS IN INIT

#
    View.add_item(Day(self.values[0]))
TypeError: add_item() missing 1 required positional argument: 'item'
#

makes total sense facepalm

rocky trench
#

Anyone knows how to change bot's voice volume in just 1 guild?

low marlin
#

which option should i choose and why?

    def __init__(self, bot):
        self.bot: commands.Bot = bot

or

    def __init__(self, bot: commands.Bot):
        self.bot = bot
slate swan
low marlin
#

oh kk, thx

boreal ravine
slate swan
#

its just a typehint

slate swan
#

it doesnt affect run time

slate swan
#

lol

cold sonnet
#
disnake.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.options: Must be between 1 and 25 in length.
#

so like I can't make 31 days because of this

#

in a menu

slate swan
#

wdym

cold sonnet
#

so if I change this number in the source code, am I gonna get arrested?

#

πŸ‘€

slate swan
#

yes

cold sonnet
pulsar shell
slate swan
cold sonnet
#

I'm gonna do it anyways

slate swan
#

imagine changin src just to make your bot work lol

cold sonnet
#

hecker

slate swan
#

very

desert cosmos
slate swan
#

ikr

desert cosmos
#

your name too good

#

don't say, i know you know right

slate swan
#
    @commands.command()
    @commands.has_permissions(manage_channels=True)
    async def unlock(self,ctx):
      if ctx.author.guild_permissions.manage_channels == True:
          embed = discord.Embed(description = f'***:dinosuccess:   {ctx.channel.mention} is unlocked***')
          await ctx.channel.set_permissions(ctx.guild.default_role, send_messages=True)
          await ctx.send(embed=embed)
      else:
        await ctx.send(ctx.message.author.mention + ", you don't have permission")```
slate swan
desert cosmos
slate swan
#

my cat is watching you

#

Okimii you don't have a cat

slate swan
# slate swan indents

all good but it dunno send

await ctx.send(ctx.message.author.mention + ", you don't have permission")

slate swan
#

thats all

cold sonnet
#

okay but now I can't find 25 in the source code from where the error comes, where does it get the 25 from yert

quick gust
slate swan
brisk brook
#

How do i keep using the wait_for function for my discord bot

slate swan
#

but in terminat

brisk brook
#

You don't use message.author

slate swan
#
Ignoring exception in command unlock:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 855, in invoke
    await self.prepare(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 777, in prepare
    if not await self.can_run(ctx):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1087, in can_run
    return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/utils.py", line 348, in async_all
    for elem in gen:
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1087, in <genexpr>
    return await discord.utils.async_all(predicate(ctx) for predicate in predicates)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 1790, in predicate
    raise MissingPermissions(missing)
discord.ext.commands.errors.MissingPermissions: You are missing Manage Channels permission(s) to run this command.
#

this show

brisk brook
#

You use message.author when you're using an on message event

brisk brook
#

Try using ctx.author.mention

slate swan
brisk brook
#

@commands.command()

#

Whats the command

slate swan
brisk brook
#

After that line

#

Nvm

slate swan
#

oh

brisk brook
slate swan
#

sry i got it

brisk brook
#

Sorry

#

Wrong shi

#

How do i keep using the wait_for function for my discord bot

slate swan
#

yah i forget to remove this

trail oxide
#

Traceback (most recent call last):
File "c:\Users\sebas\OneDrive\Desktop\Alle Mapper\Sebastian\Python\Discord\Nyt projekt\Main.py", line 95, in <module>
Client.load_extension(f'Cogs.{filename[:-3]}')

why does it fail in my moderation cog?

slate swan
#

full tb

trail oxide
#

?

slate swan
#

!traceback

unkempt canyonBOT
#

Please provide the full traceback for your exception in order to help us identify your issue.

A full traceback could look like:

Traceback (most recent call last):
    File "tiny", line 3, in
        do_something()
    File "tiny", line 2, in do_something
        a = 6 / b
ZeroDivisionError: division by zero

The best way to read your traceback is bottom to top.

β€’ Identify the exception raised (in this case ZeroDivisionError)
β€’ Make note of the line number (in this case 2), and navigate there in your program.
β€’ Try to understand why the error occurred (in this case because b is 0).

To read more about exceptions and errors, please refer to the PyDis Wiki or the official Python tutorial.

slate swan
#

thats not the full traceback

trail oxide
#

Traceback (most recent call last):
File "c:\Users\sebas\OneDrive\Desktop\Alle Mapper\Sebastian\Python\Discord\Nyt projekt\Main.py", line 95, in <module>
Client.load_extension(f'Cogs.{filename[:-3]}')

File "C:\Users\sebas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 678, in load_extension
self._load_from_module_spec(spec, name)

File "C:\Users\sebas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\bot.py", line 623, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
discord.ext.commands.errors.ExtensionFailed: Extension 'Cogs.Moderation' raised an error: TypeError: cogs must derive from Cog

slate swan
#

show the cog

trail oxide
#
from discord import Client
from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
from discord.ext.commands import has_permissions, MissingPermissions
from nextcord import Interaction, SlashOption, ChannelType
from nextcord.abc import GuildChannel
from nextcord.ext import commands
import nextcord
import platform
import datetime

class Moderation(commands.Cog):
    def __init__(self, Client):
        self.Client = Client


    def check_if_it_is_me(ctx):
        return ctx.message.author.id == 458251225394184205

    @commands.command(pass_context = 1)
    @commands.check(check_if_it_is_me)
    async def luk(self, ctx):
        emb = discord.Embed(description = ':exclamation: Botten lukker ned...', color = 0xffffff)
        emb.set_footer(text = 'Kommando spurgt af %s' % ctx.message.author.name)
        await ctx.send(embed = emb)
        await Client.logout()

"""""
    @commands.command()
    @has_permissions(manage_channels=True)
    async def toggle(self, ctx, *, command):
        command = Client.get_command(command)
        if command == None:
            await ctx.send('`Kunne ikke finde denne kommando`')
        elif ctx.command == command:
            await ctx.send('`Du kan ikke disable denne kommando.`')
        else: 
            command.enabled = not command.enabled
            ternary = "enabled" if command.enabled else "disabled"
        await ctx.send(f'`Kommandoen {command.qualified_name} er blevet {ternary}`')

    @commands.command()
    @has_permissions(ban_members=True)
    async def listban(self, ctx):
        banned_users = await ctx.guild.bans()
        await ctx.send('**Liste over folk, der er banned:**')

        for ban_entry in banned_users:
            user = ban_entry.user
            await ctx.send(f'**- Navn: {user.name}#{user.discriminator} - Tag: {user.mention}**')
            return

    @commands.command()
    @has_permissions(manage_channels=True)
    async def slowmode(self, ctx, amount):
        try:
            await ctx.channel.edit(reason='Slowmode kommando.', slowmode_delay=int(amount))
            await ctx.send(f'**Slowmode er nu slΓ₯et til {amount} sekunder.**')
        except discord.Errors.Forbidden:
            await ctx.send('**Jeg har ikke adgang til at kunne gΓΈre dette.**')

    @commands.command()
    @has_permissions(manage_permissions=True)
    async def lock(self, ctx, channel : nextcord.TextChannel = None, setting = None):
        if setting == '--server':
            for channel in ctx.guild.channels:
                await channel.set_permissions(ctx.guild.default_role, reason=f"**{ctx.author.name} lukkede {channel.name} med --server**", send_messages=False)
        await ctx.send('**Lukkede lige serveren ned.**')     
        if channel is None:
            channel = ctx.message.channel
        await channel.set_permissions(ctx.guild.default_role, reason=f"**{ctx.author.name} lukkede {channel.name}, brug .unlock for at unlocke kanalen igen.**", send_messages=False)
        await ctx.send('**Lukkede lige kanalen ned.**')
"""""


def setup(Client):
    Client.add_cog(Moderation(Client))
#

This is the 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.

haughty quartz
#

any idea of how i could improve the text so theres a tab when on new line

trail oxide
slate swan
#

sure but you have to format it first

trail oxide
#

how to

haughty quartz
slate swan
#

check on top

haughty quartz
trail oxide
slate swan
haughty quartz
slate swan
#

thats 4 lol

haughty quartz
#

something like if songname is 20 characters long: add a \t

trail oxide
#

@slate swan could you help me after

haughty quartz
slate swan
haughty quartz
slate swan
#

yes you check the length of each sentence

slate swan
trail oxide
#

i have done

haughty quartz
#

dude

#

no

trail oxide
#

oh

haughty quartz
#

after the 3 backspaces add py

#

!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.

haughty quartz
#

like that

slate swan
#

no on the top

trail oxide
#
import discord
from discord import Client
from discord.ext import commands
from discord.ext.commands.cooldowns import BucketType
from discord.ext.commands import has_permissions, MissingPermissions
from nextcord import Interaction, SlashOption, ChannelType
from nextcord.abc import GuildChannel
from nextcord.ext import commands
import nextcord
import platform
import datetime

class Moderation(commands.Cog):
    def __init__(self, Client):
        self.Client = Client


    def check_if_it_is_me(ctx):
        return ctx.message.author.id == 458251225394184205

    @commands.command(pass_context = 1)
    @commands.check(check_if_it_is_me)
    async def luk(self, ctx):
        emb = discord.Embed(description = ':exclamation: Botten lukker ned...', color = 0xffffff)
        emb.set_footer(text = 'Kommando spurgt af %s' % ctx.message.author.name)
        await ctx.send(embed = emb)
        await Client.logout()

"""""
    @commands.command()
    @has_permissions(manage_channels=True)
    async def toggle(self, ctx, *, command):
        command = Client.get_command(command)
        if command == None:
            await ctx.send('`Kunne ikke finde denne kommando`')
        elif ctx.command == command:
            await ctx.send('`Du kan ikke disable denne kommando.`')
        else: 
            command.enabled = not command.enabled
            ternary = "enabled" if command.enabled else "disabled"
        await ctx.send(f'`Kommandoen {command.qualified_name} er blevet {ternary}`')

    @commands.command()
    @has_permissions(ban_members=True)
    async def listban(self, ctx):
        banned_users = await ctx.guild.bans()
        await ctx.send('**Liste over folk, der er banned:**')

        for ban_entry in banned_users:
            user = ban_entry.user
            await ctx.send(f'**- Navn: {user.name}#{user.discriminator} - Tag: {user.mention}**')
            return

    @commands.command()
    @has_permissions(manage_channels=True)
    async def slowmode(self, ctx, amount):
        try:
            await ctx.channel.edit(reason='Slowmode kommando.', slowmode_delay=int(amount))
            await ctx.send(f'**Slowmode er nu slΓ₯et til {amount} sekunder.**')
        except discord.Errors.Forbidden:
            await ctx.send('**Jeg har ikke adgang til at kunne gΓΈre dette.**')

    @commands.command()
    @has_permissions(manage_permissions=True)
    async def lock(self, ctx, channel : nextcord.TextChannel = None, setting = None):
        if setting == '--server':
            for channel in ctx.guild.channels:
                await channel.set_permissions(ctx.guild.default_role, reason=f"**{ctx.author.name} lukkede {channel.name} med --server**", send_messages=False)
        await ctx.send('**Lukkede lige serveren ned.**')     
        if channel is None:
            channel = ctx.message.channel
        await channel.set_permissions(ctx.guild.default_role, reason=f"**{ctx.author.name} lukkede {channel.name}, brug .unlock for at unlocke kanalen igen.**", send_messages=False)
        await ctx.send('**Lukkede lige kanalen ned.**')
"""""


def setup(Client):
    Client.add_cog(Moderation(Client))
#

done, im sorry

haughty quartz
#

wow!

slate swan
#

there nice

#

hold on

haughty quartz
#

delete the comment @trail oxide

#

so its more readable

slate swan
#

youre importing commands from discord and nextcord wut

trail oxide
#

yes

#

should i delete that

slate swan
#

yes

haughty quartz
#

you should stick with one

trail oxide
#

then its work?

slate swan
#

yes

#

it should

slate swan
#

seen this error before when someone tried to import a cog that was in discord to disnake

trail oxide
#

oh yes it does, thanks bro!

slate swan
#

yw

trail oxide
#

but now i have this problem

C:\Users\sebas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\ext\commands\core.py:85: DeprecationWarning: logout is deprecated, use Client.close instead.
ret = await coro(*args, **kwargs)

#

i have a command that close the bot

slate swan
muted quarry
#

Hello, I want to know how I can keep my discord bot online for the whole time my computer is on.
Currently it goes offline after every command.
For example when I run the code from Visual studio code
and I do the command I coded
After the command is executed by the bot it goes offline that instant.
I need to rerun the code for it to come online every time.

trail oxide
muted quarry
wispy spade
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.

muted quarry
#

Ok I will just cut of my token and send it

#

@wispy spade @slate swan

#

I have written the code with Python 3.10. and Visual Studio code

slate swan
#

i see nothing wrong but don't do anything on ready

#

make a task

wispy spade
muted quarry
#

Ok sure

slate swan
#

i doubt that would do anything

violet nymph
muted quarry
fervent blade
#

can anybody teach me python for making a discord bot?

cold sonnet
#

oh u did

unkempt canyonBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

cold sonnet
#

I don't know, there's nothing wrong with your code

#

just this line triggers me
await context.message.channel.send(embed=myEmbed)

#

use await context.send(embed=myEmbed)

sage otter
muted quarry
sage otter
cold sonnet
#

no

muted quarry
cold sonnet
muted quarry
#

I will do it just give me 2 minutes please

cold sonnet
muted quarry
#

By restarting my bot do you mean my computer @slate swan

sage otter
#

dia you say I’m wrong but you haven’t told me why.

cold sonnet
#

just some prints

cold sonnet
#

or maybe almost always

sage otter
#

It’s a single api call to send a message

#

A single message

cold sonnet
#

and the api hates it more than anything

sage otter
#

It really doesn’t.

cold sonnet
#

sources

sage otter
#

People do that shit all day. People will send messages as soon as a shard connects to the gateway. Nothing bad happens.

wispy spade
#

In this case, it's likely something external

muted quarry
#

I dont have a vsc

#

Ohh i thought u meant
a cloud service

#

My bad

#

Yea I will restart it one sec

#

Yes will do

sage otter
cold sonnet
muted quarry
#

@slate swan I restarted it and restarted my pc too
It still didn't seem to do the trick

sage otter
#

Are you getting any errors to why your bot is dying

muted quarry
#

No errors

wispy spade
muted quarry
#

thats it and when i run the code

#

it comes online and says the message

haughty quartz
#

any idea how i can bypass every space getting deleted on \n (in embed)

muted quarry
#

One second I ran it again
I will just see if it does it again

#

It doesn't seem to be going offline now
After the restart
But i think I will give it a few minutes and get back to you

boreal ravine
#

are you using replit

muted quarry
#

@slate swan It doesn't seem to be going offline now
I think the restart fixed it

#

Thanks a lot!
I will let you know if anything happens again

cold sonnet
#

save it

#

while sending it

unkempt canyonBOT
#

@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
#

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**.
left crater
#

how can i make the bot send a video without having the link at the top

slate swan
#

a local file?

left crater
#

nah

#

can i use embed

slate swan
#

nope

placid zodiac
#

can you edit a message and remove any existing attachments?

#

aka, edit message replacing the attached file with another

left crater
#

i think u can only do ur own or the bots

cold sonnet
#

maybe inter.send doesn't return nothing

quick gust
#

i don't think there's a need to type hint it...?

#

that's probably not causing your error though

#

you'll need the ID of the message, idk if there's any other way

slate swan
#
async def vouch(ctx, *, reason=None):
  user, vouchs = reason.split(':') 
  message = await ctx.send("sending..") 
  time.sleep(0.3)
  await message.edit(content="**vouch received!!!**")
  vouch = 0
name = ("vouches.txt")
o = open(str(name), 'a')
for i in range:
        user = (f"{ctx.author.mention} vouched {user} reason: {vouchs} ")
        vouchs += 1
        print(f"{user} | {vouchs}")
        o.write(f"{user + vouchs}\n")```
cold sonnet
#

bro still stuck with intents

slate swan
#

πŸ˜…

cold sonnet
#
o = open(str(name), 'a')```this aswell
tidal hawk
#

asyncio.sleep(0.3) > time.sleep(0.3)

slate swan
#

Ok

slate swan
#

LOL

#

!snipe

#

whats the point of aliasing slash commands, that would just create multiple slash commands with same function

silk robin
placid zodiac
#

Since I want to have a message sent with one file, then edit it removing the first file and replacing it with a second

slate swan
#

No payment, the project has started a few weeks ago

placid zodiac
cold sonnet
#

!rule 9

unkempt canyonBOT
#

9. Do not offer or ask for paid work of any kind.

limber isle
#

What do you mean, discord.Attachment is the in discord version of of discord.File, you cant just turn a File into an Attachment locally

#

iirc

cold sonnet
slate swan
slate swan
cold sonnet
#

it's an offered job

slate swan
#

yeah

#

the rule says i cant offer paid jobes

cold sonnet
#

so it's against rule 9

slate swan
#

Nope, im not paying anyone

cold sonnet
#

they really have to rewrite that

dire folio
#

Ye

#

They do

cold sonnet
#

all these lawyers coming here to be smart

#

smarter than everyone else here

slate swan
#

Sure

limber isle
#

I think the linter is not smart enough for that

cold sonnet
#

isn't filter a keyword

#

seems from the coloring

limber isle
#

he has overwritten it as a keyword

cold sonnet
#

oh okay

#

well I've never seen anyone use it anyways

limber isle
#

Yeah I just think the linter has low IQ

cold sonnet
#

tho why are you splitting the message's content?

unkempt canyonBOT
#

@slate swan :white_check_mark: Your eval job has completed with return code 0.

True
cold sonnet
#

!e

print("hi" in "abcd hi there")```
unkempt canyonBOT
#

@cold sonnet :white_check_mark: Your eval job has completed with return code 0.

True
limber isle
#

!e print("hi" in "abcdhi there")

unkempt canyonBOT
#

@limber isle :white_check_mark: Your eval job has completed with return code 0.

True
slate swan
#

no

#

it checks if 'hi' is there , even if its a complete word or a part of a word

cold sonnet
#

um no

#

but it's the same outcome, except for what mathias showed

slate swan
#

guys gimme some codes to create a mute command with the bot

slate swan
#

yes because str.split breaks the string into a list of strings , and in would work with the complete words only

limber isle
unkempt canyonBOT
#
Not gonna happen.

No documentation found for the requested symbol.

slate swan
#

discord doesnt have timeout

#

!d disnake.Member.timeout

unkempt canyonBOT
#

await timeout(*, duration=..., until=..., reason=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Times out the member from the guild; until then, the member will not be able to interact with the guild.

Exactly one of `duration` or `until` must be provided. To remove a timeout, set one of the parameters to `None`.

You must have the [`Permissions.moderate_members`](https://docs.disnake.dev/en/latest/api.html#disnake.Permissions.moderate_members "disnake.Permissions.moderate_members") permission to do this.

New in version 2.3.
limber isle
#

Yeah forgot, I use pycord

slate swan
#

timeout in pycord is still beta right?

#

not in the pypi version

limber isle
#

It actually got realeased to beta yesterday