#discord-bots

1 messages Β· Page 1070 of 1

regal pulsar
#

!d str.replace

unkempt canyonBOT
#

str.replace(old, new[, count])```
Return a copy of the string with all occurrences of substring *old* replaced by *new*. If the optional argument *count* is given, only the first *count* occurrences are replaced.
slate swan
#

it's from the variable though

green bluff
#

image doesn't send

slate swan
#

what if the bot stops? you do stuff in the on_disconnect event too?

honest laurel
#

It's better to just use proper db

vocal snow
#

having large amount of data in memory is not always viable though

maiden fable
maiden fable
maiden fable
#

But then, bots like reaction roles do store everything in the cache so that everything is fast and they don't have to query their DB repeatedly

slate swan
#

@maiden fable How can I replace spaces with a certain character?

maiden fable
green bluff
slate swan
#
ch = "%"
lyrics = lyrics.replace(' ', ch)

this didn't seem to work

maiden fable
green bluff
paper sluice
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

hello%world
maiden fable
unkempt canyonBOT
#

@maiden fable :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print("    Hello     ".replace(" ", "%")
003 |          ^
004 | SyntaxError: '(' was never closed
maiden fable
#

Smh discord bugs

#

I can't react to messages

green bluff
robust fulcrum
#

Guys how can we make a !e comamnd like @unkempt canyon have?

green bluff
maiden fable
#

Add this in yr error handlers

unkempt canyonBOT
#
Command: eval

Run Python code and get the results.

Source Code
slate swan
#

@maiden fable you probably will know why this aint work lemme show the full code

#
@client.command(aliases=['ly'])
async def lyrics(ctx, lyrics):
    ch = "%"
    lyrics = lyrics.replace(' ', ch)
    r = requests.get(f'https://some-random-api.ml/lyrics?title={lyrics}')
    r = r.json()
    title = r['title']
    author = r['author']
    links = r['links']['genius']
    lyricss = r['lyrics']
    thumbnail = r['thumbnail']['genius']
    
    em = discord.Embed(url=f"{links}", title=f"{title} by {author}", description=f"{lyricss}" + "\n\n", color=discord.Color.blue())
    em.set_thumbnail(url=thumbnail)
    em.set_author(name=f'Result for: {title} by {author}', icon_url='https://images-ext-2.discordapp.net/external/ifcJsOb6tpFUWKRg2H5oUxp7RONA6nSV2ajXJ8-NP1s/%3Fformat%3D2500w/https/images.squarespace-cdn.com/content/v1/5aa2ed3f5b409b04f26f8580/1521864384033-QCLP1SKYQBAHQOVV3TGO/genius%2B4.png?width=582&height=582')
    await ctx.send(embed=em)
green bluff
robust fulcrum
#

@maiden fable

@command(name="eval", aliases=("e",))
    @guild_only()
    @redirect_output(
        destination_channel=Channels.bot_commands,
        bypass_roles=SNEKBOX_ROLES,
        categories=NO_SNEKBOX_CATEGORIES,
        channels=NO_SNEKBOX_CHANNELS,
        ping_user=False
    )
    async def eval_command(self, ctx: Context, *, code: CodeblockConverter) -> None:
        """
        Run Python code and get the results.
        This command supports multiple lines of code, including code wrapped inside a formatted code
        block. Code can be re-evaluated by editing the original message within 10 seconds and
        clicking the reaction that subsequently appears.
        We've done our best to make this sandboxed, but do let us know if you manage to find an
        issue with it!
        """
        await self.run_job("eval", ctx, "\n".join(code))

Here is source code of
Which libraries do i need to import for it?

paper sluice
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

hello%20world
paper sluice
#

its supposed to be %20 for space char

dull tide
#

How to start the ban function from @bot.event?

paper sluice
#

urllib.parse.quote will do all conversions for you :)

slate swan
paper sluice
#

yes

maiden fable
green bluff
maiden fable
#

Did u add that everywhere?

#

Like every error handler

green bluff
maiden fable
#

Add it everywhere

slate swan
#

like if I do !ly sky carti It's only using sky

green bluff
#

still nothing

paper sluice
slate swan
green bluff
#

um oopsies

#

it doesn't print the second "run"

dull tide
#

How to start ban from event decorator?

@bot.event
async def on_raw_reaction_add(payload):
    if payload.channel_id == 977614786311372830:
        if payload.emoji.name == "βœ…":
            channel = bot.get_channel(payload.channel_id)
            message = await channel.fetch_message(payload.message_id)
            reaction = get(message.reactions, emoji=payload.emoji.name)
            if reaction and reaction.count > 4:
            	await ban()
            	
@bot.command
async def ban(ctx):
		await bot.get_channel(977614786311372830).send("ban")
		await ctx.guild.ban(BanMember, reason=BanReason)
maiden fable
slate swan
#

@maiden fable error handler for a specific keyerror?

paper sluice
slate swan
green bluff
#

NOT FOUND??/

glad cradle
#

and have you saved the file?

green bluff
green bluff
glad cradle
green bluff
#

I am loading them on the on_ready event, tbh I need to start using setup hooks

glad cradle
#

I think that your class and you function shouldn't have the same name

green bluff
#

I get this error

green bluff
#

very creative

#

how would i specify the dir

slate swan
glad cradle
slate swan
#

@glad cradle coulda ya help?

#

how would I make a error handler for a specific keyerror

green bluff
#

😎

#

did it first try

slate swan
#

and if it returns None, its not there

#

better than raising unnecessary exceptions

#

but I kinda want the exception

slate swan
#
try:
     v_key = dict_["key"]
except KeyError:
     print(...)```
slate swan
#

thats where im accesing them

slate swan
#

and im telling you lmao

#

its better to use the get method here since you can set its default value withoit any unnecessary hastle, for example

