#discord-bots

1 messages ยท Page 1041 of 1

slate swan
#

but

frozen patio
slate swan
frozen patio
slate swan
#

those emojis

#

on names

frozen patio
#

I finally got C++ build tools to download

#

Now I can compile things

slate swan
#

๐Ÿ‘€

frozen patio
#

I made many more things in Python now ๐Ÿ˜…

frozen patio
#

I learned how to add HTML, CSS, JS, TS, and Python together using Django

#

Then a flask API

boreal ravine
#

Ah... chat is active, best time to leave ๐Ÿšถโ€โ™‚๏ธ

frozen patio
slate swan
#

hard for me

frozen patio
#

It is

frozen patio
#

I ignore that fact that I typed 15k lines of CSS

slate swan
#

using css is harder than learning it imo

#

ye i mean using tho

frozen patio
#

for the user interface and the administration panel

slate swan
frozen patio
#

Yeah

#

It took me a month to do it

west mango
#

Thank you! So to clarify in this case, each event would be defined in separate cogs right? For example I just wrote this up for this:

class TestMessage(commands.Cog): #  declaring the cog
  def __init__(self, bot):
    self.client = bot
  
  @commands.Cog.listener() 
  async def on_message(self, message): #probably shouldnt use 'on_message' in a cog huh?
    if message.content.lower().startswith('hi'):
           await message.channel.send('hello')
def setup(bot): 
  bot.add_cog(TestMessage(bot))

If im understanding correctly, I create a cog for each message cog listener, then just load all of them in the main file and the conditions defined within each separate cog would determine whether it gets executed, yeah?

supple thorn
west mango
frozen patio
boreal ravine
#

I prefer to keep them inside a file called "listeners"

supple thorn
west mango
slate swan
supple thorn
#

Since you're using bot

west mango
#

you ever ask a question and then the answer is so obvious it hurts your soul?

supple thorn
#

Yes

west mango
#

same, thanks for the help

frozen patio
west mango
keen mural
#

How would i make it so only the author of the cmd can press the button

slate swan
frozen patio
#

there is like 10 in each

slate swan
#

what the

frozen patio
slate swan
#

frick

west mango
#

yikes

frozen patio
west mango
frozen patio
#

You should look at my JS files

slate swan
#

i seen something weird when i was scrolling

slate swan
frozen patio
#

7.6k lines of CSS

slate swan
#

RIP

frozen patio
#

?

slate swan
#

its a pain

frozen patio
boreal ravine
frozen patio
#

I also hate JS

slate swan
#

lmaoo

west mango
slate swan
#

cool then :D

slate swan
#

!pip javascript ๐Ÿ˜ณ

unkempt canyonBOT
slate swan
#

PyScript is cool but I definitely don't see its relevance

frozen patio
west mango
#

Sorry guys last question, so if I name a bunch of listeners in one cog file for listeners (including multiple message listeners), would they ideally be separated into different classes?

slate swan
#

That's no reason to hate JS

#

It's minified JS, I wonder why you're even opening it

frozen patio
slate swan
#

wow code in 1 line

slate swan
slate swan
frozen patio
slate swan
#

Do you not have source maps?

frozen patio
#

I coded it from scratch

slate swan
slate swan
boreal ravine
slate swan
west mango
frozen patio
frozen patio
slate swan
slate swan
west mango
#

appreciate your folks' help. Its humbling as a senior data monkey to have no idea what im doing again

frozen patio
#

You're not the one who typed all that

slate swan
#

...?

frozen patio
#

Ok

frozen patio
keen mural
#

ephemeral

slate swan
#

ye

keen mural
#

what if i dont want it ephemeral tho

#

is there a way

slate swan
#

then u pass the id

keen mural
#

how do i make the id the command author's id

#

ctx wouldnt be defined since its not a command

slate swan
#

you can pass the context to your view class and check that

#

yes

slate swan
#

like

#

View(ctx)

#

like

keen mural
#
class Game(discord.ui.View):
    def __init__(self):
        super().__init__()
        self.value = None


    @discord.ui.button(label=' ',style=discord.ButtonStyle.grey, row=0, disabled=True)
    async def Nothing1(self, interaction: discord.Interaction, button: discord.ui.Button):
      self.value = True


    @discord.ui.button(label='Up', style=discord.ButtonStyle.green, row=0)
    async def Up(self, interaction: discord.Interaction, button: discord.ui.Button):
        #await interaction.response.send_message('Confirming', ephemeral=True)
        moveUp()
        embedVar=getNormalEmbededData(title="Pick Apple Game", description="{}".format(getGameGrid()))
        embedVar.add_field(name="Your Score", value=points, inline=True)
        await interaction.response.edit_message(embed=embedVar)
        self.value = True



@client.command()
async def game(ctx: commands.Context):
    reset()
    """Asks the user a question to confirm something."""
    # We create the view and assign it to a variable so we can wait for it later.
    view = Game()
    msg = await ctx.reply('Lets play a game', view=view)
    # Wait for the View to stop listening for input...
    await view.wait()
    if view.value is None:
        print('Timed out...')
    elif view.value:
      return
    else:
        print('Cancelled...')```
#

there is some

slate swan
#

alr

#
class MyView(ui.View):
  def __init__(self, context: commands.Context):
    self.command_ctx = context
    super().__init__()

  async def interaction_check(self, inter):
    if inter.user.id == self.command_ctx.author.id: # stuff```
#

yes

#

like that

#

for initialising the view you would have to pass a context in it

#

discord code blocks are trash when high width

