#discord-bots

1 messages ยท Page 108 of 1

slate swan
#

Oh like that

#

message.author.id

#

You most likely have the message object where you're trying to get that information

slate swan
#

Name error message is not defined

#

Well, no code no help

#

ยฏ_(ใƒ„)_/ยฏ

slate swan
# slate swan Well, no code no help
@bot.command()
@has_permissions(administrator=True)
async def check(ctx, hashn=None, conf=None):
  if not hashn or not conf:
    await ctx.message.delete()
  else:
    y = time.time()
    mam = message.author.id
    mauthor = f("<@{mam}>")```
#

ctx.author.id in here

#

You also used it for getting the message object above

await ctx.message.delete()

You can access the author with ctx.author and then have access to lots of attributes and methods

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.

slate swan
#
import discord
import os
from discord import Intents
from discord.ext import commands

intents = Intents.default()


client = discord.Client(intents=intents)
my_secret = os.environ['TOKEN']

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

@client.event
async def on_message(message):
  if message.author == client.user:
    return
  if message.content.startwith("`hello"):
    await message.channel.send("Whats good!")

client.run(my_secret)
#

again using replit, this gave a really long error

#

Remove

bot = commands.Bot(command_prefix="`", intents=intents)
#

You never use that..

#

Remove

intents.members = True

as well

#

You don't need that either as you never use it either

slate swan
#

Look the code, they are using

client = discord.Client(intents=intents)

kryptonShrug

#

Yes using Bot is recommended, though they can at least get their bot running by removing unnecessary declarations and intents

slate swan
#

Well sorry but we are not interpreters so we can't guess your error..

#

soething to do with my TOKEN variable...

#

Again, that's very vague how about you give the actual error ._.

#

Though my supposition is that you haven't set the environment variable

#

yeah something about that

#

Take a look at that

#
#So i have a separate file that stores TOKEN, this is the code:

import discord
import os

client = discord.Client()
intents = Intents.default()

#the Intents.default() now has red squiggly line

client = discord.Client(intents=intents)
@client.event
async def on_ready():
  print("We have logged in as {0.user}".format(client))

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

  if message.content.startwith("!hello"):
    await message.channel.send("Whats good!")

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

#The SAMEerror:

Traceback (most recent call last):
  File "main.py", line 4, in <module>
    client = discord.Client()
TypeError: __init__() missing 1 required keyword-only argument: 'intents'

#

Maybe you can explain why you removed that

#

I just told you to specifically remove

intents.members = True
#

Never told you to remove

intents = Intents.default()
client = discord.Client(intents=intents)
#
#So i have a separate file that stores TOKEN, this is the code:

import discord
import os

client = discord.Client()
intents = Intents.default()

#the Intents.default() now has red squiggly line

client = discord.Client(intents=intents)
@client.event
async def on_ready():
  print("We have logged in as {0.user}".format(client))

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

  if message.content.startwith("!hello"):
    await message.channel.send("Whats good!")

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

#The SAME error:

Traceback (most recent call last):
  File "main.py", line 4, in <module>
    client = discord.Client()
TypeError: __init__() missing 1 required keyword-only argument: 'intents'

#

Stop declaring twice client=

#

Have it only once

#

what am i doing man

#

And you need to import the package accordingly, again

from discord import Intents
#

yess it worksss

#

for nowmost likely will come back later

#

i typed !hello

#
2022-10-17 13:12:41 ERROR    discord.client Ignoring exception in on_message
Traceback (most recent call last):
  File "/home/runner/Call-Of-Duty/venv/lib/python3.8/site-packages/discord/client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 17, in on_message
    if message.content.startwith("!hello"):
AttributeError: 'str' object has no attribute 'startwith'
#

!d str.startswith

unkempt canyonBOT
#

str.startswith(prefix[, start[, end]])```
Return `True` if string starts with the *prefix*, otherwise return `False`. *prefix* can also be a tuple of prefixes to look for. With optional *start*, test string beginning at that position. With optional *end*, stop comparing string at that position.
slate swan
#

uh

#

There's a difference between a, yours, and b

a. startwith
b. startswith
#

sigh

#

now no error, no reply

#

yess it replies

#

now to make a full on combat simulator since my friends want me too but ill get there soon

slate swan
#

Essentially the same, just replace the client = ... related line with

from discord.ext import commands

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

and then create commands with

@bot.command()
async def hello(ctx):
    await ctx.send("hello")
#

so all my @client.event becomes @bot.command()

#

You have only one, so you'll remove it and only use @bot.command()

#

And

@client.event
async def on_ready():
  ...

becomes

@bot.event # Only changes here
async def on_ready():
  ...
#

replaced all the client. to bot.

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

Well that still doesn't change, you need to pass intents=intents in the constructor all the time

#
import discord
import os
from discord import Intents

intents = Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
from discord.ext import commands

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

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

@bot.event
@bot.command()
async def hello(ctx):
    await ctx.send("hello")
  if message.author == bot.user:
    return

  if message.content.startswith("`hello"):
    await message.channel.send("Whats good!")

bot.run(os.getenv("TOKEN"))


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

Still not passed in the commands.Bot constructor

#

Still not removed

client = ...
#

Still not removed on_message and replaced with an actual command

#

ok lemme edit my thing

#
import discord
import os
from discord import Intents

intents = Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
from discord.ext import commands

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

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

@bot.event
@bot.command()
async def hello(ctx):
    await ctx.send("hello")
  if message.author == bot.user:
    return

  if message.content.startswith("`hello"):
    await message.channel.send("Whats good!")

bot.run(os.getenv("TOKEN"))
slate swan
slate swan
#
File "main.py", line 20
    if message.author == bot.user:
                                 ^
IndentationError: unindent does not match any outer indentation level

i dont need that part right

#

Correct

sick birch
slate swan
#

Just need await ctx.send("hello")

slate swan
#

I just said you need to

#

well

Traceback (most recent call last):
  File "main.py", line 9, in <module>
    bot = commands.Bot(command_prefix='!')
TypeError: __init__() missing 1 required keyword-only argument: 'intents'
slate swan
slate swan
#
import discord
import os
from discord import Intents

intents = Intents.default()
intents.message_content = True
from discord.ext import commands

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

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

@bot.command()
async def hello(ctx):
    await ctx.send("hello")

bot.run(os.getenv("TOKEN"))
#

Why on earth did you remove commands.Bot(..)

#

wait a minute

#

Told you to remove discord.Client

#

Which you did correctly

#

i wish ?tag lp existed here

#

Yeah

paper sluice
shrewd apex
#

๐Ÿ‘€

paper sluice
#

hate when they delete the message

shrewd apex
#

kewl

slate swan
#

sorry

shrewd apex
#

i was just in time to witness

slate swan
#

good for you

paper sluice
#

lol

slate swan
#

its a historical momett

#

sorry for english

#

the only thing i did was learn it for half a year once a week is lucky in school