title = r.get("title", "No title found")```
#

!d dict.get

unkempt canyonBOT
#

get(key[, default])```
Return the value for *key* if *key* is in the dictionary, else *default*. If *default* is not given, it defaults to `None`, so that this method never raises a [`KeyError`](https://docs.python.org/3/library/exceptions.html#KeyError "KeyError").
slate swan
#

I see i see

#

if it finds the title key in the dictionary, it'll return that else it'll return the default value No title found

dull tide
#

How to ban a user from on_raw_reaction_add?

slate swan
light violet
#

How to detect if my bot have top role in server on not

vital glacier
#

anyone who's familiar with the subclassing of a help command and how it works?

vital glacier
#

I know, mine works, just wondering on how I can make it if I do a command it'll give me the usage automatically instead of having to hardcode it every time in every single command

vital glacier
#

But I can't seem to figure it out

paper sluice
#

or just use the signature

azure depot
#

how to make xp and level system

vital glacier
paper sluice
#

U can gte the command signature in ur error handler. Then u can format it

robust fulcrum
#

Guys how can we edit message when we click on button send in the message?
I saw a gist but that not worked

vital glacier
#

also, that error message isn't an error handler, it's hardcoded into my command

warped mirage
#

Can someone help me fix code

dense swallow
#

@wet crystal this is what I was thinking, if the person clicks any of the item in the select menu, the button will be clickable.

class HelpView(discord.ui.View):
    def __init__(self, mapping: dict, ctx: commands.Context):
        super().__init__(timeout=180)
        self.ctx = ctx
        self.mapping = mapping
        self.message = None
        self.add_item(HelpDropdown(mapping, ctx))

    @discord.ui.button(label="Home", emoji="🏠", style=discord.ButtonStyle.blurple, disabled=True)
    async def home(self, button: discord.ui.Button, interaction: discord.Interaction):
        for item in self.children:
            item.disabled = False
        button.disabled = True
        
        embed = await bot_help_embed(self.ctx, self.mapping)
        await interaction.message.edit(embed=embed, view=self)
slate swan
#

hm yes, that should work

warped mirage
#

Can someone help me

slate swan
warped mirage
slate swan
robust fulcrum
#

Guys i made a button command but when i click button says interaction failed and gets error
I saw this buttons command on GitHub

warped mirage
#

Oh ye I need a leave message aswell forgot

placid skiff
green bluff
#

what is difference between async and coro

sacred oyster
#

hello

warped mirage
paper sluice
# vital glacier also, that error message isn't an error handler, it's hardcoded into my command

oh, like if u have an error handler u can get the parameter's name like

@bot.event
async def on_command_error(ctx, error):
    if isinstance(error, discord.ext.commands.error.MissingRequiredArgument):
          error.param.name   :: this gives the name of the missing parameter

another way could be that u make a function to format the signature like you do in your help command, and call that in the error handler

paper sluice
dense swallow
devout iris
#

what is the problem?

paper sluice
slate swan
#

oh wait nvm

robust fulcrum
dense swallow
paper sluice
#

just set it to False :p

dense swallow
#

both to false?

devout iris
#
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 300, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized

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

Traceback (most recent call last):
  File "c:\Users\Administrator\Desktop\TestiCanFly\main.py", line 279, in <module>
    bot.run(TOKEN)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 723, in run
    return future.result()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 511, in login
#

what is that

devout iris
paper sluice
#

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

devout iris
#

ah

dense swallow
# paper sluice just set it to False :p
    @discord.ui.button(label="Home", emoji="🏠", style=discord.ButtonStyle.blurple, disabled=True)
    async def home(self, button: discord.ui.Button, interaction: discord.Interaction):
        for item in self.children:
            item.disabled = False
        button.disabled = False
``` still does not work
#

or should i remove the disabled = True at the top?

devout iris
dense swallow
paper sluice
# devout iris https://paste.pythondiscord.com/hikihuwico
TOKEN = ""
bot = commands.Bot(command_prefix=discord.ext.commands.when_mentioned_or("i!", "hey bot ", "Δ°!", "Hey bot  " "gΓΆster "), intents = discord.Intents.all())
prefix = bot.command_prefix
bot.remove_command('help')
bot.launch_time = datetime.datetime.utcnow()

"""
if __name__ == "__main__":
  bot.load_extension("jishaku")
"""

u made this part a string, maybe thats the issue

paper sluice
# dense swallow discord.py 2.0a

in dpy, interactions come before buttons so ur signature would be

async def home(self, interaction: discord.Interaction, button: discord.ui.Button):
robust fulcrum
#

Hey me also have same problem

#

The interaction problem

paper sluice
#

obv\

robust fulcrum
#

Whenever I click button it says interaction failed

dense swallow
#

ok

robust fulcrum
paper sluice
devout iris
#

token has been invalid

#

i've regenerated the token and now working.... ty

paper sluice
#

ah k πŸ‘

paper sluice
young pendant
#

how to mention someone from nickname with tag?

robust fulcrum
#
import discord
from discord.ext import commands
from discord.ui  import Button , view

class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def blurple_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        button.style=discord.ButtonStyle.green
        await interaction.response.edit_message(content=f"This is an edited button response!",view=self)

class channel(commands.Cog):                       
	def __init__(self, bot):                          
		self.bot = bot

	@commands.command()
	@commands.has_permissions(manage_messages=True)
	async def test(self, ctx):
		await ctx.send("This message has buttons!",view=Buttons())

async def setup(bot):
	await bot.add_cog(channel(bot))

@paper sluice

young pendant
warped mirage
#

Can someone help me

robust fulcrum
paper sluice
#

which lib?

robust fulcrum
robust fulcrum
#

🧐

#

Where would I place it

#

In my code

paper sluice
#

in ur command button signature

robust fulcrum
#

At test command?

slate swan
#

poor ryuga

young pendant
robust fulcrum
#

Bruh

robust fulcrum
slate swan
#

!d discord.ext.commands.MemberConverter

unkempt canyonBOT
#

class discord.ext.commands.MemberConverter(*args, **kwargs)```
Converts to a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member").

All lookups are via the local guild. If in a DM context, then the lookup is done by the global cache.

The lookup strategy is as follows (in order)...
robust fulcrum
#

Sed

young pendant
robust fulcrum
young pendant
#

how to get User object from username

robust fulcrum
#

I guess can't

devout iris
#

how to add Loading emoji to a message?

#

or any emoji

dense swallow
dense swallow
#

type the emoji, the put this infront of the emoji - \

#

that will give u the format..

devout iris
#

ah okayy thankss

dense swallow
#

np

devout iris
#

πŸ™‚

dense swallow
#

it wont work with regular emoji.. im saying custom ones

robust fulcrum
#
    @commands.command() # Create a command inside a cog
    async def button(self, ctx,interaction: discord.Interaction, button: discord.ui.Button(style=discord.ButtonStyle.red,label="edited")):
		view = discord.ui.View() # Establish an instance of the discord.ui.View class
		style = discord.ButtonStyle.gray  # The button will be gray in color
		item = discord.ui.Button(style=style, label="Read the docs!")  # Create an item to pass into the view class.
		view.add_item(item=item)  # Add that item into the view class
		await ctx.send("This message has buttons!", view=view)

Will it work?

dense swallow
dense swallow
devout iris
#

also i have a question more....

#

how to get a random number? which lib?

dense swallow
#

random number?

devout iris
#

like 1-5

slate swan
unkempt canyonBOT
#

random.randint(a, b)```
Return a random integer *N* such that `a <= N <= b`. Alias for `randrange(a, b+1)`.
devout iris
#

ty

warped mirage
#

Can someone help me

tawdry perch
#

Just ask away

robust fulcrum
#
@commands.command()
	async def button(self, ctx):
		view = discord.ui.View() # Establish an instance of the discord.ui.View class
		style = discord.ButtonStyle.gray  # The button will be gray in color
		item = discord.ui.Button(style=style, label="Read the docs!")  # Create an item to pass into the view class.
		view.add_item(item=item)  # Add that item into the view class
		await ctx.send("This message has buttons!", view=view)

Where I ahve to put interaction thing

silk fulcrum
dense swallow
#

whats the error

silk fulcrum
#

but i didnt find his issue

formal basin
#

Guys what is wrong with this

robust fulcrum
devout iris
#

@dense swallowlol, how to get a bult-in emoji ?

slate swan
devout iris
#

where can i find

slate swan
robust fulcrum
#

![logo_vsc_insiders](https://cdn.discordapp.com/emojis/841900989245947914.webp?size=128 "logo_vsc_insiders") like this

devout iris
#

ty

formal basin
slate swan
formal basin
robust fulcrum
#

Will anyone help me pls!

slate swan
warped mirage
#

If someone can assist me ping me or reply

slate swan
dense swallow
formal basin
slate swan
formal basin
robust fulcrum
silk fulcrum
dense swallow
#

or f strings

silk fulcrum
#

yeah

formal basin
#

Thanks

slate swan
quaint epoch
#

hello hooman

robust fulcrum
# dense swallow sub class the buttons and view, it will be much easier

class Buttons(discord.ui.View):
    def __init__(self, *, timeout=180):
        super().__init__(timeout=timeout)
    @discord.ui.button(label="Button",style=discord.ButtonStyle.gray)
    async def gray_button(self,button:discord.ui.Button,interaction:discord.Interaction):
        await interaction.response.edit_message(content=f"This is an edited button response!")

class channel(commands.Cog):                       
	def __init__(self, bot):                          
		self.bot = bot
		
	@commands.command()
	async def test(self, ctx):
		await ctx.send("hello",view=Buttons)

Will it work?

silk fulcrum
#

i think they're different

slate swan
#

!d discord.InteractionResponse.send_message

unkempt canyonBOT
#

await send_message(content=None, *, embed=..., embeds=..., file=..., files=..., view=..., tts=False, ephemeral=False, allowed_mentions=..., suppress_embeds=False)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Responds to this interaction by sending a message.
robust fulcrum
#

Interaction is big problem

young pendant
slate swan
slate swan
unkempt canyonBOT
#

class discord.ext.commands.MemberConverter(*args, **kwargs)```
Converts to a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member").

All lookups are via the local guild. If in a DM context, then the lookup is done by the global cache.

The lookup strategy is as follows (in order)...
robust fulcrum
#

But button comes but interaction fails

slate swan
#

you have to create an instance of the View object

#

view=Buttons()

robust fulcrum
#

I made a class already

slate swan
#

instantiate it

robust fulcrum
#

Oh k

young pendant
slate swan
#

welcome

robust fulcrum
#

view = Buttons()
await ctx.send("blah",view=view)

#

Like this?

robust fulcrum
silk fulcrum
#

uhm, yeah it'll work, but ya can just type await ctx.send("blah",view=Buttons())

robust fulcrum
#

I did

#

But interaction problem

silk fulcrum
#

what problem?

young pendant
silk fulcrum
#

error?

silk fulcrum
robust fulcrum
#

Do you know how can I remove that

slate swan
silk fulcrum
slate swan
#

whoknowsmaybeyoudo

silk fulcrum
unkempt canyonBOT
#

await edit_original_message(*, content=..., embeds=..., embed=..., attachments=..., view=..., allowed_mentions=None)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Edits the original interaction response message.

This is a lower level interface to [`InteractionMessage.edit()`](https://discordpy.readthedocs.io/en/latest/interactions/api.html#discord.InteractionMessage.edit "discord.InteractionMessage.edit") in case you do not want to fetch the message and save an HTTP request.

This method is also the only way to edit the original message if the message sent was ephemeral.
silk fulcrum
#

this?

young pendant
#

how to get ctx in task?

slate swan
unkempt canyonBOT
#

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

Returns the invocation context from the message or interaction.

This is a more low-level counter-part for [`process_commands()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.process_commands "discord.ext.commands.Bot.process_commands") to allow users more fine grained control over the processing.

The returned context is not guaranteed to be a valid invocation context, [`Context.valid`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Context.valid "discord.ext.commands.Context.valid") must be checked to make sure it is. If the context is not valid then it is not a valid candidate to be invoked under [`invoke()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

Note

In order for the custom context to be used inside an interaction-based context (such as [`HybridCommand`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.HybridCommand "discord.ext.commands.HybridCommand")) then this method must be overridden to return that class...
young pendant
young pendant
silk fulcrum
#

wtf

#

it's not being imported

#

you need an instance of Bot class

young pendant
#

I havnt

silk fulcrum
#

like myBot = commands.Bot(prefix='????')

young pendant
#

I have client

silk fulcrum
#

oof

young pendant
#

I dont write bot

silk fulcrum
#

channel name: yeah, who am i

young pendant
#

I write script for my account, not bot, should I create Bot istance?

silk fulcrum
#

😳

#

i dont know if im allowed to help with illegal things

young pendant
#

hmm bro

slate swan
#

!rule 5

unkempt canyonBOT
#

5. Do not provide or request help on projects that may break laws, breach terms of services, or are malicious or inappropriate.

young pendant
#

I want to send messsages in my own server with friends

#

where are there illigal things?

silk fulcrum
#

you could at least use webhook...

silk fulcrum
young pendant
young pendant
silk fulcrum
#

yes

young pendant
slate swan
#

automating your bot account is against discord Tos amd can get you banned.

silk fulcrum
slate swan
young pendant
#

okey................

slate swan
silk fulcrum
#

ohk

slate swan
#

But that still doesn't change the fact that it's against the ToS

young pendant
#

I just learn python bro

silk fulcrum
#

bro W3Schools

#

go learn python lol

devout iris
#

How to see server's cpu usage ?

young pendant
#

and I decided to learn this lib a little bit for practice

silk fulcrum
devout iris
silk fulcrum
#

nvm just joking

devout iris
#

πŸ€·β€β™‚οΈ

young pendant
silk fulcrum
#

is it hard to create a bot to learn it ?

young pendant
slate swan
loud junco
#

how to make my bot send a message to a specific channel with id

silk fulcrum
#

get / fetch channel, send message

#

!d discord.ext.commands.Bot.fetch_channel

unkempt canyonBOT
#

await fetch_channel(channel_id, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Retrieves a [`abc.GuildChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel"), [`abc.PrivateChannel`](https://discordpy.readthedocs.io/en/latest/api.html#discord.abc.PrivateChannel "discord.abc.PrivateChannel"), or [`Thread`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Thread "discord.Thread") with the specified ID.

Note

This method is an API call. For general usage, consider [`get_channel()`](https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#discord.ext.commands.Bot.get_channel "discord.ext.commands.Bot.get_channel") instead.

New in version 1.2.

Changed in version 2.0: `channel_id` parameter is now positional-only.
loud junco
#

thanks

devout iris
warped mirage
#

Can someone help me

silk fulcrum
#

I didnt find it, maybe i should've scrolled even more...

slate swan
#

!d psutil.cpu_percent

unkempt canyonBOT
maiden fable
#

Ngl psutil is one of the best modules out there

loud junco
#
words = ['mwds', 'mds', 'smwnc', 'mdwc', 'change', 'massive']
list1 = ''
for word in words:
  if word.startswith('mwd'):
    #replace mwd to meaty wooly diamond
    list1 += f' {word}'
print(list1)
#

how do i replace

maiden fable
loud junco
#

alright

#

!paste

maiden fable
#

Uh?

loud junco
maiden fable
#

Ah

loud junco
#

mwds -> meaty wooly diamond s

maiden fable
#

Nvm

loud junco
#

i dont want to replace it in the list

maiden fable
#

Then

loud junco
#
res2 = ''
    for items in itemss['items']:
      my_emote = discord.utils.get(bot.emojis, name = items)
      value = db[stats.userid + items]
      if value > 0:
        res2 += f"{my_emote}{items}: {value}\n"

because the some name != items

supple thorn
#

You could also do this ```py
words = ['mwds', 'mds', 'smwnc', 'mdwc', 'change', 'massive']
list1 = [f' {word}' for word in words if word.startswith("mwd")]
print(list1)

#

!e ```py
words = ['mwds', 'mds', 'smwnc', 'mdwc', 'change', 'massive']
list1 = [f' {word}' for word in words if word.startswith("mwd")]
print(list1)

unkempt canyonBOT
#

@supple thorn :white_check_mark: Your eval job has completed with return code 0.

[' mwds']
loud junco
#

i still want to iterate through all of them

#

alright

#

i found a way to fix it
its freaking simple

#
if value == 1:
        my_emote = discord.utils.get(bot.emojis, name = f'pog_{armor}')
        res4 += f'{my_emote}pog_{armor}\n'
      if value == 2:
        my_emote = discord.utils.get(bot.emojis, name = f'iron_{armor}')
        res4 += f'{my_emote}iron_{armor}\n'
      if value == 3:
        my_emote = discord.utils.get(bot.emojis, name = f'diamond_{armor}')
        res4 += f'{my_emote}diamond_{armor}\n'
      if value == 4:
        my_emote = discord.utils.get(bot.emojis, name = f'meaty_wooly_diamond_{armor}')
        res4 += f'{my_emote}meaty_wooly_diamond_{armor}\n'
      if value == 5:
        my_emote = discord.utils.get(bot.emojis, name = f'shiny_meaty_wooly_diamond_{armor}')
        res4 += f'{my_emote}shiny_meaty_wooly_diamond_{armor}\n'
      if value == 6:
        my_emote = discord.utils.get(bot.emojis, name = f'shiny meaty wooly netherite {armor}')
        res4 += f'{my_emote}shiny meaty wooly netherite {armor}\n'
      if value == 7:
        my_emote = discord.utils.get(bot.emojis, name = f'more shiny meaty wooly netherite {armor}')
        res4 += f'{my_emote}more shiny meaty wooly netherite {armor}\n'
      if value == 69:
        res4 += ':beefy_sword: beefy_sword'
#

just change the my_emote = ...

silk fulcrum
#

oof

placid skiff
loud junco
#

πŸ‘€

warped mirage
#

yo how is everyone doing . can someone help me with my welcome system

placid skiff
#

!e

my_dict = {1: "first string", 2: "second string", 3: "third string"}
print(my_dict[1])
unkempt canyonBOT
#

@placid skiff :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 2
002 |     print(my_dict[1]
003 |          ^
004 | SyntaxError: '(' was never closed
placid skiff
#

I can t press buttons on mobile lol

#

Thanks

slate swan
#

πŸ‘

warped mirage
slate swan
#

So it's clear

placid skiff
#

It don't let me press the button xD

slate swan
#

Lol

silk fulcrum
warped mirage
#

making the last 2 commands

silk fulcrum
#

ah i see

maiden fable
warped mirage
#

i tried before but it messed up with my first 2 commands and they looked the same so idk

placid skiff
#

So weird

slate swan
#

Rip I delete that

placid skiff
#

I think that he saw that
I hope...

slate swan
#

Huh

loud junco
#

its ok

#

i fixed it

placid skiff
#

Commands must initiate with the prefix xD

slate swan
silk fulcrum
#

isnt hydro a prefix?

placid skiff
#

It's a mention lol

silk fulcrum
#

sed

#

xd

warped mirage
#

anyways what now

slate swan
#

add pass

silk fulcrum
#

idk

jade tartan
slate swan
#

BIG

warped mirage
jade tartan
devout iris
#

is that true?

silk fulcrum
#

maybe random with lowercase r?

hot cobalt
#

^

#

You should be using random.randint

#

You've done something like from random import Random

#

Just import random

#

And then random.randint

warped mirage
slate swan
#

How to get 1 user out of the reaction and ping him/her?

devout iris
jade tartan
#

Hi peeps do you know how to have this bot give out auto assign multiple roles members to when they join? in this code

    async def autoRole(self, ctx):
        channel = ctx.message.channel
        author = ctx.message.author
        server = ctx.message.guild

        defRole = self.settings.getServerStat(server, "DefaultRole")
        verify = int(self.settings.getServerStat(server, "VerificationTime"))

        msg = '**__Auto-Role Management__**:\n\nWould you like me to auto-assign a role to new users when they join? (y/n/skip)'
        if defRole:
            auto = 'set to: **{}**.'.format(DisplayName.roleForID(defRole, server))
        else:
            auto = '*disabled*.'

        if verify == 0:
            verifyString = 'No delay before applying.'
        else:
            verifyString = '{} minute delay before applying.'.format(verify)

        msg = '{}\n\nCurrently {}\n{}'.format(msg, auto, verifyString)

        await author.send(msg)

        gotIt = False
        while not gotIt:
            def littleCheck(m):
                return author.id == m.author.id and self.check(m)
            try:
                talk = await self.bot.wait_for('message', check=littleCheck, timeout=60)
            except Exception:
                talk = None

            if not talk:
                msg = "*{}*, I'm out of time... type `{}setup` in the main chat to start again.".format(
                    DisplayName.name(author), ctx.prefix)
                await author.send(msg)
                return
            else:
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.

devout iris
#

What are these ?

paper sluice
#

u didnt call the function

#

!e

def foo():
    return 'bar'

print(foo) # didnt call the function
print(foo()) # called the function
unkempt canyonBOT
#

@paper sluice :white_check_mark: Your eval job has completed with return code 0.

001 | <function foo at 0x7fd88a85cc10>
002 | bar
devout iris
#

Ah yeah πŸ€¦β€β™‚οΈ lemme test it

jade tartan
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.

slate swan
paper sluice
paper sluice
#

```py
<your code>

```

devout iris
#

Why i got None?

maiden fable
#

Show the embed code

paper sluice
#

so it returns None

maiden fable
#

Uh, yea that

warped mirage
#

guys can u help me with the welcoming text code

devout iris
#

Hmmm

warped mirage
#

first as that

jade tartan
#

It wont send it

devout iris
#

But idk What should i return ....

paper sluice
slate swan
#

web browser discord.

jade tartan
#

i didnt

#

i am sending it here

paper sluice
#

huh, weird

jade tartan
#

But this what happens when i click send here

slate swan
carmine hearth
#

i'm making discord bot

warped mirage
#

@slate swan im almost done with my first command and ima show and u tell me how close i am to fixing it

paper sluice
jade tartan
#

So

silk fulcrum
jade tartan
#

i dont have any other choice than !paste

#

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

jade tartan
#

So can i?

slate swan
#

yes

jade tartan
#

ok thank you

placid skiff
carmine hearth
#

guys i cant write code for help menu

#

it isn't works

#

i dont know why

silk fulcrum
#

error?

carmine hearth
#

no

slate swan
paper sluice
silk fulcrum
warped mirage
#
 @commands.command()
    async def set_msg(self, ctx):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.cursor()
            await cursor.execute("SELECT * FROM wm WHERE guild_id = ?", (ctx.guild.id,))
            await db.commit()
            data = await cursor.fetchone()

            if data is None:
                await cursor.execute("INSERT INTO wm(guild_id, channel_id, welcome TEXT) VALUES(?,?,?)", (ctx.guild.id, ctx.channel.id,))
                await db.commit()
                await ctx.send(f"Welcome Message has been set!")
                return
            if data is not None:
                await cursor.execute("SELECT welcome TEXT FROM wm WHERE guild_id = ?", (ctx.guild.id,))
                await cursor.fetchone()
                result = data[0]
                await ctx.send(f"This server already has a Welcome Message set.", delete_after = 10 )
                return``` i actually re writed but idk
vale wing
#

It's only for CREATE TABLE and ALTER TABLE

placid skiff
#

Wtf is bot.say

silk fulcrum
#

a command maybe :lemao:

warped mirage
carmine hearth
#

ok

warped mirage
#

btw

jade tartan
vale wing
#

And yeah why wouldn't you add ability to overwrite existing welcome channel

#

UPDATE exists

warped mirage
#
@commands.Cog.listener()
    async def on_member_join(self, member):
        async with aiosqlite.connect("wm.db") as db:
            cursor = await db.cursor()
            await cursor.execute("SELECT * FROM wm WHERE guild_id = ?", (member.guild.id,))
            data = await cursor.fetchone() 
            if data is None:
                return
            else:
                if data is not None:
                    await cursor.execute("SELECT channel_id FROM wm WHERE guild_id = ?", (member.guild.id,))
                    channel_id = await cursor.fetchone()
                    channel = channel_id[0]
                    final = self.client.get_channel(channel)
                    await final.send(f"welcome {member.mention}")

                else:
                    return``` since im doing a set message command do i need everything here
paper sluice
#
            if data is None:
                return
            else:
                if data is not None:

u dont need if data is not None:

vale wing
#
if data is None:
    return
else:
    if data is not None:
``` very interestring construction
vocal snow
#

Ideally you shouldn't be creating a new connection each time

warped mirage
slate swan
#
Ignoring exception in command gcreate:
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 200, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Users\Jaisman's PC\Desktop\ACLib\bot.py", line 249, in gcreate
    users = [user async for user in reaction.users()]
AttributeError: 'NoneType' object has no attribute 'users'

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

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1329, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 995, in invoke
    await injected(*ctx.args, **ctx.kwargs)  # type: ignore
  File "C:\Python310\lib\site-packages\discord\ext\commands\core.py", line 209, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'users'
``` error ^
vale wing
#

reaction is None

slate swan
jade tartan
#

uhh ill just wait till you guys are done

slate swan
#
@client.command()
async def gcreate(ctx, mins: int, *, prize):

  await ctx.send("Giveaway!")

  end = datetime.utcnow() + timedelta(seconds=mins*60)
  embed = discord.Embed(title=f"{prize}", description=f"React With :tada_cyan: to enter \nEnds: <t:{end.timestamp():.0f}:R> \n Hosted By: {ctx.author.mention}", color = discord.Color.random())
  embed.set_footer(text=f"1 Winner | Ends {mins} min(s) from now!")

  my_msg = await ctx.send(embed=embed)

  reaction = await my_msg.add_reaction(":tada_cyan:")

  await asyncio.sleep(mins*60)

  new_msg = await ctx.channel.fetch_message(my_msg.id)

  users = [user async for user in reaction.users()]
  users.pop(users.remove(client.user))

  winner = random.choice(users)

  await ctx.send(f"{winner.mention}")

  embed2 = discord.Embed(title="Winner!", description=f"{winner.mention}")
  embed2.set_thumbnail(url=winner.avatar_url)
  embed2.add_field(name = "Prize", value=f"{prize}")
  embed2.set_footer(text="Giveaway Ended!")

  server = ctx.guild.name

  await ctx.send(embed = embed2)
  await winner.send(f"You Won a giveaway in {server} \n Prize: {prize}")
``` code
warped mirage
#

nah i can change it but i need help

vale wing
slate swan
jade tartan
warped mirage
#

async def setup_db() i know some stuff xd

vale wing
#

!d discord.Message.add_reaction

unkempt canyonBOT
#

await add_reaction(emoji, /)```
This function is a [*coroutine*](https://docs.python.org/3/library/asyncio-task.html#coroutine).

Adds a reaction to the message.

The emoji may be a unicode emoji or a custom guild [`Emoji`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Emoji "discord.Emoji").

You must have the [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") permission to use this. If nobody else has reacted to the message using this emoji, the [`add_reactions`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.add_reactions "discord.Permissions.add_reactions") permission is required.

Changed in version 2.0: `emoji` parameter is now positional-only.

Changed in version 2.0: This function will now raise [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "(in Python v3.10)") instead of `InvalidArgument`.
paper sluice
slate swan
vale wing
#

@slate swan add_reaction doesn't return anything

slate swan
silk fulcrum
#

:tada_cyan:

carmine hearth
jade tartan
vocal snow
warped mirage
#

well

#

Great Things Take time

slate swan
warped mirage
#

im working on this system for 2 days now

paper sluice
vale wing
slate swan
#

To add reaction to the message and then get one user out of it
And mention him/her

carmine hearth
tacit token
#

hi guys, what is this?

tacit token
slate swan
vale wing
slate swan
warped mirage
shrewd apex
tacit token
shrewd apex
warped mirage
jade tartan
slate swan
silk fulcrum
warped mirage
#

ok so what shall i MAsterKnots do now

#

one person tell me

slate swan
silk fulcrum
#

they're both using SQL queries

shrewd apex
#

u can create roles when user joins then use addroles

vale wing
slate swan
jade tartan
#

What line is that?

#

or what link to add it

paper sluice
# warped mirage discord.py

[EDIT: only works with dpy2.0] u can setup connection like this b4 starting your bot

async with bot:
    async with aiosqlite.connect(db-name) as db:
          bot.db = db
          await bot.start(token)

this will make it so that u dont have to connect again and again to the same db

vale wing
#

You can change cursor factory ofc but still aiosqlite looks cringe

slate swan
slate swan
vale wing
#

It is easier

carmine hearth
jade tartan
vale wing
#

Working with tuples is very inconvenient

shrewd apex
#

its more readble

vale wing
#

Dict-like objects are much more convenient

#

Cursor factory for aiosqlite can do that as well but yeah

slate swan
slate swan
#

πŸŒοΈβ€β™€οΈ i just covert my tuple to a dataclass so really doesn't bother me

vale wing
unkempt canyonBOT
carmine hearth
paper sluice
warped mirage
#

guys?

carmine hearth
#

what?

vale wing
unkempt canyonBOT
#

discord.on_member_join(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member") joins a [`Guild`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild "discord.Guild").

This requires [`Intents.members`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Intents.members "discord.Intents.members") to be enabled.
slate swan
slate swan
#

Hello

#

hello?

warped mirage
# slate swan yes?
async def setup_db():
    async with aiosqlite.connect("wm.db") as db:
        cursor = await db.cursor()
        await cursor.execute("CREATE TABLE IF NOT EXISTS wm(guild_id INTEGER, channel_id INTEGER, welcome TEXT, leave TEXT)")
        await db.commit()``` would this work
#

thats my one connection

warped mirage
#

then can u help me please because i dont understand now

slate swan
#

how would you even run the function, and you aren't returning the cursor

#

so it will just return None

#

and I still recommend to switch to v2 since you just started with this bot and there's still time

warped mirage
#

well can u help me with my thing or nah

loud junco
#

if i input rpm eat steak 4
rpm is prefix
eat is the command
steak, 4 is argument

#

how do i split steak and 4

paper sluice
#

just take them as arguments like eat(ctx, food_item: str, quantity: int)
or u can str.split

slate swan
#

i dont know, im out

maiden fable
#

@warped mirage u will still have to switch to 2.0 in a few weeks since the API version 1.7 uses will be decommissioned

#

And rewriting in a few weeks is not better than writing with 2.0 once

warped mirage
#

If I update to 2.0 will u help me with the entire code

#

Idk

paper sluice
warped mirage
#

2.0 has a huge difference

#

I cba

maiden fable
#

I mean, she (or anyone else here) isn't liable to help you here and she's making u switch to 2.0 since that will make sure yr bot continues working even when the current API version is decommissioned

warped mirage
#

Nice

warped mirage
#

@slate swan how do I install 2.0

slate swan
#

at last

#

I love you so much, Hunter

carmine hearth
#

i use repl it for coding

maiden fable
#

Lmao

carmine hearth
#

is this good?

loud junco
#

🀣

maiden fable
slate swan
loud junco
#

oo he wants wrapper

warped mirage
#

wait do i gotta install git the software aswell?

jade tartan
#

Can you help me?

warped mirage
#

Ok

#

WOW @slate swan it finally installed

slate swan
#

ohmi god

jagged adder
#

how do i check if there is items in a dict? i know its simple but im having a mental blank. i want it to work that if there is items in a 'chest' certain text is printed, if all values are 0 (false) then return different text

warped mirage
# slate swan ohmi god
Successfully built discord.py
Installing collected packages: discord.py
  Attempting uninstall: discord.py
    Found existing installation: discord.py 1.7.3
    Uninstalling discord.py-1.7.3:
      Successfully uninstalled discord.py-1.7.3
Successfully installed discord.py-2.0.0a4308+gf24f34e3``` is this correct?
warped mirage
#

ok so now what πŸ˜‰

#

oh damn i already get errors : here we go

slate swan
warped mirage
#

first error

#
File "C:\Users\Dom\Desktop\beta test\bot.py", line 4, in <module>
    from discord_slash import SlashCommand```
#
mportError: cannot import name 'InvalidArgument' from 'discord' (C:\Users\Dom\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\__init__.py)```
maiden fable
#

Yes

#

Uninstall those libraries

#

discord.py supports slash commands and other context commands

warped mirage
#
aiohttp                  3.7.4.post0
aiosignal                1.2.0
aiosqlite                0.17.0
arrow                    1.2.2
async-timeout            3.0.1
asyncio                  3.4.3
attrs                    21.4.0
binaryornot              0.4.4
certifi                  2021.10.8
cffi                     1.15.0
chardet                  4.0.0
charset-normalizer       2.0.12
click                    8.1.2
colorama                 0.4.4
cookiecutter             1.7.3
cookiejar                0.0.3
discord                  1.7.3
discord.py               2.0.0a4308+gf24f34e3
discord-py-slash-command 3.0.3
discord-ui               5.1.6
distlib                  0.3.4
dnspython                2.2.1
easy-pil                 0.1.6
filelock                 3.6.0
frozenlist               1.3.0
idna                     3.3
Jinja2                   3.1.1
jinja2-time              0.2.0
MarkupSafe               2.1.1
mkdir                    2020.12.3
multidict                6.0.2
pager                    3.3
Pillow                   8.4.0
pip                      21.2.4
platformdirs             2.5.2
poyo                     0.5.0
pycparser                2.21
pymongo                  4.1.1
PyNaCl                   1.5.0
python-dateutil          2.8.2
python-slugify           6.1.1
requests                 2.27.1
setuptools               58.1.0
six                      1.16.0
text-unidecode           1.3
typing_extensions        4.1.1
urllib3                  1.26.9
useragent                0.1.1
values                   2020.12.3
view                     0.1
virtualenv               20.14.1
wavelink                 1.2.4
write                    2020.12.3
yarl                     1.7.2``` what shall i uninstall
#

i have some xd

maiden fable
#

discord-py-slash-command
discord-py-ui

warped mirage
#

ok

maiden fable
#

And discord too

#

And why tf did u install asyncio via pypi

warped mirage
#

ok done

maiden fable
#

!pypi asyncio

unkempt canyonBOT
warped mirage
#

ok ima uninstall

maiden fable
#

Yes

warped mirage
#

done

maiden fable
#

What's yr Python version?

#

python -V

warped mirage
robust fulcrum
#

Guys i am getting error can anyone help me fix?

warped mirage
#

my py version is Python 3.10.2 @maiden fable

carmine hearth
robust fulcrum
carmine hearth
#

i'm on pc

robust fulcrum
#

Ok

carmine hearth
#

i'm making my first bot

#

can i show my code?

#

i'm speak russian

#

#ΠΈΠΌΠΏΠΎΡ€Ρ‚Ρ‹ from
from webserver import keep_alive
from discord.ext import commands, tasks
from discord.utils import get
from discord.ext.commands import has_permissions, CheckFailure, check

#ΠΈΠΌΠΏΠΎΡ€Ρ‚Ρ‹
import random
import os
import discord
import asyncio
import time
import discord.ext

#настройка Π±ΠΎΡ‚Π°
prefix = 'o!'
bot = commands.Bot(command_prefix = prefix)
bot.remove_command('help')

#ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ для Π±ΠΎΡ‚Π°
@bot.command()
async def ping(ctx):
await ctx.send('pong!')

@bot.command(pass_context=False)
async def botping(ctx):
#Π’Ρ‹Π²ΠΎΠ΄ Π·Π°Π΄Π΅Ρ€ΠΆΠΊΠΈ Π² Ρ‡Π°Ρ‚
await ctx.send('Пинг: {0}'.format(bot.latency))

#ΠΎΡ‚ΠΎΠ±Ρ€Π°ΠΆΠ°Π΅Ρ‚ Π² консоли Ρ‡Ρ‚ΠΎ Π²ΠΊΠ»ΡŽΡ‡Ρ‘Π½
@bot.event
async def on_ready():
print("bot online")

keep_alive()
bot.run(os.getenv("DISCORD_TOKEN"))

#

from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def home():
return "ΠœΠΎΠ½ΠΈΡ‚ΠΎΡ€ Π°ΠΊΡ‚ΠΈΠ²Π΅Π½."

def run():
app.run(host='0.0.0.0',port=8080)

def keep_alive():
t = Thread(target=run)
t.start()

heady sluice
#

@bot.command(pass_context=False) ?

carmine hearth
#

i cant make help command

#

what i should to do???

heady sluice
#

what's stopping you from making one?

maiden fable
carmine hearth
heady sluice
#

do you get an error?

carmine hearth
#

nope

#

i can try again

dense swallow
carmine hearth
#

and make screenshot

heady sluice
#

so when you put something like this in your code

@bot.command()
async def help(ctx):
    await ctx.send("Help arrived!")

and you type o!help in discord, nothing happens?

carmine hearth
#

now it works

heady sluice
#

nice

slate swan
#

I tried looking for it in the documentation but I didn't have any luck finding out how to make the bot execute a certain block of code when replied to. Does anyone know?

heady sluice
carmine hearth
#

i tryed to make embed what send bot when i use o!help

unkempt canyonBOT
#

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

Waits for a WebSocket event to be dispatched.

This could be used to wait for a user to reply to a message, or to react to a message, or to edit a message in a self-contained way.

The `timeout` parameter is passed onto [`asyncio.wait_for()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.wait_for "(in Python v3.10)"). By default, it does not timeout. Note that this does propagate the [`asyncio.TimeoutError`](https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError "(in Python v3.10)") for you in case of timeout and is provided for ease of use.

In case the event returns multiple arguments, a [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)") containing those arguments is returned instead. Please check the [documentation](https://discordpy.readthedocs.io/en/latest/api.html#discord-api-events) for a list of events and their parameters.

This function returns the **first event that meets the requirements**...
carmine hearth
#

how to make help menu in embed?

heady sluice
carmine hearth
#

ok

slate swan
#

You'd have to study how to make embeds.

robust fulcrum
slate swan
heady sluice
#

there are examples on the docs for bot.wait_for

carmine hearth
heady sluice
robust fulcrum
#

Ok

devout iris
#

How to fix that?

slate swan
heady sluice
robust fulcrum
#
import discord
from discord.ext import commands
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw

class channel(commands.Cog):                       
	def __init__(self, bot):                          
		self.bot = bot
	@commands.command(pass_context=True)
	async def info(ctx, user: discord.Member):
		img = Image.open("infoimgimg.png") #Replace infoimgimg.png with your background image.
		draw = ImageDraw.Draw(img)
		font = ImageFont.truetype("Modern_Sans_Light.otf", 100) #Make sure you insert a valid font from your folder.
		fontbig = ImageFont.truetype("Fitamint Script.ttf", 400) #Make sure you insert a valid font from your folder.
    #    (x,y)::↓ ↓ ↓ (text)::↓ ↓     (r,g,b)::↓ ↓ ↓
		draw.text((200, 0), "Information:", (255, 255, 255), font=fontbig) #draws Information
		draw.text((50, 500), "Username: {}".format(user.name), (255, 255, 255), font=font) #draws the Username of the user
		draw.text((50, 700), "ID:  {}".format(user.id), (255, 255, 255), font=font) #draws the user ID
		draw.text((50, 900), "User Status:{}".format(user.status), (255, 255, 255), font=font) #draws the user status
		draw.text((50, 1100), "Account created: {}".format(user.created_at), (255, 255, 255), font=font) #When the account was created 
		draw.text((50, 1300), "Nickname:{}".format(user.display_name), (255, 255, 255), font=font) # Nickname of the user
		draw.text((50, 1500), "Users' Top Role:{}".format(user.top_role), (255, 255, 255), font=font) #draws the top rome
		draw.text((50, 1700), "User Joined:{}".format(user.joined_at), (255, 255, 255), font=font) #draws info about when the user joined
		img.save('infoimg2.png') #Change infoimg2.png if needed.
		await ctx.send(file=discord.File("infoimg2.png"))	
	

async def setup(bot):
	await bot.add_cog(channel(bot))


@heady sluice

slate swan
heady sluice
heady sluice
devout iris
robust fulcrum
heady sluice
#

every function in a class takes self as first param

robust fulcrum
#

Ik forgot

#

Cogs makes brain blast

heady sluice
#

you'll get used to them πŸ‘

robust fulcrum
#

Thanks for help

#

Me first time used cogs today

heady sluice
#

or a quick google

devout iris
#
def pingg():
  return int(bot.latency*1000)β€Š
hushed galleon
#

yeah dpy returns NaN latency if you try to check it before the bot has actually connected to discord

heady sluice
#

oh

heady sluice
devout iris
#

I am really confused πŸ˜†πŸ˜†

hushed galleon
#

based on their traceback they ran the function at the module-level

devout iris
heady sluice
#

okay but when do you call pingg()

devout iris
heady sluice
#

you'd have to call it in a command

#

or on_ready

#

or a task that's waiting till it's ready

young flower
devout iris
young flower
#

or wait is it a cog?

heady sluice
#

you don't need an async function

#

for a function that doesn't have any asyncio in it

heady sluice
#

or in a command

heady sluice
#

in a cog

devout iris
carmine hearth
#

from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw

vale wing
# devout iris

Um are you even allowed to use those symbols in variables names

heady sluice
#

I usually don't recommend doing things in on_ready, but as long as you don't send a message or make an API call it's fine

carmine hearth
young flower
#

any unicode thing works

carmine hearth
#

from PIL import Image, ImageFont, ImageDraw

robust fulcrum
vale wing
#

😩

carmine hearth
#

from PIL import Image, ImageFont, ImageDraw

warped mirage
#

guys

devout iris
carmine hearth
robust fulcrum
#

Guys anyone know a cool library that i can use in my discord bot?

warped mirage
#

so i updated to 2.0 , my py v is Python 3.10.2 what now

vale wing
#

Pretty sure it's recommended to use english in your code tho

warped mirage
#

someone help me

carmine hearth
heady sluice
#

bad code

robust fulcrum
#

Ye

#

He should have first randint and round off

young flower
warped mirage
#

@slate swan wanna help me while hunter is afk

carmine hearth
young flower
#

in the main file

#

not a cog

robust fulcrum
carmine hearth
#

def pingg():
return int(bot.latency*1000)

heady sluice
#

but you don't return in a command

heady sluice
carmine hearth
robust fulcrum
#

I'll add it then

vale wing
warped mirage
#

can someone who has 2.0 of dpy help me please

vale wing
#

Commands callbacks have corresponding decorators

carmine hearth
heady sluice
#

return int(bot.latency*1000)

vale wing
#

Returns bot's latency multiplied by 1000 with removed float part

heady sluice
carmine hearth
warped mirage
vale wing
#

Why is it pingg and not ping tho

heady sluice
#

why would you uninstall discord

warped mirage
vale wing
#

And yeah why use function for such a simple calculation

heady sluice
vale wing
#

Flooding namespace

warped mirage
#

hunter told me to

carmine hearth
devout iris
heady sluice
#

how do you ping hunter

#

@maiden fable wat

carmine hearth
vale wing
#

Wtf discord

devout iris
heady sluice
#

pip install -U git+https://github.com/Rapptz/discord.py to install 2.0

#

I copied this from a message where Ashley told u how to install 2.0

carmine hearth
heady sluice
devout iris
#

Ah okay then, you can exactly use

warped mirage
#

i had to uninstall discord , slash commands

carmine hearth
#

i made this:

heady sluice
#

I don't think you had to

carmine hearth
#

and this:

#

@bot.command(pass_context=False)
async def botping(ctx):
#Π’Ρ‹Π²ΠΎΠ΄ Π·Π°Π΄Π΅Ρ€ΠΆΠΊΠΈ Π² Ρ‡Π°Ρ‚
await ctx.send('Пинг: {0}'.format(bot.latency))

heady sluice
#

remove pass_context=False already

carmine hearth
heady sluice
#

cuz it makes no sense

carmine hearth
#

ok

vale wing
#

Why str.format like f-strings exist

heady sluice
#

and f-strings are great
await ctx.send(f'Пинг: {bot.latency}')

vale wing
maiden fable
heady sluice
#

why does he have to uninstall discord

maiden fable
regal pulsar
maiden fable
heady sluice
vale wing
#

Russian

heady sluice
#

well I made sure I don't sound american

vale wing
#

Lol ok

vale wing
maiden fable
#

That's not discord 🀣

heady sluice
#

makes sense

maiden fable
#

The profile picture

heady sluice
#

why would you even get an e-mail from discord

#

that someone messaged you

maiden fable
#

Tbh won't be surprised if ppl fall for it

vale wing
heady sluice
#

you can send e-mails from others' mails

maiden fable
#

Really?

heady sluice
#

my friend asked me what my e-mail is then sent me a mail from my e-mail

#

weird dude

vale wing
#

Maybe with unprotected protocol you can

carmine hearth
#

мяу

vale wing
#

Ok comrade

heady sluice
vocal plover
carmine hearth
#

@vale wing ΠΊΠ°ΠΊ ΡΠ΄Π΅Π»Π°Ρ‚ΡŒ Ρ‚Π°ΠΊ Ρ‡Ρ‚ΠΎΠ±Ρ‹ Π±ΠΎΡ‚ писал Ρ‚Π²ΠΎΠΉ ΠΏΠΈΠ½Π³?

vale wing
#

Go to my DMs cuz speaking foreign languages is prohibited here

carmine hearth
#

ok

jade tartan
halcyon onyx
slate swan
robust fulcrum
#

Guys how can we make that
If there is small price of image provided in a image ( short form:image recognisation) then bot should send message
Which library should i use?

maiden fable
loud junco
#

my main.py is like 2120 lines already

#

should i make a file for every command

carmine hearth
#

how to make it so that when you write a command o!myping he writes my ping

loud junco
carmine hearth
#

nope

#

o!myping

loud junco
#

u write o!myping
then bot pings u?

carmine hearth
#

yes

loud junco
#

await ctx.mention(ctx.author) i think

#

nc

carmine hearth
#

ah oh

#

i understand

flint isle
#

i did it it got approved now disnake documentation can be viewed offline and downloaded ^w^

loud junco
carmine hearth
#

ok

loud junco
#

any source?

#

alright thanksss

#

mention

#

btw that wont help fix my situation tho

#

its also something like normal commands without cogs

#

its still gonna end up 2000 lines

#

its hard to edit sometimes

#

i want to decrease the line of my main.py

carmine hearth
#

when i write o!ping bot say pong!

loud junco
carmine hearth
#

it's a test command

loud junco
#
@bot.command(name='ping')
async def ping(ctx):
  await ctx.send(f"Pong! {round(bot.latency * 1000)}ms"
#

here is the whole goddamn command for u

#

🀣

carmine hearth
loud junco
#

... jesus christ

carmine hearth
#

what

loud junco
#

i wanna do something like

from Ping import ping
from Hunt import hunt
@bot.command(name='ping')
async ping(ctx)

@bot.command(name='hunt')
async hunt(ctx)
#

will this work?

heady sluice
#

def 😭

loud junco
#

can i do one command one file?

#

more accessable and managable

loud junco
#

so i dont need cogs to do that =.=

loud junco
#

alright 🀣

#

i will wait for ashley sarth and hunter to help me

#

cuz i dont understand the doc =.=

slate swan
# maiden fable Huh? No?

yes, thats when you don't use discord for a considerable amount of time and didn't sign off from notifications

loud junco
#

:D

#

thats what im about to do

#

🀣

slate swan
#

you want to import commands from another file?

loud junco
#

ya

#

πŸ’€

#

debugging on a 2k line file is starting to kill me

#

i dont even understand what is it talking about

slate swan
#
#other.py

from discord.ext import commands

@commands.command()
async def foo(context):
   ...
#bot.py

from discord.ext import commands

from other import foo

bot = commands.Bot(**kwargs)
bot.add_command(foo)

bot.run()
``` πŸ™ƒ essentially what cogs do
loud junco
#

😭

carmine hearth
#

what is this

loud junco
#

but what is kwargs i see this thing a lot but idk what is that

slate swan
carmine hearth
#

i'll use it

slate swan
unkempt canyonBOT
#

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

{'hello': '1', 'world': '2'}
carmine hearth
#

can i use this?

slate swan
#

though, cogs do the same L.

carmine hearth
#

ok

#

how to make slash-commands???

slate swan
#

out of interest,what's the point of having an init dunder which does nothing πŸ˜”. or did you just remove that part of the code

slate swan
#

oh, thought so

warped mirage
#

Guys I updated to 2.0

#

Can people help me fix all my code

loud junco
warped mirage
#

I was told to uninstall discord and slash commands

#

So idk what to put

warped mirage
loud junco
warped mirage
#

Why rip

#

Hunter told me to

loud junco
#

pip uninstall discord?

warped mirage
#

Yes

loud junco
#

but why

slate swan
#

if you were using discord-py-slash-comamnds, I'd do the same.

warped mirage
#

My py version is 3.10.2

loud junco
#

what for

warped mirage
#

So what do I do now

slate swan
#

And yes discord.py 1.7.3 has issues with building aiohttp wheels in py 3.10

warped mirage
#

So is it good that I changed

slate swan
#

what did you change to

warped mirage
#

2.0

#

Of dpy

#

So how do I import discord and stuff now if it doesn’t work

slate swan
#

yes, thats better
and you would be using that in future anyways, so why not now

vale wing
#

One question about dpy docs: I noticed that it is no longer /master/ in the URL but /latest/, did they make a release to pypi or smth

warped mirage
#

So shall I pip install discord again

#

So this stays the same ?

slate swan
#

i was just about to ask where did the master branch go lol

warped mirage
#

Do the intents and like commands.Bot all this is the same

#

Or nah

unkempt canyonBOT
warped mirage
#

Oh ok

vale wing
#

Ok cool

warped mirage
#

How do I import / download slash commands

vale wing
#

Well it's a mirror

unkempt canyonBOT
vale wing
#

Nvm it's the same

slate swan
#

I have a question and it may be really dumb so I will say sorry in advance.

@bot.event
async def on_message(message):
    if message.reference is not None:
        da_msg = await fetch_message(message.reference.message_id)
        if da_msg.author == bot.user:
            message.channel.send("Someone replied to me?")β€Š
```I'm trying to make the bot say something when a user references any of the bot's message but for some reason, my IDE says that fetch_message is not defined? I really don't know what to do now lol.
warped mirage
#

Your event loop is closed

vale wing
#

Lul

warped mirage
#

Check ur code

slate swan
#

here we go

loud junco
vale wing
#

Does this happen on bot shutdown

warped mirage
#

Guys when I’m back can someone help me fix my code lol

slate swan
#

is that your Full traceback?

vale wing
#

Weird

slate swan
vale wing
#

I think there should be another part

warped mirage
unkempt canyonBOT
#

Hey @slate swan!

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

vale wing
#

It can't close just created loop if there are no errors

#

Ah yes

#

@slate swan man why would you put "my token" literally

#

You need to put your bot's token

slate swan
vale wing
#

And for god's sake don't copypaste code if you do