light violet
#
select = Select(options = [
     disnake.SelectOption[
       label ="Help Base 2",emoji="",description ="Shows Second Help Embed",
       
       
       ],```
slate swan
#

๐Ÿ—ฟ no, use pep8 to not exceed word limits per line

light violet
#

how is this invalid syntax

slate swan
#

SelectOption(...)

#

wrong brackets.

#

[ [ ] error

#

all the brackets are messed up

#

also why that comma

light violet
#

ok

slate swan
#

its fine to have an extra comma, also they may have more code below which they didnt send..

#

black formats stuff like that

light violet
#

still invalid syntax

#

ok

slate swan
#

read the traceback lol

#

no

#

just hover

light violet
slate swan
slate swan
slate swan
light violet
slate swan
light violet
slate swan
light violet
#

what should i do

slate swan
#

close )

light violet
light violet
slate swan
#

๐Ÿ˜” man ignored me like i dont even exist, anyways, youre using wrong brackets

#

bruh

#

it should be ( instead of [ for the SelectMenu

#

use views

#

best

keen mural
#

thx for the help guys!

slate swan
#

:D

slate swan
slate swan
slate swan
#

!ot

unkempt canyonBOT
slate swan
#

๐Ÿ’€

west mango
# slate swan with the second way I sent, you can have multiple listeners in same cog class

ok trying this out now, are there different ways for the bot to reference itself when using cogs?

from discord.ext import commands

class TestMessage(commands.Cog): #  declaring the cog
  def __init__(self, bot):
    self.bot = bot
  
  @commands.Cog.listener() 
  async def on_message(self, msg):
    if msg.content.lower().startswith('hi'):
           await msg.channel.send('hello')

  @commands.Cog.listener() 
  async def self_message(self, msg):
    if msg.author == bot.user:                 #Linter warning = "undefined name 'bot'"
           await msg.add_reaction("๐Ÿ’–")
def setup(bot): 
  bot.add_cog(TestMessage(bot))

message.author == bot.user doesnt seem to work like it does outside without cogs since I use this same syntax in multiple other live bots.

slate swan
#

self.bot

slate swan
slate swan
west mango
#

oh god

slate swan
#

lis got pinged

#

lol

#

good for them ig ๐Ÿ˜‚ ?

#

inside lis

#

tener

#

ye

#

interesting

slate swan
#

sarth alts

west mango
#

Im on a roll with bad questions tonight. I keep expecting my issues to be due to some new parts of the library that I havent handled but theyre consistently just me making dumb mistakes and thinking its something new

slate swan
west mango
#

thanks for the help

slate swan
#

๐Ÿ‘€

slate swan
#

atleast you understand what you are doing :p

west mango
#

debatable but I appreciate the sentiment lol.

slate swan
#

sarthak is such a lovely, kind person๐Ÿฅฐ

slate swan
#

sparky want a compliment lemon_glass

slate swan
slate swan
#

sparky is a nice cool person๐Ÿฅฐ

slate swan
unkempt canyonBOT
slate swan
#

SIKE

#

kali-ma-linux

#

xD

#

i give my love and you reject it smh๐Ÿ˜ก

#

can you both stop? or take this to an ot channel for real

#

ok

slate swan
#

that was just the ot channel name ๐Ÿ˜” ~

#

lol

slate swan
#

๐Ÿง > ๐ŸชŸ

#

lol

#

๐Ÿ˜ณ

#

okimii's the best at making weirded reactions

#

now stop

#

๐Ÿ—ฟ i have an exam in 50 minutes so guess i'll take a leave, cya guys

sick birch
#

hi

slate swan
#

robin i see youuu๐Ÿ‘๏ธ ๐Ÿ‘๏ธ

sick birch
#

i observe this chat

slate swan
#

robin wants a compliment๐Ÿ‚

sick birch
#

no i was actually about to tell you all to get back on topic

slate swan
#

but only sarthak can give it so bye byeshipit

sick birch
#

so consider that said

slate swan
#

robin mad he got no compliment anyway back on topic

sick birch
#

yes please

slate swan
#

.topic

lament depotBOT
#
**What's one feature you wish more developers had in their bots?**

Suggest more topics here!

slate swan
#

boring .........24

sick birch
# lament depot

Is having basic things like not changing presence on_ready and not calling commands.Bot client considered a feature?

slate swan
#

๐Ÿ˜

slate swan
#

for the backend, we could say that.

slate swan
sick birch
#

but doesn't seem like many follow it unfortunately

slate swan
#

bad yt tutorials.

slate swan
#

..

slate swan
# lament depot

better error handling i guess, i have seen bots which dont even respond with what problem was there with the invocation of the commands

spring verge
#

so I have been getting some images through an api but they are super low quality.. any python lib uk of which upscales the resolution and doesnt take time?

slate swan
# lament depot

buttons so they can leave behind reactions and their 2/1s iirc ratelimit

slate swan
#

i dont have error handlers

slate swan
spring verge
#

read this ^

slate swan
#

thats yet another thing, and it fails the "doesnt take time" part.

spring verge
#

otherwise I already know about opencv lib etc..

#

ig its not yet possible for both the options (less time and upscaling) hmm

#

thx for the help

slate swan
spring verge
#

wish discord allowed us to customize image sizes :c

#

atleast I would have picked a fixed size for thumbnail so it didnt look very small on phone

slate swan
#

resize*

spring verge
#

even if its a good resolution discord wont increase its size

slate swan
spring verge
#

I mean thats why I said "wish"

maiden fable
#

@spring verge use an image api

west mango
maiden fable
spring verge
#

thx for the suggestion

slate swan
west mango
#

so it should also just be normal on_message

slate swan
#

you need to pass "on_message" in the @listener decorator for that to work

#
@commands.Cog.listener("on_message")
async def cog_message(....
west mango
#

oh... quotes....

slate swan
#

๐Ÿ‘

west mango
slate swan
# west mango oh so this keeps it from redefining the same event

you can have seperate functions for the same events to keep your code organized if you like

@commands.Cog.listener("on_message")
async def message_one(...): ...

@commands.Cog.listener("on_message")
async def message_two(...): ...

both of them will get triggered when a message is sent

west mango
# slate swan you can have seperate functions for the same events to keep your code organized ...

just tried this and now both arent executed ๐Ÿ˜ฎ

from discord.ext import commands

class TestMessage(commands.Cog): #  declaring the cog
  def __init__(self, bot):
    self.bot = bot
  
  @commands.Cog.listener("on_message") 
  async def user_message(self, msg):
    if msg.content.lower().startswith('hi'):
           await msg.channel.send('hello')

  @commands.Cog.listener("on_message") 
  async def meta_message(self, msg):
    emoji = '\N{THUMBS UP SIGN}'
    if msg.author == self.bot:
           await msg.add_reaction(emoji)
def setup(bot): 
  bot.add_cog(TestMessage(bot)
slate swan
#

weird

west mango
#

ok so that was my bad, now its just the second. Maybe Im just doing emoji referencing wrong

#

just the second not working*

#

its something to do with if msg.author == self.bot:

slate swan
west mango
#

got it

#

yeah just noticed that, thanks

daring olive
#

re-posting the final message from #965291445999239258:

alrighty, that's a wrap! ๐Ÿ‘๐Ÿป
this thread will be closed

the proposal for a library discussion thread was made, but i didn't see too much interest or desire for the idea, so we'll leave it at 2 threads for now (#965291480992321536 and #965291516031549500)

if you strongly disagree, or have any future ideas for a thread, come and make your case in #community-meta!

nimble plume
#

ok

light violet
#

cant i run another command like
async def button_callback(interaction):
ck(ctx)

light violet
#

coroutine 'Command.call' was never awaited
ck(ctx)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
172.18.0.1 - - [13/May/2022 04:00:36] "GET / HTTP/1.1" 200 -

#

getting this error@nimble plume

#

fgl

maiden fable
#

U forgot await

#

somewhere

light violet
#

ok ok

nimble plume
#

also dont use replit

nimble plume
#

late bro

vale wing
#

Wtf for

nimble plume
#

help

vale wing
#

With

nimble plume
#

! !

#

~ i ~

#

! !

vale wing
#

Calling a command is not a good idea just saying

vale wing
#

Command is supposed to be a command and not a callable

nimble plume
#

im guessing thats not a command

vale wing
#

The code that should be executed may be brought out to the separated module

vale wing
#

Command.__call__

#

Basically invoking a command

nimble plume
#

ok

#

dont call commands

#

@light violet

vale wing
#

They share attributes but are not the same

#

Yk

#

So as I said, bring the code that should be executed from several places to one module and import it from there

light violet
#

File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
return await self.run_in_executor(
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/nix/store/p21fdyxqb3yqflpim7g8s1mymgpnqiv7-python3-3.8.12/lib/python3.8/socket.py", line 918, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
172.18.0.1 - - [13/May/2022 04:22:30] "HEAD / HTTP/1.1" 200 -

pls tell me an easy solution to call it

light violet
#

then? what should i do

keen mural
honest laurel
keen mural
last cedar
#
import discord
import os 
from discord.ext import commands


TOKEN = 'token'

bot = commands.Bot(command_prefix='!!')
client = discord.Client()

print('Running........')

@client.event
async def on_ready():
  print('We have logged in as {0.user}'.format(client))


# some codes


bot.run('token')
#

bot is online

#

but commands dont work and it doesn print we have logged in as....

#

can anyone help?

honest laurel
#

@last cedar Remove client, use bot instead

import discord
import os 
from discord.ext import commands


TOKEN = 'token'

bot = commands.Bot(command_prefix='!!')

print('Running........')

@bot.event
async def on_ready():
  print('We have logged in as {0.user}'.format(bot))

# some codes

bot.run('token')
last cedar
#

i was about to switch to discord.js

vale wing
#

Useless TOKEN variable

slate swan
#
@client.event
async def on_message_delete(message):
     snipe_message_author[message.channel.id] = message.author
     snipe_message_content[message.channel.id] = message.content
     await sleep(60)
     del snipe_message_author[message.channel.id]
     del snipe_message_content[message.channel.id]
``` correct?
olive osprey
supple thorn
#

!d asyncio.sleep

unkempt canyonBOT
#

coroutine asyncio.sleep(delay, result=None)```
Block for *delay* seconds.

If *result* is provided, it is returned to the caller when the coroutine completes.

`sleep()` always suspends the current task, allowing other tasks to run.

Setting the delay to 0 provides an optimized path to allow other tasks to run. This can be used by long-running functions to avoid blocking the event loop for the full duration of the function call.

Deprecated since version 3.8, removed in version 3.10: The `loop` parameter. This function has been implicitly getting the current running loop since 3.7. See [Whatโ€™s New in 3.10โ€™s Removed section](https://docs.python.org/3/whatsnew/3.10.html#whatsnew310-removed) for more information.

Example of coroutine displaying the current date every second for 5 seconds:
supple thorn
#

Use this so it won't freeze your bot

slate swan
#

await asyncio.sleep(60) this is correct?

supple thorn
slate swan
#

thx

supple thorn
#

Maybe only the ip value is there?

#

You did put it in a if statement

slate swan
#

hmm

slate swan
#
Kiff connected!
Ignoring exception in command hello:
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 855, in invoke
    await self.prepare(ctx)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 789, in prepare
    await self._parse_arguments(ctx)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.```
#

=/

slate swan
slate swan
# slate swan ???

for example

@Command
async def cmd(ctx, member): ...

#when *running* the command on discord

<prefix>cmd <member>

# if you dont provide the member argument, it'll raise that error
#

oh, sorry

#

thx

slate swan
#

how to make the bot status "stream"?

heavy folio
#

!d discord.Streaming

unkempt canyonBOT
#

class discord.Streaming(*, name, url, **extra)```
A slimmed down version of [`Activity`](https://discordpy.readthedocs.io/en/master/api.html#discord.Activity "discord.Activity") that represents a Discord streaming status.

This is typically displayed via **Streaming** on the official Discord client...
west mango
#

successfully moved 800 lines of code to cogs (first time using) and everything is finally working and so much cleaner

#

anyone know if its possible to have a pin-message button?

maiden fable
#

Or that, yea
change_presence(activity=discord.Streaming(...))

tropic burrow
#

so when messages are cleared by my bot, i want it to say py "I have cleared",amount,"messages for you" but i get this error await ctx.channel.send("I have deleted",amount,"messages for you.") TypeError: Messageable.send() takes from 1 to 2 positional arguments but 4 were given

#

how to fix this

elfin island
#

use an f-string or other forms of string interpolation

#

!e

amount = 10
print(f"I have cleared {amount} messages for you")
unkempt canyonBOT
#

@elfin island :white_check_mark: Your eval job has completed with return code 0.

I have cleared 10 messages for you
tropic burrow
#

k

#

thx

#

so i want a joke command my code is

import os
import requests
from dotenv import load_dotenv
import random
from discord.ext import commands
from discord.ext.commands import has_permissions, MissingPermissions

client = commands.Bot(command_prefix = "Pyramid: ")

def get_joke():
            r = requests.get("https://v2.jokeapi.dev/joke/Miscellaneous,Dark,Spooky?blacklistFlags=racist&type=twopart")
            json_data = r.json()
            if json_data["type"] == "single":
                return json_data["joke"]
            elif json_data["type"] == "twopart":
                return "\n".join([json_data[x] for x in ["setup","delivery"]])
            else:
                return f"Sorry, I dont know how to tell a joke of type {json_data['type']}"

@client.event
async def on_ready():
    print("Bot is ready")

@client.command()
async def Joke(ctx,joke):
    joke = get_joke()
    ctx.channel.send(joke)

load_dotenv()

client.run(os.getenv('TOKEN'))

i get this transformed = await self.transform(ctx, param) File "C:\Users\n/a\AppData\Local\Programs\Python\Python310\lib\site-packages\nextcord\ext\commands\core.py", line 599, in transform raise MissingRequiredArgument(param) nextcord.ext.commands.errors.MissingRequiredArgument: joke is a required argument that is missing.

placid skiff
#

joke is not an argument that the command caster would send, remove it from the args

tropic burrow
#

how

slate swan
#
๎บง python3 main.py
Traceback (most recent call last):
  File "main.py", line 14, in <module>
    import clean_code
ModuleNotFoundError: No module named 'clean_code'
placid skiff
#

....

#

just remove joke from Joke()

tropic burrow
#

k

silver wolf
#

How many slash commands can a single bot have?

placid skiff
placid skiff
slate swan
#

!import clean_code

unkempt canyonBOT
#

Star / Wildcard imports

Wildcard imports are import statements in the form from <module_name> import *. What imports like these do is that they import everything [1] from the module into the current module's namespace [2]. This allows you to use names defined in the imported module without prefixing the module's name.

Example:

>>> from math import *
>>> sin(pi / 2)
1.0

This is discouraged, for various reasons:

Example:

>>> from custom_sin import sin
>>> from math import *
>>> sin(pi / 2)  # uses sin from math rather than your custom sin

โ€ข Potential namespace collision. Names defined from a previous import might get shadowed by a wildcard import.
โ€ข Causes ambiguity. From the example, it is unclear which sin function is actually being used. From the Zen of Python [3]: Explicit is better than implicit.
โ€ข Makes import order significant, which they shouldn't. Certain IDE's sort import functionality may end up breaking code due to namespace collision.

How should you import?

โ€ข Import the module under the module's namespace (Only import the name of the module, and names defined in the module can be used by prefixing the module's name)

>>> import math
>>> math.sin(math.pi / 2)

โ€ข Explicitly import certain names from the module

>>> from math import sin, pi
>>> sin(pi / 2)

Conclusion: Namespaces are one honking great idea -- let's do more of those! [3]

[1] If the module defines the variable __all__, the names defined in __all__ will get imported by the wildcard import, otherwise all the names in the module get imported (except for names with a leading underscore)
[2] Namespaces and scopes
[3] Zen of Python

tropic burrow
placid skiff
#

you have to remove joke from the argument of the command function and stop

#

you will get your joke from your api

placid skiff
#

!e

def foo():
  return "ok"

def uwu():
  message = foo()
  print(message)
tropic burrow
#

perform uwu?

placid skiff
#

!e

def foo():
  return "ok"

def uwu():
  message = foo()
  print(message)

def bar(message):
  message = foo()
  print(message)

uwu()
bar()
unkempt canyonBOT
#

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

001 | ok
002 | Traceback (most recent call last):
003 |   File "<string>", line 13, in <module>
004 | TypeError: bar() missing 1 required positional argument: 'message'
placid skiff
#

as you see it gets the error on bar because it takes message as argument but i give no message in input of the function

tropic burrow
#

joke is not argument

fleet sand
#

This worked a month ago, but now it doesn't. Where did I go wrong?

@bot.command(name = "announce")
@commands.has_role("bot bot")
async def announce(ctx, role: discord.Role, *, message):
    channel = bot.get_channel(something something)
    embed = discord.Embed(
    title = f"Announcement",
    description = f"Announcement for {role.mention},\n\n{message}",
    color = 0xFFFF00,
    timestamp = datetime.utcnow())
    embed.set_footer(text = f"{ctx.message.author.user.name}")
    await ctx.message.delete()
    await channel.send(embed = embed)
@announce.error
async def announce_error(ctx, error):
    if isinstance(error, commands.MissingRole):
        await ctx.message.delete()
        await ctx.send("You don't have permission to use this command!", delete_after = 3)
tropic burrow
cloud dawn
fleet sand
slate swan
#

add else: raise error at the end of your error handler

fleet sand
tropic burrow
# cloud dawn Yeah prob because you awaited those.

how to await it then code:

def get_joke():
            r = requests.get("https://v2.jokeapi.dev/joke/Miscellaneous,Dark,Spooky?blacklistFlags=racist&type=twopart")
            json_data = r.json()
            if json_data["type"] == "single":
                return json_data["joke"]
            elif json_data["type"] == "twopart":
                return "\n".join([json_data[x] for x in ["setup","delivery"]])
            else:
                return f"Sorry, I dont know how to tell a joke of type {json_data['type']}"

@client.command()
async def Joke(ctx):
    joke = get_joke()
    ctx.channel.send(joke)
slate swan
#

should be ctx.author.name

fleet sand
#

Eh?

#

Aight, lemme change that

#

@slate swan it works, man! Thanks!

#

But I wonder why this code works back then

#

But now it doesn't

last cedar
#

guys what is ctx

#

lot of ppl use ctx.send

cloud dawn
unkempt canyonBOT
#
class discord.ext.commands.Context(*, message, bot, view, args=..., kwargs=..., prefix=None, command=None, invoked_with=None, invoked_parents=..., invoked_subcommand=None, ...)```
Represents the context in which a command is being invoked under.

This class contains a lot of meta data to help you understand more about
the invocation context. This class is not created manually and is instead
passed around to commands as the first parameter.

This class implements the [`Messageable`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Messageable "discord.abc.Messageable") ABC.
cloud dawn
#

ctx.send is just a shorthand for ctx.channel.send, it has been shortened because if you do .send on the context you can only really have one destination. That being the response.

last cedar
#

like how does this work

#

there is no if messag ==

last cedar
cloud dawn
last cedar
#

for example $membercount

fleet sand
#

How to make discord.Role case insensitive?
Like announce testrole message but the mentioned role is Testrole

@bot.command(name = "announce")
@commands.has_role("bot bot")
async def announce(ctx, role: discord.Role, *, message):
    channel = bot.get_channel(something something)
    embed = discord.Embed(
    title = f"Announcement",
    description = f"Announcement for {role.mention},\n\n{message}",
    color = 0xFFFF00,
    timestamp = datetime.utcnow())
    embed.set_footer(text = f"{ctx.message.author.name}")
    await ctx.message.delete()
    await channel.send(embed = embed)
@announce.error
async def announce_error(ctx, error):
    if isinstance(error, commands.MissingRole):
        await ctx.message.delete()
        await ctx.send("You don't have permission to use this command!", delete_after = 3)โ€Š
    else:
        raise error
last cedar
#

to membercount?

cloud dawn
last cedar
cloud dawn
last cedar
#

oh ok ty

cloud dawn
#

That's automatically added.

cloud dawn
placid skiff
fleet sand
#

Better to change the role, right?

cloud dawn
#

It's best to just not have role as an argument.

placid skiff
#

not totally, I always create custom checks for roles so i can extract the role from database so my bot would have dynamic role checks

fleet sand
#

The role is a must for this announcement, there are 5 groups in the server

tropic burrow
#
@client.command()
@has_permissions(kick_members=True)
async def Kick(ctx, member : discord.Member)```
how to add a reason for this
cloud dawn
placid skiff
#

for example if I have roleplay bot with custom roles integration for every guild i want that some commands are accessible only for some roles, the builtin custom check isn't enough to check them dynamically so a custom check comes handy

fleet sand
placid skiff
cloud dawn
fleet sand
#

So no one will get a ping?

cloud dawn
#

Yep it just appears as a normal mention without a ping.

fleet sand
#

So the ping should be outside of embed?

cloud dawn
#

Yes.

fleet sand
#

Aight, thank you Panda and BlvckTvrsier

last cedar
#

the bot didnt respond

cloud dawn
last cedar
placid skiff
#

do you have intents?

last cedar
#

bot = commands.Bot(command_prefix='!!')

print('Running........')

@bot.event
async def on_ready():
  print('We have logged in as {0.user}'.format(bot))

slate swan
#

@client.event
async def on_message(msg):
  if msg.content == "<@bot_id>":
    await msg.reply(conent = "hello",mention_author=False)
  client.process_commands(msg)

``` this is correct?
cloud dawn
last cedar
#

ooh

placid skiff
slate swan
placid skiff
#

!d discord.ext.commands.when_mentioned_or

unkempt canyonBOT
#

discord.ext.commands.when_mentioned_or(*prefixes)```
A callable that implements when mentioned or other prefixes provided.

These are meant to be passed into the [`Bot.command_prefix`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

Example...
last cedar
cloud dawn
last cedar
#

no

slate swan
last cedar
#

maybe the imports are wrong

#

do i need seperate package for ctx thing

cloud dawn
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
#

the heck is conent?

last cedar
cloud dawn
#

Make sure to hide the token.

last cedar
# cloud dawn Make sure to hide the token.
import discord
import os 
from discord.ext import commands


TOKEN = 'DDDDDDDD'

bot = commands.Bot(command_prefix='$')

print('Running........')

@bot.event
async def on_ready():
  print('We have logged in as {0.user}'.format(bot))



@bot.event
async def on_message(message):
  if message.author == bot.user:
    return

@bot.command(name='membercount')
async def membercount(ctx):
    await ctx.send(ctx.guild.member_count)
    



bot.run('NDDDD)
slate swan
#

!intents

unkempt canyonBOT
#

Using intents in discord.py

Intents are a feature of Discord that tells the gateway exactly which events to send your bot. By default discord.py has all intents enabled except for Members, Message Content, and Presences. These are needed for features such as on_member events, to get access to message content, and to get members' statuses.

To enable one of these intents, you need to first go to the Discord developer portal, then to the bot page of your bot's application. Scroll down to the Privileged Gateway Intents section, then enable the intents that you need.

Next, in your bot you need to set the intents you want to connect with in the bot's constructor using the intents keyword argument, like this:

from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)

For more info about using intents, see the discord.py docs on intents, and for general information about them, see the Discord developer documentation on intents.

cloud dawn
#

Yep

last cedar
#
from discord import Intents
from discord.ext import commands

intents = Intents.default()
intents.members = True

bot = commands.Bot(command_prefix="!", intents=intents)
visual island
slate swan
#

that too, but member_count wont work without the intents anyways

visual island
#

Oh, for that, yeah, but for why the command didn't get invoked, the link above

slate swan
#

agreed

granite parcel
#

getting channel by id through discord.utils?

supple thorn
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
granite parcel
#

using client.get

supple thorn
#

Use the get_channel method

#

It gets the channel from the cache

granite parcel
#

i wanted to put the id through db

supple thorn
#

Which is faster then looping through all of the channels and checking itโ€™s id attribute

supple thorn
#

Just get the channel by the get_channel method

granite parcel
#
                cursor.execute(f"SELECT channel_id FROM logs WHERE guild_id = {ctx.guild.id}")
                chan = cursor.fetchone()```
#
channel = self.client.get_channel(id=chan[0])
                await channel.send(embed=embed)```
#

this won't work?

placid skiff
#

bruh you have the guild D_D

supple thorn
#

^

supple thorn
placid skiff
placid skiff
supple thorn
granite parcel
granite parcel
placid skiff
#

use ctx.guild.get_channel(id)

granite parcel
#
channel = ctx.guild.get_channel(chan[0])
await channel.send(embed=embed)```
#

Command raised an exception: AttributeError: 'NoneType' object has no attribute 'send'

#

i get this error

#

@placid skiff?

supple thorn
#

Try fetching it

granite parcel
#

what

granite parcel
supple thorn
granite parcel
#

then

supple thorn
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/master/api.html#discord.abc.GuildChannel "discord.abc.GuildChannel") or [`Thread`](https://discordpy.readthedocs.io/en/master/api.html#discord.Thread "discord.Thread") with the specified ID...
slate swan
#

Can i run two separate bots using

bot.run("TOKEN1")
bot.run("TOKEN2")
```?
tropic burrow
#

this code works but for some reason the person i unbanned does not show up in the server list is it a bug or problem in my code:

import discord
import os
import requests
from dotenv import load_dotenv
import random
from discord.ext import commands
from discord import Member
from discord.ext.commands import has_permissions, MissingPermissions

client = commands.Bot(command_prefix = "Pyramid: ")

@client.command()
@has_permissions(ban_members=True)
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"I have unbanned {user.mention}")



load_dotenv()

client.run(os.getenv('TOKEN'))
#

is it cause bot names are identical

visual island
#

The member/bot you've unbanned won't join automatically, you need to invite it again

slate swan
#

don't use lucas' unban code ๐Ÿ˜ฉ

visual island
slate swan
#
TypeError: Expected discord.Colour, int, or Embed.Empty but received method instead.        

This error comes when I try to assign a colour to an embed like this

embed = discord.Embed(colour=discord.Colour.green)
#

help wen

paper sluice
#

!d discord.Colour

unkempt canyonBOT
#

class discord.Colour(value)```
Represents a Discord role colour. This class is similar
to a (red, green, blue) [`tuple`](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.10)").

There is an alias for this called Color...
slate swan
paper sluice
#

so green()

slate swan
#

ohh

#

ok let me try

slate swan
slate swan
minor totem
slate swan
#

i didnt call it so it accepted it as a method

#

not a func

minor totem
#

Okay! Just wanted to know whether I should've explained it

slate swan
gilded gust
#

Hey, for some reason the on_member_join event isn't activating when a user joins. I have intents.members enabled.

placid skiff
#

code

gilded gust
#

which part do you need

placid skiff
#

the on_member_join event

gilded gust
#
    @commands.Cog.listener()
    async def on_member_join(self, member):
        print('member joined')
#

it's in a cog

boreal ravine
#

Was the cog loaded?

gilded gust
#

lemme check

paper sluice
#

!d discord.ext.commands.Cog.listener

unkempt canyonBOT
#

classmethod listener(name=...)```
A decorator that marks a function as a listener.

This is the cog equivalent of [`Bot.listen()`](https://discordpy.readthedocs.io/en/master/ext/commands/api.html#discord.ext.commands.Bot.listen "discord.ext.commands.Bot.listen").
gilded gust
#

for some reason no

boreal ravine
#

Then load it using the Bot.load_extension method

gilded gust
#

OMG

#

i see why it didn't work

#

I put the file in the wrong folder tfo_smh

boreal ravine
#

Why didn't it?

#

Rip

gilded gust
#

i didn't put it in the cog folder lol

gilded gust
jade tartan
#
Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\mod.py", line 206, in mute_command
    unmutes = await self.mute_members(ctx.message, targets, hours, reason)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\cogs\mod.py", line 166, in mute_members
    if not self.mute_role in target.roles:
AttributeError: 'Mod' object has no attribute 'mute_role'

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

Traceback (most recent call last):
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 343, in _run_event    
    await coro(*args, **kwargs)
  File "c:\Users\thoma\OneDrive\Desktop\discord server bot\Bot2.py", line 28, in on_command_error
    raise error
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\thoma\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Mod' object has no attribute 'mute_role'```
#

Someone plz

jade tartan
#

Yes does that mean it hasnt specified the role to give the user

potent spear
#

what's the error, tell me

jade tartan
potent spear
jade tartan
#

The role is not the highest in the chain in the server

potent spear
jade tartan
#

hold on a minute

jade tartan
#

tho

lyric apex
#

Can We Len Imports and Lines That Is In Bot

livid elk
#

how do i add the intents

#

Traceback (most recent call last):
File "main.py", line 5, in <module>
bot=commands.Bot(command_prefix="!")
TypeError: init() missing 1 required keyword-only argument: 'intents'

livid elk
#

ok

#

thanks

#

where do i add it in

#

after command_prefix?

#

intens=Intents.all()?

#

something like that

honest laurel
lyric apex
#
intents = discord.Intents.all()
bot=commands.Bot(command_prefix="!", intents=intents)```
honest laurel
#
bot = commands.Bot(
    command_prefix="!",
    intents=Intents.default(),
)
livid elk
#

ahh

#

ok

honest laurel
#

If you use keyworded arguments order shouldn't matter by the way

livid elk
#

ok

honest laurel
#
f(a=a, b=b)

Is the same as

f(b=b, a=a)
lyric apex
#

Yep but for understanding we do it so

livid elk
#

ok

slate swan
#

guys i'm using with open to create a file and the name of the file is a variable as well and i want it to be created as txt so how ?

slate swan
slate swan
pallid meadow
slate swan
slate swan
#

how to make a command of 2 words?

loud junco
slate swan
loud junco
#

make purge an argument?

tropic burrow
#

why does it not actually unban someone
(noone except for me and the bot is there)
my code is:

@client.command()
@has_permissions(ban_members=True)
async def Ban(ctx, member : discord.Member, *, reason=None):
    await member.ban(reason=reason)
    await ctx.channel.send(f"I have banned {member}")

@client.command()
@has_permissions(ban_members=True)
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"I have unbanned {user.mention}")



load_dotenv()

client.run(os.getenv('TOKEN'))
slate swan
#
@bot.command()
async def restock(ctx, category, stuff):
    attachment_url = ctx.message.attachments[0].url
    stuff = requests.get(attachment_url)
    print(stuff.content)
    with open(category + ".txt", "r+") as file:
        file.write(stuff + '\n')
        await ctx.send("added successfully!")```

discord.ext.commands.errors.MissingRequiredArgument: stuff is a required argument that is missing.
how can i make it count the file i requested from the message as a argument ?
tropic burrow
slate swan
tropic burrow
slate swan
tropic burrow
#

its an alt

sage otter
#

100% got that from Lucas

slate swan
loud junco
slate swan
slate swan
loud junco
slate swan
#

he inspired me to do shit in past but i honestly don't bother copying shit for no purpose

sage otter
loud junco
#

then how do u learn

slate swan
loud junco
slate swan
# loud junco then how do u learn

yeah i do learn from him and others and websites/etc how stuff work/syntax etc but i don't like to copy the exact same code i need and paste it

loud junco
slate swan
#

how to make time by type s, h?

sage otter
slate swan
#

s-second, h=hour

slate swan
tropic burrow
slate swan
#
  • i understand what the code does and how it works so i can use it for other uses in future
slate swan
loud junco
sage otter
#

I mean thatโ€™s the most precise and unique part of user identification

loud junco
sage otter
#

So when it comes down to moderation Iโ€™d consider using that.

loud junco
#

u can change anything except id

slate swan
loud junco
#

he wants the s, m, h, d thing

slate swan
loud junco
#

i forgot what is it call

slate swan
loud junco
#

sarth told me before

#

cuz i literally created a second -> h, m, s function

#

so he shows me

#

this one

#

found it

#

@slate swan

placid skiff
#

!d datetime.timedelta

loud junco
#

!d datetime.timedelta

unkempt canyonBOT
#

class datetime.timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)```
All arguments are optional and default to `0`. Arguments may be integers or floats, and may be positive or negative.

Only *days*, *seconds* and *microseconds* are stored internally. Arguments are converted to those units...
loud junco
#

@slate swan

slate swan
#

thx

loud junco
#

np

#

thank sarth ๐Ÿคฃ

#
@bot.event
async def on_command_error(ctx, error):
  if isinstance(error, commands.CommandOnCooldown):
    seccd = round(error.cooldown.get_retry_after())
    mincd = 0
    hrcd = 0
    rseccd = 0
    rmincd = 0

    if seccd > 59:  
      
      rseccd = int(seccd % 60)
      mincd = int((seccd - rseccd) / 60)
      if mincd > 59:
        rmincd = int(mincd % 60)
        hrcd = int((mincd - rmincd) / 60)
    else:
      rseccd = seccd
    await ctx.send(f'''
Dont spam :/ 
Try again in another **{hrcd}h {rmincd}m {rseccd}s**
''')
slate swan
tropic burrow
# sage otter Just by id

this better?

@client.command()
@has_permissions(ban_members=True)
async def Unban(ctx, id: discord.Member.id):
    banned_members = ctx.guild.bans()

    for ban_entry in banned_members:
        user = ban_entry.user

        if user.id == id:
            await ctx.send(f"I have unbanned {user}")
#

i just read the api and tried this

#

there might be mistake

#

and also i forgot

slate swan
#

lucas?

tropic burrow
slate swan
#

just wait for an int and get the user

tropic burrow
#

oh

slate swan
#

!d discord.ext.commands.Bot.get_user

unkempt canyonBOT
slate swan
#

!d discord.Guild.unban

unkempt canyonBOT
#

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

Unbans a user from the guild.

The user must meet the [`abc.Snowflake`](https://discordpy.readthedocs.io/en/master/api.html#discord.abc.Snowflake "discord.abc.Snowflake") abc.

You must have the [`ban_members`](https://discordpy.readthedocs.io/en/master/api.html#discord.Permissions.ban_members "discord.Permissions.ban_members") permission to
do this.
boreal ravine
#
await unban(Object(id=1234567))

Is fine.

slate swan
#

ew

#

Object Objectshipit

cloud dawn
unkempt canyonBOT
#

@cloud dawn :white_check_mark: Your eval job has completed with return code 0.

Try again in another **02h 39m 58s**
cloud dawn
light violet
#

how to call a async function with button callback with same context

slate swan
slate swan
#

๐Ÿคซ

light violet
#

help me pls

#

how to call a async function with button callback with same context

cloud dawn
maiden fable
#

Since it's gonna return None and the error is gonna be NoneType has no attribute id

light violet
#

pithink everybody ignoring me

stiff gorge
#

how to get a user status

gaunt ice
cloud dawn
tropic burrow
# slate swan !d discord.Guild.unban

is this better ```py
@client.command()
@has_permissions(ban_members=True)
async def Unban(ctx, id):
user = client.get_user(id=id)
await discord.Guild.unban(user=user)

slate swan
#

you would need to typehint id as an int and the unban coro needs to be an instance of the class Guild

#

and you should use or if the user isnt in cache and it returns none

light violet
#

@gaunt ice how do i call a async function with button callback with same contextpithink pithink

#

@cloud dawn pithink ok

gaunt ice
#

hmm

light violet
#

np

gaunt ice
#

what do u want to make

loud junco
loud junco
#

id: int

tropic burrow
#

wait do i use

ctx.guild.bans()
light violet
supple thorn
supple thorn
#

!d discord.ext.commands.Bot.get_user

unkempt canyonBOT
supple thorn
#

!d discord.ext.commands.Bot.fetch_user

unkempt canyonBOT
#

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

Retrieves a [`User`](https://discordpy.readthedocs.io/en/master/api.html#discord.User "discord.User") based on their ID.
You do not have to share any guilds with the user to get this information,
however many operations do require that you do...
supple thorn
#

Also positional

#

Only

tropic burrow
#

.

supple thorn
slate swan
#

Solved

slate swan
#
@bot.command()
async def restock(ctx, category):
    attachment_url = ctx.message.attachments[0].url
    swallo = requests.get(attachment_url)
    poggywoggy = str(swallo.content)
    print(poggywoggy)
    with open(category + ".txt", "r+") as file:
        file.write(poggywoggy + '\n')
        await ctx.send("added successfully!")```
livid elk
#

how do i use cogs

stiff gorge
#

how to get the server region ?

spring flax
slate swan
spring flax
unkempt canyonBOT
#
I'm sorry Dave, I'm afraid I can't do that.

No documentation found for the requested symbol.

spring flax
#

but why

spring flax
#

oh i'm looking at the stable docs nevermind

spring flax
#

!d aiohttp consider this instead

unkempt canyonBOT
#

Common data structures used by aiohttp internally...

stiff gorge
livid elk
#

SO COGS HOW DO I START

paper sluice
#

??

slate swan
unkempt canyonBOT
#
I don't think so.

No documentation found for the requested symbol.

slate swan
#

!d discord.ext.commands.Bot.load_extension

unkempt canyonBOT
#

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

Loads an extension.

An extension is a python module that contains commands, cogs, or
listeners...
regal pulsar
#

and the file has to have a setup function

#

cogs = [โ€œcog_file_nameโ€, โ€œcog_file_name2โ€]

heavy folio
#

what happens if i wanna annotate my arg to be a converter, but in the Converter i have some args i need to pass

regal pulsar
#

for cog in cogs:
bot.load_extension(cog)

#

what is giveaway_answers

#

@slate swan

#

what on earth is

#

try:
pass

#

lmao

#

use an error handler

#

@giveaway.error
async def on_giveaway_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
do this

#

also for the error

#

you arnt doing line 713 right

vale wing
#

Local handlers are cringe

regal pulsar
vale wing
#

Especially for this error

regal pulsar
#

true

vale wing
#

Make global one

slate swan
#

Try except ยฏ\_(ใƒ„)_/ยฏ

regal pulsar
#

but that is annoying

#

blocks every error

pure crypt
#

How can i check if a member join?

vale wing
slate swan
#

Ye use global for that

regal pulsar
unkempt canyonBOT
#

discord.on_member_join(member)``````py

discord.on_member_remove(member)```
Called when a [`Member`](https://discordpy.readthedocs.io/en/master/api.html#discord.Member "discord.Member") join or leaves a [`Guild`](https://discordpy.readthedocs.io/en/master/api.html#discord.Guild "discord.Guild").

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

Global

regal pulsar
#

well he could do

#

channel = None

slate swan
#

No

vale wing
#

It will raise literally everything if there's no situation

regal pulsar
#

then if channel == None raise error

slate swan
#

no

regal pulsar
#

or something

slate swan
#

What if multiple arguments

regal pulsar
#

what about it

vale wing
regal pulsar
#

im on my phone gimme a break ;/

slate swan
#

use a loop first

pure crypt
#

and how can i send a message in a specific chnnel?

slate swan
#

then break

#

Jk

slate swan
pure crypt
#

thanks

slate swan
#

On mobile

vale wing
#

Typical global handler looks like this

@commands.Cog.listener("")
async def on_command_error(ctx, error):
    if isinstance(error, commands.SomeError):
         # do action
    elif isinstance(error, commands.SomeOtherError):
        # do another action
    else:
         raise error```
regal pulsar
#
@bot.command()
async def avatar(ctx: commands.Context, member: disnake.Member = None):
    if member == None:
        member = ctx.author
    await ctx.channel.send(member.avatar_url)
#

like this

#

or something

vale wing
slate swan
regal pulsar
#

good idea

#

ah but it only works if member evals to false

#

if member is none then wont it still take it

slate swan
#

U can default it anything but

regal pulsar
#

hmm

slate swan
#

!e

def no(a = False):
  M = a or 1
  print(M)
no()
regal pulsar
#

!e

def no(a = False):
M = a or 1
print(M)
no()

unkempt canyonBOT
#

@regal pulsar :white_check_mark: Your eval job has completed with return code 0.

1
slate swan
#

I hate coding in mlbile

regal pulsar
#

ah

#

same ;/

slate swan
#

The autocorrecter sucks

#

If I close it it messes

regal pulsar
slate swan
#

!e

def no(a = False):
M = a or 1
print(M)
no(9)

unkempt canyonBOT
#

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

9
regal pulsar
#

yikes

slate swan
slate swan
regal pulsar
#

no

#

its great

#

its the best coding app ever

vale wing
#

I've once tried that thing, I had a feeling like it is for kids

#

No offense

regal pulsar
sick birch
#

Personally I donโ€™t agree with learning that way but everyone learns differently so thereโ€™s that

regal pulsar
slate swan
#

its explaining is so bad its like w3school

regal pulsar
#

its awful

slate swan
#

Use replit better

regal pulsar
regal pulsar
sick birch
vale wing
#

I don't have a constant resource I just google ๐Ÿ˜‰

regal pulsar
#

can anyone guess what project this is

slate swan
#

Use vscode online if u dont want to run and goto replit if u want to run

vale wing
slate swan
regal pulsar
#

but it has tkinter

sick birch
slate swan
#

Youtube_dl

sick birch
#

How did you even get tkinter to work alongside a discord bot? Threading?

regal pulsar
slate swan
#

..

regal pulsar
#

lol

slate swan
#

Maybe he's working on app like Spotify

#

But didcord

regal pulsar
#

hmm

slate swan
#

I hate typing

civic sun
livid elk
#

i hate talking to yo

regal pulsar
slate swan
regal pulsar
#

type pip install discord

slate swan
#

No

regal pulsar
slate swan
#

Install from github

regal pulsar
#

idr

regal pulsar
#

or something

civic sun
regal pulsar
#

it is

civic sun
#

alr

regal pulsar
#

or you could just use disnake

slate swan
#

I can barely see

regal pulsar
#

pip install disnake

slate swan
#

Why maximise cmd

civic sun
regal pulsar
#

๐Ÿ’€

civic sun
#

oh

slate swan
#

bruh

civic sun
#

so it's pip install discord?

regal pulsar
#

yeah

#

but disnake recommended

civic sun
#

What's that?

regal pulsar
torn sail
regal pulsar
#

basically the same thing but more features

slate swan
#

py -m pip install git+https://github.com/Rapptz/discord.py

civic sun
regal pulsar
#

since d.py got discontinued (temporarily)

civic sun
#

No?

regal pulsar
#

disnake is a good alternative

torn sail
civic sun
#

It recently got back

regal pulsar
#

i know ;-;

#

yeah i said temporarily

civic sun
#

Wait so what do I use?

regal pulsar
#

disnake

#

its really easy to switch back anyway

civic sun
regal pulsar
#

yes

regal pulsar
civic sun
#

I only came here to figure out what I was doing wrong

slate swan
#

lower administator

civic sun
#

Not for recommendations

regal pulsar
#

pip install discord then

torn sail
#

Spell administrator lowercase and correctly then yes

regal pulsar
slate swan
civic sun
regal pulsar
#

np

slate swan
slate swan
torn sail
#

Spelling

regal pulsar
#
for member in ctx.guild:
    await DMChannel.send(member, โ€œVery friendly messageโ€)
slate swan
#

administrator

torn sail
#

administrator

slate swan
#

Ye

#

administrator

regal pulsar
#

administrator*

#

np

slate swan
#

๐Ÿฅฒ

#

its okay, just spell administrator right before coming back with an error again ๐Ÿซ‚

regal pulsar
#

yes

#

now about my paymentโ€ฆ

loud junco
regal pulsar
sick birch
loud junco
#

lmao

slate swan
sick birch
#

we only take snail mail, fyi

regal pulsar
#

or you could be my discord kitten

#

thats fine too

slate swan
#

Can u show the imports

regal pulsar
#

imports please ;/

slate swan
loud junco
slate swan
regal pulsar
loud junco
#

imagine using pycord for bot

sick birch
regal pulsar
#

imagine not using discum

slate swan
regal pulsar
#

and yes its a thing

slate swan
sick birch
#

Don't know why they'd do that

regal pulsar
#

hmm ill help

#

but

#

can you meow for me

slate swan
#

New mentions in gamedevelopment

#

pycord supports both commands.Bot and disocrd.Bot the second one is nonsense though

regal pulsar
#

:)

placid skiff
#

Lol only know i discover that Py-script was announced

slate swan
#

@slate swan uninstall pycord and install it again

regal pulsar
#

๐Ÿซฅ

slate swan
#

im using a command to add seperated line text to a specific file but it adds with spaces how can i not allow it doing this ?

slate swan
slate swan
#

are you using writelines()

#

dunno then some lbrary did do discord.Bot

slate swan
#

i'll do now and try

#

show how you write in thr file

vale wing
#

How do you write those

slate swan
#
@bot.command()
async def restock(ctx, category):
    attachment_url = ctx.message.attachments[0].url
    swallo = requests.get(attachment_url)
    poggywoggy = (swallo.content)
    b = poggywoggy.decode("utf-8")
    print(b)
    with open(category + ".txt", "a") as file:
        file.write(b+'\n')
        await ctx.send("added successfully!")```
#

Back

regal pulsar
#
with open(โ€œfile.txtโ€, mode=โ€œwโ€, encoding=โ€œutf8โ€) as file:
    for line in lines:
        file.writelines(line)
slate swan
#

i tried writelines just now and it'll not work

slate swan
regal pulsar
#

idk

sick birch
regal pulsar
#

you dont

sick birch
#

What's the default?

slate swan
#

you can, but don't need to

#

read

regal pulsar
#

read and write i think

slate swan