#

You'll need more knowledge than half a year once every week, and motivation as well; once a week doesn't really show motivation at all

slate swan
#

i cant make out this error is

#

Bot doesn't seem to have permission to create application/slash commands within a guild

#

Make sure bot is invited with applications.command scope, should be default now when inviting though

#

Shouldn't add that to your bot, against Discord ToS - they don't like it

#

Can use .members on the channel object and then give them for the select menu

wispy trail
#

what did i do wrong here

paper sluice
#

its __init__ not __int__

wispy trail
#

oops

shrewd apex
#

25 is max number of options

#

so if users are more than 25 it won't work

#

u can just assign discord.ui.select to a var and keep updating

shrewd apex
#

move people from one voice channel to another

slate swan
#

well I'm sorry I'm dumb and can only read sentences that aren't surrounded by other text, my fault

shrewd apex
#

hmm so u read only single sentences not paragraphs? pithink

pastel basin
#

๐Ÿ˜ฆ

#

Rooting for everyybody who helps!

feral frost
#

how can i stop asyncio sleep ? within the command ?

#

for example

#

i have

await asyncio.sleep(20)

How can i stop that from happening ?

#

cuz i am making a notify me and cancel button

feral frost
#

but if i click cancel i want it to cancel doing that

hallow kernel
#

How to send long code

unkempt canyonBOT
#

@hallow kernel, looks like you posted a Discord webhook URL. Therefore, your message has been removed, and your webhook has been deleted. You can re-create it if you wish to. If you believe this was a mistake, please let us know.

brittle tapir
#

does anyone know any good bots for reporting stuff to mods? I've looked at modmail and you have to physically DM the bot and verify which I would imagine would be too annoying to follow through with, and a ticket bot is just hard to report someone else because its only you in the chat with a moderator

hallow kernel
#

hhhh i had to remove whole link

hallow kernel
muted robin
hallow kernel
#
async def on_ready():
        log("started, getting bank channel...")
        ch = client.get_channel(sender.bank)
        log("got bank channel.")
        times = int(input("how many arts to send?: "))
        log(f"sending {times} arts...")
        for i in range(times):
            log("making history")
            history = ch.history(oldest_first=True)
            log("made history, asking first message...")
            first = await history.next()
            log("got first message, downloading art...")
            first_art = await first.attachments[-1].to_file()
            
            log("loaded art, sending art...")
            sender.send_art(first_art, file=True)
            
            log("art sent, deleting from bank channel...")
            await first.delete()
            log(f"deleted. done {i} arts")
        
        log("finished!", "\n"*2, "-"*15)
        exit()

if __name__=="__main__":
    log("starting...")
    client.run(sender.token)
#

Yea something like this

#

So what is happened with channel.history?

vocal snow
#

it was changed in dpy 2.0

#

see the examples in the docs for the new usage

#

!d discord.TextChannel.history

unkempt canyonBOT
#

async for ... in history(*, limit=100, before=None, after=None, around=None, oldest_first=None)```
Returns an [asynchronous iterator](https://docs.python.org/3/glossary.html#term-asynchronous-iterator "(in Python v3.10)") that enables receiving the destinationโ€™s message history.

You must have [`read_message_history`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Permissions.read_message_history "discord.Permissions.read_message_history") to do this.

Examples

Usage...
vague moon
#

Hi! Can i somehow get access to guild or command author at this point?

@CLIENT.tree.command(name="name")
hallow kernel
#

DiscrodWebhook strange

im1: source
im2: whook link 1
im3: whook link 2

#

First made perfect and second made some sss...

#

I have no ideas......
library broken maybe

Explanation:
I tried to send images with webhook to 2 discord servers, it sent normal on first, but on second it send with no pfp and no image data, only empty files

hushed galleon
hallow kernel
#

hm, ok, but what is with pfp(avatar), same?

hushed galleon
#

i cant tell where you even sent the pfp from that screenshot, which you should also show as a paste so its easier to read

#

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

hushed galleon
#

given that it seems you're also using discord.py (based on your log) i would suggest using its builtin webhook support rather than the discord_webhook package

hallow kernel
slate swan
feral frost
#

ok

slate swan
#

There is an example on the docs explaining how to do so, take inspiration from it

feral frost
#

ok can you show me the example cuz i dont see it

slate swan
#

Literally click on the URL

feral frost
#
async def cancel_me():
    print('cancel_me(): before sleep')

    try:
        # Wait for 1 hour
        await asyncio.sleep(3600)
    except asyncio.CancelledError:
        print('cancel_me(): cancel sleep')
        raise
    finally:
        print('cancel_me(): after sleep')

async def main():
    # Create a "cancel_me" Task
    task = asyncio.create_task(cancel_me())

    # Wait for 1 second
    await asyncio.sleep(1)

    task.cancel()
    try:
        await task
    except asyncio.CancelledError:
        print("main(): cancel_me is cancelled now")

asyncio.run(main())

# Expected output:
#
#     cancel_me(): before sleep
#     cancel_me(): cancel sleep
#     cancel_me(): after sleep
#     main(): cancel_me is cancelled now``` is it this
slate swan
#

Yes, no need to paste it here

feral frost
#

ok

hallow kernel
#

@hushed galleon any ideas?

slate swan
#

You can see they await asyncio.sleep(3600) but cancel that afterwards with task.cancel()

feral frost
#

ah ok

#

but how

slate swan
#

Read the code

feral frost
#

ah nvm

hushed galleon
feral frost
#

how does it even work

slate swan
#

Look at the code

feral frost
#

bro i dont understand it

slate swan
#

They create a function to sleep, they wrap that function in a task and call it. Then they cancel it

feral frost
#

but how does it get cancelled

#

what do they do to cancel it

slate swan
#

Well technically they cancel it first hut that doesn't matter

feral frost
#

like i need this in buttons

slate swan
feral frost
#

so i just use task.cancel

hushed galleon
#

!d discord.Webhook

unkempt canyonBOT
#

class discord.Webhook```
Represents an asynchronous Discord webhook.

Webhooks are a form to send messages to channels in Discord without a bot user or authentication.

There are two main ways to use Webhooks. The first is through the ones received by the library such as [`Guild.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Guild.webhooks "discord.Guild.webhooks"), [`TextChannel.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.TextChannel.webhooks "discord.TextChannel.webhooks"), [`VoiceChannel.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.VoiceChannel.webhooks "discord.VoiceChannel.webhooks") and [`ForumChannel.webhooks()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.ForumChannel.webhooks "discord.ForumChannel.webhooks"). The ones received by the library will automatically be bound using the libraryโ€™s internal HTTP session.

The second form involves creating a webhook object manually using the [`from_url()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook.from_url "discord.Webhook.from_url") or [`partial()`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook.partial "discord.Webhook.partial") classmethods.

For example, creating a webhook from a URL and using [aiohttp](https://docs.aiohttp.org/en/stable/index.html "(in aiohttp v3.8)"):
hallow kernel
#

And it can solve all problems..

feral frost
slate swan
#

Thanks, I can definitely read your screen from where I am and see why it's not working ๐Ÿ‘

feral frost
#

just ask for code

#

i am gonna send an image

feral frost
slate swan
#

I said you don't need to copy paste the code from the docs, not yours...

feral frost
#

ah ok

slate swan
#

Yeah that's not like the docs as I can see, the sleep is the only thing in the function

feral frost
#

ye

slate swan
#

Got other things to do, so someone else can help you further

feral frost
#

i hope so

hushed galleon
# hallow kernel And it can solve all problems..

for using it id structure your code as something like this: ```py

Define the webhook

session = aiohttp.ClientSession()
webhook = discord.Webhook.from_url('https:...', session=session)

async for message in channel.history(limit=times, oldest_first=True):
# ^ Simpler than using anext() repeatedly
file = await message.attachments[-1].to_file()

# Send the file through the webhook
await webhook.send(file=file)

# Delete the message afterwards...```
#

send() is also where you can specify the username and avatar_url, you can check the previously linked docs to reference that

hallow kernel
hushed galleon
#

thats what limit= is for

hallow kernel
#

Hmm

#

Uh, genius, i unreasonably considered that it works only with oldest_first=False

#

Ok ill try tommorow

#

Thank you

hallow kernel
#

still think like that

slate swan
fading marlin
#

simply saying "it doesn't work" doesn't help. Are there any tracebacks that you could send? What is the expected behaviour vs the actual behaviour?

slate swan
hushed galleon
hallow kernel
slate swan
hallow kernel
#

h idk

#

Will try your variant

hushed galleon
hallow kernel
#

It works so i wont change code

fading marlin
slate swan
#

People with lack of experience/habit tend to forget self pOg

fading marlin
#

tbf this is a kinda of odd approach to this

#

and you don't even have to pass in bot at all, just use interaction.client

shrewd apex
#

if u are gonna use an interaction just use a modal itself for this pithink

slate swan
#

Yeah

wraith flume
#

Just purchased a raspberry pi 4

And I was looking into how to host multiple bots

Anyone know a good article/video they can share?

runic notch
#
@client.event
async def on_message(message):
    if message.author == client.user:
        return

    if message.content == "hello":
        await message.channel.send("Welcome!")

Why isn't the bot responding when message.content is "hello"

slate swan
#

dev portal and bot object

slate swan
wraith flume
runic notch
slate swan
#

discord.Intents.all()

runic notch
#

ok

runic notch
slate swan
#

enable them in dev portal

#

as well

runic notch
#

ight thanks

nimble minnow
sick birch
#

How so?

nimble minnow
#

Bot gets online but commands don't work

sick birch
#

Your message content intents are disabled

#

You need to enable them in the dev portal first then in your code

nimble minnow
#

is that a new update

sick birch
nimble minnow
nimble minnow
sick birch
#

But discord's message content intent went live much longer before that

nimble minnow
sick birch
# nimble minnow MESSAGE CONTENT INTENT?

yeah

intents = discord.Intents.default()
intents.message_content = True # this is the important part

bot = commands.Bot(..., intents=intents)

as always not a plug and play copy and paste solution but more of a general idea

sick birch
nimble minnow
#

Alright, ill try it.

nimble minnow
sick birch
nimble minnow
#

lol

nimble minnow
slate swan
#

``
@commands.Cog.listener()
async def on_command_error(ctx, error):
if isinstance(error, commands.errors.NSFWChannelRequired):
embed = discord.Embed
embed.title = "NSFW Command"
embed.description = error.args[0]
await ctx.send(embed=embed)

``

|| discord.ext.commands.errors.NSFWChannelRequired: Channel 'no-nsfw-test' needs to be NSFW for this command to work. ||

nimble minnow
#
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Command' object has no attribute 'choice'```
i get this error bc `random.choice` doesnt work
grand willow
#

This is my Code

temp_array = []
bot = ctx.guild.get_member(client.user.id)
count = 0
for r in ctx.guild.roles:
  if r.position >= bot.top_role.position:
    continue
  else:
    count += 1
    temp_array.append(r.id)

And this is the Error I get Command raised an exception: AttributeError: 'int' object has no attribute 'id'. Im not sure what I did wrong because normally when I do this things it works

glad cradle
unkempt canyonBOT
#

property me```
Similar to [`Client.user`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.user "discord.Client.user") except an instance of [`Member`](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member "discord.Member"). This is essentially used to get the member version of yourself.
glad cradle
slate swan
#

ohh i got it

sick birch
nimble minnow
#

Is that the problem?

hot cobalt
#

Yes, you overwrote the random lib

sick birch
# nimble minnow Is that the problem?

you can change the name of the function to something like _random or random_command or something more specific or fitting than just random. You can pass in the name= parameter to change the name of the command that you'll type in discord to be seperate from the actual function name

nimble minnow
sick birch
#
@bot.command(name="hello")
async def world(...):
  ...

the command would not work with !world but would work with !hello

nimble minnow
#

I understand what I did wrong, thank you guys.

dull terrace
#

is there a clean way to import across all your modules the same module rather than doing import x on every thing 7739monkathink

#

i'm tired of writing py import asyncio

nimble minnow
dull terrace
#

in one line i somehow import asyncio to every module im using in a folder

#

instead of writing it every time

slate swan
#

@dull terrace

fading marlin
#

some editors (at least pycharm) have the ability to use live templates, but I don't see why you'd use that for just one line

slate swan
#

@sick birch

dull terrace
#

the amount of times i forgot to import something

fading marlin
slate swan
#

yea

wraith flume
#

Just purchased a raspberry pi 4

And I was looking into how to host multiple bots

Anyone know a good article/video they can share?

sick birch
wraith flume
#

Oooo thanks

hushed galleon
#

the most basic setup would be manually starting each bot script, but raspbian OS (and also ubuntu if you already installed it) manages services with systemd, therefore you could set up a unit file per bot to run on and have them start on each boot

limber pagoda
#

why dont ppl commonly dopy intents = discord.Intents.all()

sick birch
#

It's OK in the testing or development phase but when it goes out to production it's important you change it to only the intents you need

#

Or just keep it as the intents you need from the start

#

Imagine if you're in a larger server, and your bot doesn't care about presence updates, but you can potentially get multiple presence updates that discord.py has to parse out and dispatch for you which can be a problem

primal token
#

TL;DR it's a waste of resources

sick birch
#

basically

velvet mortar
#

im trying to make my first simple discord bot but its giving me an error with this code

import discord
import random

TOKEN = 'my token that i deleted for this'

client = discord.Client()

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

client.run(TOKEN)
#

File "C:\Users\rmont\PycharmProjects\discordBot\main.py", line 6, in <module>
client = discord.Client()
TypeError: Client.init() missing 1 required keyword-only argument: 'intents'

limber pagoda
#
    client = discord.Client()
TypeError: Client.init() missing 1 required keyword-only argument: 'intents'```
limber pagoda
velvet mortar
#

so like discord.Client(intents)?

wicked atlas
#

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

limber pagoda
#

example:py client = discord.Client(intents = discord.Intents.default())

velvet mortar
limber pagoda
velvet mortar
#

it gave me a whole bunch of errors wehn i replaced it

limber pagoda
velvet mortar
#
    data = await self.request(Route('GET', '/users/@me'))
  File "C:\Users\rmont\PycharmProjects\discordBot\venv\lib\site-packages\discord\http.py", line 744, in request
    raise HTTPException(response, 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\rmont\PycharmProjects\discordBot\main.py", line 13, in <module>
    client.run(TOKEN)
  File "C:\Users\rmont\PycharmProjects\discordBot\venv\lib\site-packages\discord\client.py", line 828, in run
    asyncio.run(runner())
  File "C:\Users\rmont\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\rmont\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Users\rmont\PycharmProjects\discordBot\venv\lib\site-packages\discord\client.py", line 817, in runner
    await self.start(token, reconnect=reconnect)
  File "C:\Users\rmont\PycharmProjects\discordBot\venv\lib\site-packages\discord\client.py", line 745, in start
    await self.login(token)
  File "C:\Users\rmont\PycharmProjects\discordBot\venv\lib\site-packages\discord\client.py", line 580, in login
    data = await self.http.static_login(token)
  File "C:\Users\rmont\PycharmProjects\discordBot\venv\lib\site-packages\discord\http.py", line 805, in static_login
    raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.```
limber pagoda
#

you gave the wrong token

velvet mortar
#

breh

limber pagoda
#

on the very last line, it says Improper token has been passed.

velvet mortar
#

ok ill reset it

limber pagoda
velvet mortar
# limber pagoda ๐Ÿ‘

it said

[2022-10-17 21:22:35] [INFO    ] discord.gateway: Shard ID None has connected to Gateway (Session ID: 1d8b0bb42729fca37aaab9d9082d01e1).
We have logged in as Ethan Mwiti#9621
#

thanks

amber ether
#

BRUH THERE ARE NO DAMN SPACES

limber pagoda
#

in the form of indents

amber ether
#

so i do this?

limber pagoda
#

dude you cant just use different indent sizes in your code

#

sadly replit just becomes a bozo when u do so

limber pagoda
amber ether
#

well replit is my temporary bc it sucks Idk about this

amber ether
limber pagoda
#

can you explain to me why it is indented more than if a == 36:

amber ether
#

then it will reply to the user getting round id

limber pagoda
sick birch
limber pagoda
#

you have not set e equal to anything in the function, so yes, the argument is required

limber pagoda
#

but due to positioning you cant have required arguments after a default argument

sick birch
#

now it's just a matter of indents

limber pagoda
#

bro

#

lol

amber ether
#

I dont know alot of py tbh

limber pagoda
#

ok so

amber ether
#

My friend is just helping me out but hes offline

sick birch
#

Or at least, the root of the problem

limber pagoda
sick birch
#

I usually don't like telling people this but discord.py is not a beginner friendly library and you'll only be doing yourself a favour by learning intermediate python before attempting discord.py

#

This current issue should ideally take no more than 5 seconds to solve
But as it stands, everything after if a == 30: needs to be indented one step so it's inside the function

limber pagoda
# amber ether

when it says if (line 71), else (line 76), and try (line 81), since these arent indented, you have put them OUTSIDE of the pmines function, meaning the pmines command will not execute that code

amber ether
#

I managed to fix it.

sick birch
#
@bot.command()
async def pmines(ctx, e, mines=None, spots=None):
  a = len(e)
  if a == 30:
    await ctx.send("**Getting RoundID {e}**")
  # rest of code here
limber pagoda
#

yes but now

#

can you copy and paste your code

#

@amber ether

#

instead of sending a picture

amber ether
#

i legit did that on my own XD

limber pagoda
amber ether
#
async def pmines(ctx, e, mines=None, spots=None):
  
      a = len(e)
      if a == 36:
       await ctx.send(f'**Getting RoundID {e}**')
      if checkid(e) == False:
        return
      await mines(ctx, e)
 else:
      time.sleep(2)
      await ctx.send('**Invalid RoundID**')```
sick birch
#

The indents are still messed up

amber ether
#

now at else: its gonna give me, unindent does not match any outer indentation level. But when i move it its still on

#

lemme legit try this on VS

limber pagoda
#
async def pmines(ctx, e, mines=None, spots=None):
  
    a = len(e)
    if a == 36:
       await ctx.send(f'**Getting RoundID {e}**')

    if checkid(e) == False:
        return
        await mines(ctx, e)

    else:
    time.sleep(2)
    await ctx.send('**Invalid RoundID**')```
vocal snow
#

The last two lines should be indented as well

primal token
primal token
sick birch
#

With the initial indents fixed up to get them on the right foot

primal token
primal token
#

Ok I'll stop kek

sick birch
# primal token fix it

That's going to detract away from the main problem. Don't want to overwhelm them. One issue at a time

#

Throwing everything wrong with the code at their face is not going to help

#

Indents first, as that's the basic building blocks of the app, then the logical errors that require a little bit more thinking

primal token
#

I would say fixing one issue would still overwhelm the user from what the messages sent

sick birch
#

No need to make it worse then, eh?

amber ether
sick birch
#

You probably meant to indent the time.sleep(2) so it's inside the else

primal token
#

Robin you take your time telling him all the issues, ill be sleeping

#

๐Ÿ˜ญ

sick birch
primal token
#

lol

amber ether
#

why is everything so damn hard to learn lol

sick birch
#

that is the nature of all things

#

you reap what you sow, if you get me

primal token
#

reap?

amber ether
#
    if mines == None:
      await ctx.reply("You forgot mines! `.pmines (MINES) (SPOTS)`")
      return
    elif spots == None:
      await ctx.reply("You forgot spots! `.pmines (MINES) (SPOTS)`")``` i get yield outside the function?
velvet mortar
#

why does this not work

import random

TOKEN = "my token :)"

client = discord.Client(intents = discord.Intents.default())


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

@client.event
async def on_message(message):
    username = str(message.author).split("#")[0]
    user_message = str(message.content)
    channel = str(message.channel.name)
    print(f"{username}: {user_message} ({channel})")


    if message.author == client.user:
        return

    if message.channel.name == "chat":
        if user_message.lower() == "chicken":
            await message.channel.send(f"hello {username}! did i hear chicken?")
            return
        elif user_message.lower() == ("summon mwiti"):
            await message.channel.send(f"IM NOT GOIN BACK TO WORK UNLESS I GET ME SOME FRIED CHICKEN")
            return
        elif user_message.lower() == ("watermelon"):
            await message.channel.send(f"Where?")
            return

client.run(TOKEN)

i dont get any errors but it doesnt work

limber pagoda
#

starting from @bot.command

sick birch
velvet mortar
#
rmont:  (chat)
rmont:  (chat)```
sick birch
velvet mortar
#

so what do i do to fix it?

amber ether
#

cuh wtf

sick birch
primal token
sick birch
sick birch
#

You have a return statement breaking up the flow

primal token
sick birch
#

first thing that came to mind

primal token
#

Did your grandma told you that?

sick birch
#

!resources in all seriousness though @amber ether I think you may find some of the resources here helpful

unkempt canyonBOT
#
Resources

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

sick birch
amber ether
#

I JUST DONT GET INDENTED I LITTERALLY NOT FIX THAT
|

primal token
sick birch
velvet mortar
sick birch
velvet mortar
sick birch
primal token
velvet mortar
sick birch
#

What does the error say?

#

I have a feeling it's not the improper token is passed error

velvet mortar
#

yeah nvm read a bit wrong it says at the bottom

discord.errors.PrivilegedIntentsRequired: Shard ID None is requesting privileged intents that have not been explicitly enabled in the developer portal. It is recommended to go to https://discord.com/developers/applications/ and explicitly enable the privileged intents within your application's page. If this is not possible, then consider disabling the privileged intents instead.```
sick birch
#

knew it

#

yup just follow the link in the error and do as it says

#

you should be golden

velvet mortar
#

yes it works thanks robin

sick birch
#

np

amber ether
#

my bot is not working anymore? when i do .pmines 3 3 but without 3 3 it will say you forgot spots Like idk why. I just restarted my Bot now its not working

pastel basin
#

Can someone do anything naughty with your application id?

#

Like with bot token, they can have access to your bot.

torn sail
#

I donโ€™t think they can

vale wing
#

What malicious stuff could you do with user ID which is public data

pastel basin
#

ye

slate swan
#

what does this mean and how do i fix it?

silent portal
#

@slate swan show ur code

slate swan
silent portal
#

no, just the method it's reffering to

slate swan
slate swan
#

you didn't invite the bot with application commands scope in the server mb

brave flint
#

does anyone know how to send a embed with a view in a specified ctx.channel?
currently this doesnt work : py await self.current.source.channel.send(embed=self.current.create_embed(),view=MusicUI(MusicV2.get_voice_state(self._ctx)))

slate swan
#

the issue is not how youre sending it

#

but what you are sending

#

.send(embed=embed, view=view)
is correct.

brave flint
#

Nope

vocal snow
#

can you send some more code?

brave flint
vocal snow
#

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

brave flint
#

Wait

slate swan
#

can i set a spoiler in an embedded image?

#

try assigning a var to those functions and send the var rather than calling them inside of the .send function

#

@brave flint

brave flint
#

How?

brave flint
slate swan
brave flint
#

Like the button things?

vocal snow
#

yes, the view and the command

#

(MusicUI class and the command you're using it in)

brave flint
#

Ok

slate swan
#

That's not an *embedded * image

#

you realize u can use urls for an image right?

slate swan
slate swan
#

Needs to be a discord.File object

#

alright, thanks man

vocal snow
slate swan
#

what? no it doesnt?????????

#

embed.set_image(url=|| img url ||)

#

but its not wrong ? wtf

#

u explicitly said no as if it isn't plausible

#

it is wrong.

brave flint
#

No embed, no view

#

No error

slate swan
#

that. won't work.

#

thats not what i was referring to

#

of course if you don't read the code and what I've sent you can't understand

#

but that's a different issue

#

alright guys don't fight it's fine i appreciate you both

#

you can't have a spoiled image in an embed, can you?

#

you think he is trying to spoil an already embedded image. he isnt he is trying to send a img in a discord EMBED and add a spoiler

#

Pretty sure you can

slate swan
#

You're not that advanced to guess what my brain thinks, sorry

#

yo staff?

#

can we tell this dude to chill wtf

brave flint
#

XD

slate swan
#

You are the one already coming back? I am simply replying to you..

vocal snow
slate swan
#

for the person who needs help, sending an example of what you're trying to do would be more helpful

brave flint
#

Oh ye seffo, it will send the embed if i remove the view part

slate swan
vocal snow
slate swan
brave flint
#

Wait lemme try

#

Im on school rn so...

slate swan
# slate swan .

He said "yeah" to the second part, explaining what HE wants.
I said "No I don't think that" to the first part where you randomly guess what I think, not what HE wants.
jeez move on instead of always coming back facepalm

slate swan
slate swan
#

it will raise some error saying url must be an http or https

#

Most likely, yeeah

#

Hence discord.File

#

And provide an attachment

#

If they can be even spoilered, which I think but not sure

#

as for discord.File the spoiler kwarg does nothing but add a SPOILER_ before the file's name
so i doubt if even that would work

#

If spoilers are supported in embeds it most likely will

#

Well looks pretty bad and not what they want

#

So either way, both solutions are wrong and not what they want

slate swan
#

lol sed, any other way tho?

#

ooooo there's no spoiler in embed

#

Image spoilered in the embed apparently not

#

Will be sent separately

#

I used

f = discord.File("x.png", filename="x.png", spoiler=True)
e = discord.Embed()
e.set_image(url="attachment://x.png")
await ctx.send(file=f, embed=e)

got the result above

slate swan
#

it's fine i'll just do it without spoiler

brave flint
slate swan
#

the filename gets changed ( copy the file's url and see)

#

Can try, give me a few seconds

#

Nop

#

Sends in the embed, just not as a spoiler

#

Kind of sad they don't support that

brave flint
brave flint
vocal snow
#

Then change your class to do that

sonic chasm
#

!user

unkempt canyonBOT
#

You are not allowed to use that command here. Please use the #bot-commands channel instead.

dull terrace
#

new bot work starts today 2946catyawn

slate swan
#

how many slash commands can we add?

#

what's the limit?

#

100 global CHAT_INPUT commands
5 global USER commands
5 global MESSAGE commands

#

even for private bots?

#

Doesn't matter, it's the same

vale wing
#

That's why slash commands suck

#

With prefix commands we are only bound to machine power but with slash commands we also have limited amount

primal token
#

Seems like the first time you say slash commands suck, maybe you got a reason to hate them today

slate swan
#

Still curious why they added such a "low" limit

vale wing
#

Well ig discord just can't allow infinite amount

#

Cause their databases gonna go boom boom

primal token
#

I wouldn't say they're bad just limited literally

vale wing
#

I was not here to start an argument I can give yall another topic

vale wing
#

Also no support for arg lists

slate swan
#

They still are somewhat limited, which is why I don't really like them so far

#

i wish the limit was somewhat around 300 commands lol

vale wing
#

They are user-friendly tho

slate swan
#

They are adding things which is nice

vale wing
#

Not developer friendly

slate swan
#

i added around 70 image manipulating commands only to get slapped in the face by the limit

#

But I don't think adding a channel only select menu is of any use so far

#

That was already doable before, just without a select menu

vale wing
slate swan
vale wing
#

Also this discord mobile design update

slate swan
#

Could maybe put more time and effort in things like modals, that are missing lots of components so far

slate swan
vale wing
#

Apple definitely secretly took over discord 100%

primal token
#

You can also make a general image manipulation command that depends on input for results

slate swan
#

slash group commands are just options anyways

slate swan
#

Well that's when you use one command and make an option for it

#

Adding 70+ sub commands is not convenient either

slate swan
#

i am talking about slash commands

#

Would be a nice use case of an auto complete option

#

Where you list the different manipulations that can be done

#

tbh if your bot has these many commands, i feel like its overloaded

#

Depends, for image generation there can be lots of different images

#

They're not unique commands, just variations of one

primal token
slate swan
#

Hence just using an option is maybe not that bad

slate swan
slate swan
vale wing
slate swan
#

Wasn't that bot terminated PepeHmm

#

If the commands are organized in a good way it's not a big deal, but if you have commands like /generate cat, /generate dog, /generate ... you could as well just make /generate animal:dog

#

Which is, in my opinion, much more user friendly as you can make the animal option an auto completed option

#

Which is essentially what I use for my /tag command

slate swan
#

There are only a few tags, so could as well make them as sub-commands but it's not really handy, programmatically and user experience

#

could have added choices/autocomplete as well

#

Discord broke my connections or what PepeHmm

primal token
#

Your 8 connections still appear, seems like a client issue

slate swan
#

Same on mobile

primal token
slate swan
#

This explains the issue peepoMmmYea

primal token
#

๐Ÿ˜ฆ

slate swan
#

welp discord broke

kind trellis
#

Is it possible to describe an argument when the command is a hybrid command?

slate swan
#

Yes

#
from discord import app_commands

# ...

@app_commands.describe(arg="The description you want to give.")
slate swan
#

arg being the name of the argument in the function of course

slate swan
#

Anyone know how to login with bot token

#

I tried some utube videos but not working

dull terrace
#

are guild ids and user ids always different from each other

slate swan
slate swan
#

If you mean, you logging in as your bot and doing actions, that's against the ToS so you won't get help

slate swan
wicked atlas
vale wing
#

In fact any action done by bot can be considered done by its application's owner

opaque edge
#

/help

#

how do you go to the site again where i learn python?

slate swan
#

!resources

unkempt canyonBOT
#
Resources

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

opaque edge
#

thank you

slate swan
vale wing
#

ToS don't restrict you from that to my knowledge as well

vale wing
slate swan
#

Developer policy doesn't allow people to login explicitly as their bot as far as I remember from other people's wording and my reading

wicked atlas
#

You will use any developer credentials (such as your Application ID, passwords, keys, tokens, and client secrets) we assign to you solely with your Application and the applicable APIs...
https://discord.com/developers/docs/policies-and-agreements/terms-of-service#d-developer-credentials

Discord Developer Portal

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

slate swan
#

There

#

Thanks

vale wing
#

It's more about confidentiality of that data imo

slate swan
#

Still policies and agreements you accept by using Discord's API & Applications

vale wing
#

Well if I login with bot's token and start sending requests authenticated as bot that doesn't really break this, does it? I am still using discord API and I don't disclose the token to 3rd parties

slate swan
#

Ask Discord, we're not lawyers

vale wing
#

I'm barely interested in that, was trying to figure out this for another person

slate swan
#

You will only get a valuable answer from discord.

#

you are proving the bot token to a third party when you do that (, unless you're building the application you're logging in to yourself)
isn't that against tos

wicked atlas
vale wing
#

If that's 3rd party client it's forbidden without any doubts

vale wing
#

The section you linked was actually about keeping private data safe

wicked atlas
#

The section is about the use of APIs. The second half of that paragraph is about not disclosing your token. The first part, that I quoted, is about where you can use that token.

#

It clearly states that you can only use your token with your application, and with the allowed APIs

vale wing
#

Depends what they mean by "your application"

#

For some reason I haven't found a clear definition in that policy

slate swan
#

Clearly defined

wicked atlas
#

โ€œApplicationโ€ (or โ€œappโ€) means any application (including any bot, game, activity, website, or other client) that accesses or uses our APIs or to which we have assigned an Application ID. โ€œyour Applicationโ€ means any Application that you own or operate. References made to API Client in existing terms, policies, agreements, or Documentation will now mean Application.
section 13

slate swan
#

^

vale wing
#

Ok thanks

#

"or other client"

slate swan
#

to which we have assigned an Application ID.

vale wing
#

"any Application that you own or operate"

wicked atlas
#

โ€œyour Applicationโ€ means any Application that you own or operate.

slate swan
# vale wing "any Application that you own or operate"

That is only used

โ€œApp Contentโ€ means any data, information, technology, materials, or other content that you or those acting on your behalf add to our services or otherwise make available to us in connection with the APIs or your Application (including as submitted, posted, or displayed by or through your Application).

#

Hence unrelated

#

Its seems discord clearly state that its " not allowed "

Lets finish the topic ๐Ÿ™ƒ

#

"your Application" is not the same as "Application"

slate swan
#

That's self botting, another unrelated topic

wicked atlas
#

Nah, that post is mentioning this topic

dull terrace
#

what legitimate purpose would you even want a bot user account for?

slate swan
#

No

#

We are talking about logging in as a bot with another client, such as some fake discord client for bot

slate swan
#

They are talking about making your account using a script to automate it

vale wing
#

Why the heck every time when I get good mood I get into some pointless argument and then it worsens

slate swan
#

Which is not the same

#

Bot user accounts aren't allowed.

#

Meaning automating your user account

#

Absolutely unrelated to logging in as your bot

slate swan
vale wing
#

Mood worsens

slate swan
#

Logging in as your account with your account's token and automating your account = bot user accounts = self bots

slate swan
#

Which is not the same as making a custom client to login as your bot using the bot's token

dull terrace
#

expected result is an argument doge_kek

random saffron
#

The bro. Jamed

vale wing
wicked atlas
slate swan
#

That's more about reading but yeah KEKW

#

I guess

#

Not a lawyer, ask Discord

slate swan
#

For me that qualifies as an application so it's fine

#

Don't know how Discord considers that kryptonShrug

shrewd apex
#

kek today i learnt js on pycharm for website pWut with no prior knowledge kewl

slate swan
dull terrace
#

ew js

shrewd apex
#

ikr

vale wing
#

The only thing I created in js was the automatic github release tagger based on commits or smth and that's what js programmers definitely shouldn't look at

slate swan
#

does it even do intellisense

shrewd apex
slate swan
#

not community i suppose

#

community doesn't do it i think

shrewd apex
#

i haven't tried a js ide yet or vsc or js at all so i can't compare yet

slate swan
#

webstorm is pretty nice

shrewd apex
#

I'll take ur word for it pithink

slate swan
#

it's jetbrains' stuff

shrewd apex
#

then its nice ๐Ÿ‘

slate swan
#

you can go for the EAP version then it has a cleaner UI

#

same for all jetbrains ide

shrewd apex
#

noice

#

hmm icons looke neat

slate swan
#

ah that was intellij whatever

#

same for webstorm etc.

#

yeah icons are custom icon pack though

shrewd apex
#

which one?

slate swan
#

ehm hold on

shrewd apex
#

sure thanks

slate swan
#

i think material but not sure anymore

#

changed so many times

#

yeah is that

shrewd apex
#

noice thanks ๐Ÿ’

slate swan
#

and theme is material arc dark

#

switching between that and material deep ocean

#

Make sure you're on latest version and python version, otherwise restart vsc

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.

slate swan
#

Maybe you can explain why you have all of these when you only need one and py-cord will make conflicts

discord==2.0.0
discord.py==2.0.1
py-cord==2.0.1
honest shoal
#

What is discord

honest shoal
slate swan
#

It's a mirror of discord.py

#

discord.py should be used

#

But doesn't really matter

#

Just no point on using both and no point on using discord.py and pycord

honest shoal
#

GigaChad1 pip uninstall py-cord

slate swan
#

Yeah it's a fork either way

#

Forks are usually not pog from my experience

honest shoal
#

No, disnake is cool

slate swan
#

from my experience

honest shoal
#

Idk if disnake is included in your experience

slate swan
#

It isn't hence you can't say "No" trollgopher

honest shoal
slate swan
wicked atlas
#

Using TEXT requires you to provide a size. There are some types that have predefined sizes, like TINYTEXT, 255 characters, MEDIUMTEXT, about 16,000,000 characters, and LONGTEXT, about 4,000,000,000 characters

#

Idk, I donโ€™t use sql much

ornate crater
#

what the prob?

shrewd apex
#

it says clearly no command named asd

#

which driver is this

#

aiosqlite asyncpg

#

i don't think aiomysql has a TEXT datatype not sure lemme check

#

hmm it does

slate swan
#

all sql dbs have TEXT

shrewd apex
#

ik ik my bad

slate swan
#

LEFT is a mysql function

#

you can't use it for column name

shrewd apex
#

oh damn ๐Ÿ’€

slate swan
#

no i am just kidding, i just don't want you to use that name

shrewd apex
#

๐Ÿ’€

#

i believed u sarth pithink

#

I'll see after dinner

velvet mortar
#

where should I start if I wanna start making bots with python

slate swan
#

bruh lol

#

it actually exists, and thats your issue

#

you could literally google "left function mysql" to verify it

velvet mortar
slate swan
#

use _left

velvet mortar
#

Like functions variables loops

shrewd apex
#

just change the name smh

slate swan
shrewd apex
velvet mortar
#

Made a simple discord bot that just replies to u and stuff

slate swan
velvet mortar
shrewd apex
#

use dpy largest community for it

velvet mortar
#

Thatโ€™s the one I used to make my simple one

slate swan
shrewd apex
#

yes

slate swan
#

i just hate the codebase

#

you don't use ? in mysql, its %s

#

you asked the database to store them as Text and you are giving it as integer

#

str the ids

#

or use BIGINT data type for tables

vale wing
#

Odd comma before FROM ig

slate swan
hot prawn
#

I made a embed welcome command but it gives a error embed.set_image(url="https://tenor.com/view/welcome-gif-23422204" invalid synatx)

code:

@bot.event
async def on_join(member):
  channel = guild.get_channel(1008254245016981537)
  embed = discord.Embed(title="Welcome",description=("f(Welcome, {member.mention}. Have a great day!")
  embed.set_image(url="https://tenor.com/view/welcome-gif-23422204")
  await channel.send(embed=embed)
slate swan
#

You are missing some ) at the embed = .... line

#

As you are using a ( too much when setting the description=(

#

Which is not needed, you should use f-strings instead to add variables in text for your description

#

!f-strings

unkempt canyonBOT
#

Creating a Python string with your variables using the + operator can be difficult to write and read. F-strings (format-strings) make it easy to insert values into a string. If you put an f in front of the first quote, you can then put Python expressions between curly braces in the string.

>>> snake = "pythons"
>>> number = 21
>>> f"There are {number * 2} {snake} on the plane."
"There are 42 pythons on the plane."

Note that even when you include an expression that isn't a string, like number * 2, Python will convert it to a string for you.

slate swan
#

So something like that instead

description=f"Welcome {member.mention}....."
#

Then you will have

embed = discord.Embed(title="...", description=f"...")

and that will be fine kryptonHype

slate swan
#

yeah how are u checking if they joined from your invite?

#

what does update_totals do?

#

thats the update_totals function right?

#

yea your passing the member that joined into that function

#

should it not be the member that invited them passed into that function

stone beacon
#

What editor and theme is that?

#

Well I mean it has to be ayu that's my baby

#

But I keep forgetting the editor

#

Wh-

#

๐Ÿ—ฟ

stable path
#

Does anyone have any idea how I would get the command to grab the text that triggered it?

#

I know modifier isnโ€™t in there thatโ€™s cause modifier is exactly what Iโ€™m trying to figure out how to add.

#

Because I plan on using regex to search for the modifier inside the original text that triggered the command to apply it to the end result as a plus.

fading marlin
#

why not... use discord.ext.commands?

stable path
#

I do not know how to use it.

hushed galleon
#

its a built in extension specifically for writing commands

stable path
#

Alright.

#

But how would that help?

hushed galleon
#

although it does expect commands to be structured as prefix + command name + parameters

stable path
#

As long as it can return the end result.

#

Iโ€™d rather it work than well it not.

hushed galleon
#

they're just suggesting the extension since writing commands in on_message tends to get messy/frustrating

#

but anyway, message.content would contain the text that the user typed in their message

stable path
#

Alright Iโ€™ll try that.

hushed galleon
#

if you do go for regex you might use it on that to match the number of sides and the modifier character

stable path
#

@hushed galleon so I wrote it up and it came back with an error like this.

#

Iโ€™m pretty sure I used message.content incorrectly.

hushed galleon
#

apparently your modifier is None, which is what re.match will return if it doesnt match the string

stable path
#

Hmm alright.

#

Iโ€™ll see if I can fix the pattern then.

hushed galleon
#

id double check the regex in https://regex101.com/ first so you can get d20+ / d20 / d20- working, and also consider refactoring your startswith if-statements into just one with your new regex pattern

stable path
#

Yeah the regex is totally wrong.

#

Think I got the pattern now.

#

@hushed galleon ok so I fixed the regex and it definitely catches what I want it to now but it still comes back with the same error.

#

Wait hold on.

#

Caught what I did.

#

I was doing \d+ when I should have put \d+$.

#

It was getting two matches since I left the dollar sign out.

#

After fixing that I still got the same error.

#

Ok so I intentionally made it error out the the regex literally isnโ€™t passing anything and I know the regex is correct now. So I think I must have implemented the message.content wrong.

#

Since it is recognizing the d20 as an int.

#

@hushed galleon

hushed galleon
#

you should claim a help channel for this since its related to your regex

stable path
#

It isnโ€™t the regex is the thing it does pick up the correct portion of the message.

#

Itโ€™s just not getting any content or something.

hushed galleon
#

re.match specifically scans from the start of the string

stable path
#

Maybe itโ€™s only scanning the front.

#

I think I get it now.

#

Itโ€™s trying to match it to the entire string.

#

But it canโ€™t.

#

And then returns nothing.

#

Iโ€™ll try something.

#

I may go wrong but Iโ€™m more confident in it now.

#

It*

#

Different error this time but that better than the same error.

#

It actually came back with something.

#

@hushed galleon I got it working.

#

I realized Re.match only returns once it finds a match.

#

So it doesnโ€™t actually return the content.

#

Just checks for a match.

#

re.group actually returns the content.

#

This is what it looks like in the end.

#

Iโ€™ll try adding the ability to roll multiple dice of the same type.

#

Instead of one die at a time.

#

A global for each loop would work I think.

#

Thanks for the help btw.

zinc nacelle
wicked atlas
#

it's very much still a thing

zinc nacelle
hushed galleon
#

ive switched from dpy 2.0a to enhanced-dpy, then to disnake, then back to dpy 2.0

i never bothered to bring my bot's features to parity so its never truly been the same since then ๐Ÿ˜”

verbal monolith
#

so i want it to say a message every time a specific user says a message

#

but it isnt

#

@ me if someone responds btw im probs gonna go to sleep

hushed galleon
#

do you get an error?

#

@verbal monolith ^

verbal monolith
#

no

#

dm me? ill be able to send images there

hushed galleon
#

why not send them here

verbal monolith
#

oh hsit

#

i can send images here

#

ok look

hushed galleon
#

just keep it appropriate though, given some of those responses in your code

verbal monolith
hushed galleon
#

have you regenerated your token?

verbal monolith
#

why should i regen it ?

hushed galleon
#

its in that screenshot

verbal monolith
#

oops

#

run this

#

any progress?

hushed galleon
#

run what

#

the paste you showed earlier?

#

i can point out possible issues in it but what matters is what happens on your system

#

e.g. client.get_user shouldnt be awaited, but somehow it ran fine for you given that your deleted screenshot showed the on_message print statement had worked

verbal monolith
#

aha

#

run this

#

cause i have no idea whats wrong

sick birch
verbal monolith
#

nope

sick birch
#

What happens when you type in a message?

verbal monolith
#

so

#

when i type hi, hello, bye, cum it all works

slate swan
sick birch
verbal monolith
#

but when i want it to write a message after a specfific user writes a m,essage

#

it doesnt do it

sick birch
#

Try comparing message.author to message.guild.get_member(879004139361816596) instead

#

The discord.Member to discord.User comparision might be failing

verbal monolith
verbal monolith
sick birch
#

No, change user1 to that

verbal monolith
#

didnt work

sick birch
#

How does that if statement look now?

verbal monolith
#
@client.event
async def on_message(message):
    user1 = message.guild.get_member(879004139361816596)    # user1 = person the AI should send messages after
    username = str(message.author).split('#')[0]
    user_message = str(message.content)
    channel = str(message.channel.name)
    print(f'{username}: {user_message} ({channel}')
sick birch
#

and the if statement at the end?

verbal monolith
sick birch
#

I mean in the code

#

That last if statement, how does it look like now?

verbal monolith
sick birch
#

looks right

hushed galleon
sick birch
#

try comparing the IDs instead?

if message.author.id == 879004139361816596:
hushed galleon
#

mhm

hushed galleon
#

ah you know what

#

members intent is off

#

so get_user will never work

verbal monolith
sick birch
verbal monolith
#

it works

#

but i want the id to be ina variable

sick birch
#

Well actually default includes members, no?

#

or do you mean it's disabled on the portal

hushed galleon
#

nah members is a privileged intent so discord.py excludes it from the default

verbal monolith
#

so whjat do i do now

hushed galleon
verbal monolith
#

so i can make it multipe users

sick birch
verbal monolith
#

i,e if author = user1, user2

hushed galleon
#

you can store the ids in a list/tuple/set and then check if the message author's id is in that collection

#

e.g. ```py
OWNER_IDS = {654818715183087626} # IDs stored in a set

@client.event
async def on_message(message):
if message.author.id in OWNER_IDS:
await message.channel.send('master!')```

verbal monolith
sick birch
verbal monolith
#

so i replace py if message.author.id == 879004139361816596: response = f'die' # this should automatically send a message after user1 sends a message await message.channel.send(response) with

    if message.author.id in OWNER_IDS:
        await message.channel.send(response)```
verbal monolith
sick birch
#

correct

sick birch
hushed galleon
#

nah you dont need members intent for that

if you have the intent disabled then it merely turns off join/leave events and discord.py's member caching, but messages will receive member objects as normal

verbal monolith
#

i did it and it broke it

#

helpy D: @sick birch @hushed galleon

hushed galleon
#

i dont really understand whats going on in the screenshots

#

oh nevermind tverculosis is a different person right

verbal monolith
#

i replaced my code with the one you sent me

verbal monolith
#

the ID belongs to him

hushed galleon
#

did you make sure the ID written inside owner_ids is the same as their ID?

verbal monolith
#

ohhh

#

you used my id

hushed galleon
#

yeah, i just wrote an example

verbal monolith
#

i c

#

so if i wanted to add more ids id do

#

OWNER_IDS = {879004139361816596, a, b, c}

hushed galleon
#

sure

#

you might as well name the variable to something else that makes sense

verbal monolith
#

the moment i reaslized XD

verbal monolith
#

idk something else

sick birch
#

we devs are not good at naming

verbal monolith
#

Variable in function should be lowercase

#

what does this mean

hushed galleon
#

thats just pycharm being peeved at your variable name

verbal monolith
#

PEP 8: E225 missing whitespace around operator

#

?

hushed galleon
#

pep8 is a style guide, they want you to write cleaner code

verbal monolith
#

how do i make the errors stop appearing

#

done

#

Ignore errors like this (EZ)

sick birch
#

not the best idea

hushed galleon
#

yeah that'll work

verbal monolith
#

is it possible to make it so you could write messages as the bot from the console

sick birch
#

more effort than it's worth

#

input() is blocking so you'll have to find an asynchronous version, it's not worth it

hushed galleon
#

i wouldnt say its a lot of effort, but its janky

#

you can just run input in a thread with asyncio

sick birch
#

what we do with @unkempt canyon is the mods have a "say" command they can run from private channels and troll us