#discord-bots

1 messages · Page 475 of 1

jagged hamlet
#

PyCharm, and I don't know anything about me creating an event loop...

#

No, it happens on each run, and my bot just isn't functioning due to it

hasty iron
#

can you send your code

jolly glacier
#

Windows for daily use and gaming and Linux for programming and wasting your life trying to figure out issues on stackoverflow

jagged hamlet
hasty iron
#

well

#

can you actually send the full traceback

jagged hamlet
hasty iron
#

usually thats not the full error when you run your code and that error pops up

jolly glacier
#

He’s using pycharm so I’m pretty sure thats the full error?

jagged hamlet
jolly glacier
#

Thx

hasty iron
#

most of the time its the ImproperToken error

#

or whatever its called

jagged hamlet
#

No, it's not that

#

My token is definitely valid (it's been used in test scripts)

#

and it is passed in identically

jolly glacier
#

Maybe regenerate your token?

hasty iron
#

i dont think what you sent is the full traceback tbh

jolly glacier
#

I’m inputting the code into repl

jagged hamlet
hasty iron
#

okay send a ss

jolly glacier
jagged hamlet
hasty iron
#

there is nothing on top of that?

jagged hamlet
#

as you can see, that's all I have :p

jolly glacier
#

I’ve got to head out for a little while bye, hope you figure out a fix

jagged hamlet
#

thanks!

hasty iron
#

can you run your code outside pycharm

jagged hamlet
#

(just without the highlighting)

#

and [SESSION ENDED] is just my debug message that gets printed after bot.run()

hasty iron
#

so it just skips bot.run

#

huh

jagged hamlet
#

it seems to attempt bot.run

#

but fails, without telling me where

hasty iron
#

do you have a WSL

jagged hamlet
#

yep

hasty iron
#

can you try running it there

jagged hamlet
#

sure, ill setup a venv

#

(Also, with some more digging, PyCharm debug tells me that the exception happens when discord.ext.commands.Bot.start() is called)

hasty iron
#

hm

#

oh wait

#

the docs say, start is a combination of login and connect

#

you have only login

#

just call super().start(*args, **kwargs)

jagged hamlet
#

...i think i figured it out, yeah

hasty iron
#

pycharm actually helped pagman

jagged hamlet
#

well, it works now

#

Thanks a lot for helping!

#

i really am nothing without my traceback huh

high flame
hasty iron
#

a twitch emote

high flame
#

ah i got it pithink

sweet merlin
#

how to make commands cooldown and send a custom message?

high flame
#

!d discord.ext.commands.cooldown

unkempt canyonBOT
#

discord.ext.commands.cooldown(rate, per, type=<BucketType.default: 0>)```
A decorator that adds a cooldown to a [`Command`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Command "discord.ext.commands.Command")

A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, per-role or global basis. Denoted by the third argument of `type` which must be of enum type [`BucketType`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.BucketType "discord.ext.commands.BucketType").

If a cooldown is triggered, then [`CommandOnCooldown`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandOnCooldown "discord.ext.commands.CommandOnCooldown") is triggered in [`on_command_error()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.on_command_error "discord.on_command_error") and the local error handler.

A command can only have a single cooldown.
hasty iron
#

If a cooldown is triggered, then CommandOnCooldown is triggered in on_command_error() and the local error handler.

high flame
#

!d discord.ext.commands.CommandOnCooldown

unkempt canyonBOT
#

exception discord.ext.commands.CommandOnCooldown(cooldown, retry_after)```
Exception raised when the command being invoked is on cooldown.

This inherits from [`CommandError`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.CommandError "discord.ext.commands.CommandError")
willow vine
#

if i want an arguement to be 2 words, like a single arguement

#

how do i do that

#
@bot.commands()
async def test(ctx,arg1,arg2):
  pass```
#

here i want arg 1 to be of 2 words

hasty iron
#

when passing the argument you can do <prefix>test "this is arg1" arg2

livid roost
#

guys could you please help i dont know what this error means

surreal sierra
#

Is it possible to make two different cooldowns on a command for different roles? So one role has a cooldown on 30 seocnds but the other role has a cooldown on 15 seconds

high flame
hoary gust
#

Guys what is better Ipc or Api

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 the Members and Presences intents, which are needed for events such as on_member 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.

hoary gust
#

Guys what is better Ipc or Api

hasty iron
#

you cant compare them or say whats "better"

hoary gust
#

@hasty iron what is better for dashboard

hasty iron
#

most people use ipc for dashboards to communicate with their bot

hoary gust
#

@hasty iron ipc isin't working with me lol

#

I am not even able to connect to the backend

hasty iron
#

ur using discord.ext.ipc?

hoary gust
#

Only getting a freaking error

hoary gust
hasty iron
#

ive seen somebody on the discord.py server saying to use zmq rather than that for IPC

hasty iron
hoary gust
#

Wait a sec how th can it help me

hasty iron
#

it can be used for ipc

hoary gust
#

For ipc or in replacement of ipc?@hasty iron

hasty iron
#

what

slate swan
#

Guys, how do I display the time when the message was sent to embed? Discord.py

hoary gust
#

@hasty iron well maybe yes it can be used

#

It's kinda ipc

#

But yea better

sweet merlin
#

how do i fix this?

    @commands.command()
    @commands.is_owner()
    async def saran(self, message, ctx, *, args):
        channel = self.bot.get_channel(887908566382571580)
        await channel.send(f"{message.author.mention} saran: {args}")```

it works but the problem is, when i run this command, it will send the second argument 
example
input: hello world

output:
world
hasty iron
#

why do you have message, ctx

sweet merlin
#

message.author.mention

hasty iron
#

and the ctx?

sweet merlin
hasty iron
#

ok so what are those two doing there

sweet merlin
#

wait it is the same?

hasty iron
#

normally, a command has its first argument as?

sweet merlin
#

ctx?

hasty iron
#

yes

#

message isnt supplied

sweet merlin
#

wait so message is the same as ctx?

hasty iron
#

ctx is Context and message is Message

sweet merlin
#

thanks!! i got it

supple thorn
keen talon
#

so no one needs help rn ducky_dave

slate swan
#

bot.user is None here , could you show more of the code?

full lily
#

bot.user is None when the bot isn't logged in

slate swan
#

Guys, how do I display the time when the message was sent to embed? Discord.py

#

define your lavalink client after bot is ready

spring flax
#

i am not sure what this client_secret is but as the name suggests it seems to be something that should not be leaked and you have done just that.

slate swan
#

mhm

slate swan
unkempt canyonBOT
rare saddle
slate swan
#

delete "pass"

hollow mortar
#

hello

#

i have a question do discord can bots play songs from spotify

#

or its against discord tos like youtube ?

final iron
rare saddle
final iron
#

Just in case

dense swallow
surreal sierra
#

Does anyone know why this does not work?

await ctx.send(embed=random.choice(errormsg)).delete(delay=4)
``` the msg gets sent but it doesnt get deleted after the delay, why?
full lily
#

!d discord.abc.Messageable.send

unkempt canyonBOT
#

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

Sends a message to the destination with the content given.

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

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

If the `embed` parameter is provided, it must be of type [`Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed "discord.Embed") and it must be a rich embed type.
full lily
#

delete_after=4

surreal sierra
#

oh okay, thanks!

#

it still doesnt work

stone palm
#

what forks yall using 👀

valid galleon
#

so uhh im making a custom prefix command for my bot, and i have this code which uses json to store the data. im not using json, instead im using mongodb. can someone help me convert this code to mongo? im guessing its gonna be similar since mongodb uses BSON

with open("prefixes.json") as f:
    prefixes = json.load(f)
default_prefix = "!"

def prefix(bot, message):
    id = message.server.id
    return prefixes.get(id, default_prefix)
stone palm
#

are you sure youre not using json 🤔

full lily
valid galleon
stone palm
valid galleon
valid galleon
stone palm
#

oh just realized, disnake isnt even in alpha anymore lol

#

pretty stable i gotta say

slate swan
#
async def play(ctx, url):
    with youtube_dl.YoutubeDL(ydl_opts) as ydl:
        info = ydl.extract_info(url, download=False)
        URL = info['formats'][0]['url']
    voice = ctx.author.voice.channel
    try:
        await voice.connect()
    except:
        pass
    voice_client = ctx.guild.voice_client
    await ctx.guild.change_voice_state(channel=voice,self_mute=False, self_deaf=True)
    voice_client.play(discord.FFmpegPCMAudio(URL))```
its start to play and suddenly stop
stone palm
reef shell
#

!rule 5

unkempt canyonBOT
#

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

stone palm
#

hmmmm

valid galleon
#

wait

#

i have better code one sec

stone palm
#

wait one sec

craggy cloak
valid galleon
craggy cloak
#

thx :)

reef shell
#

pip install pynacl in shell

valid galleon
#

then restart ur IDE

reef shell
#

oh late

#

nvm

stone palm
#

motor is preferred for pymongo and discord bots as it is async

valid galleon
#

alright i'll try to code it now

craggy cloak
#

How can my bot play playlists from spotify in VC?

slate swan
#

im trying to do that the bot takes a random image from a site and sends it to the channel but it says syntax error on embed

@client.event
async def waifu(self, ctx, arg): embed = discord.Embed( title = 'waifu',
    description = 'waifu', colour = discord.Colour.purple())embed.set_image(url= "websiteurl.format(arg)) embed.set_footer(text="")")
    await ctx.send(embed=embed)

lets not talk about the name btw

valid galleon
#

its pretty easy to use too

slate swan
valid galleon
slate swan
maiden fable
valid galleon
valid galleon
valid galleon
#

easier to use as well

maiden fable
valid galleon
#

convert the code to asyncpraw once it works

slate swan
#

how to make my bot join a server via invite?

unkempt canyonBOT
#

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

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

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

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

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

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

i want like !join invitecode then the bot joins the server

#

not a thing?

keen talon
valid galleon
valid galleon
slate swan
#

meh

#

ok ty

#

how about using discord api?

#

think its like Authorization: Bot TOKEN

valid galleon
slate swan
#

huh

valid galleon
#

its a very simple command. just make an embed and put the hyperlink in it

slate swan
#

yes but i wanna auto mate it

#

its ok

#

i will use network n that

keen talon
#

saw what ?

slate nymph
#

i have made my bot online using replit now how do i bring it back to offline without changing the code

stark bobcat
#

Did anyone use heroku for hosting their bot

#

Having some problems with it

fossil monolith
#

you’ll need to change the code though

round yarrow
slate nymph
round yarrow
slate nymph
#

thank you

round yarrow
#

np

boreal ravine
slate nymph
#

i m not sure why but your replit looks different from mine @round yarrow

#

there is no stop button aswell

#

can ya tell me why

slate swan
# valid galleon np

it gaved me this error
Traceback (most recent call last):
File "C:\Users\guest\Downloads\bot.py", line 5, in <module>
reddit = praw.reddit(client_id = "XXXXXXXXXXX",
TypeError: 'module' object is not callable

slate nymph
#

why is my replit different from yours

slate swan
slate nymph
#

i dont have a stop button either

slate swan
#

and they are using a web server to keep their repl running 24*7 so a webpage appears

slate swan
slate swan
slate nymph
#

also my bot is running forever even tho i dont have any web serer

#

server*

slate swan
#

hacker plan ig

sweet pilot
#

means you kinda have a server in replit. but not exactly

slate nymph
#

wheres the stop button tho?

sweet pilot
#

its a terminal so press ctrl + c

slate nymph
#

in replit?

#

oh k i got it

#

GUYS

#

i dont know but my bot is alway online

hollow dock
#
@bot.command()
async def coinflip(ctx,message,message1):
  await open_account(ctx.author)
  users = await get_bank_data()
  user = ctx.author
  if message1 is None:
    await ctx.send("Please Type how much you are Gambling.")

    money = message1

  
    if random.choice(determine_flip) == message:
        embed = discord.Embed(title="Toss", description=f"{ctx.author.mention} Flipped coin, YOU **WONN**! {money} coins")
        users[str(user.id)]["Wallet"] += money
        await ctx.send(embed=embed)

    else:
        embed = discord.Embed(title="Toss", description=f"{ctx.author.mention} Flipped coin, YOU **LOST**!")
        users[str(user.id)]["Wallet"] -= money
        await ctx.send(embed=embed)    

    with open("bank.json","w") as f:
        json.dump(users,f)```
#

isn't showing any error but not working

#

any idea what's wrong

dry pelican
#

Hello. I am taking input from the user as : value, first unit and second unit. I want to convert the value from the first unit to the second unit, any idea how will I do that, the units can range from anything

maiden fable
dry pelican
#

like i enter

#

!convert 10mm cm
This should return 1 cm.

maiden fable
#

ah

dry pelican
#

I made one but it is specific to certain units. I need to make it for all units or most of them.

maiden fable
#

You will have to convert yourself

#

I don't think there is a way to do so in dpy

#

u can see the math lib if there is something

#

!d math

unkempt canyonBOT
#

This module provides access to the mathematical functions defined by the C standard.

These functions cannot be used with complex numbers; use the functions of the same name from the cmath module if you require support for complex numbers. The distinction between functions which support complex numbers and those which don’t is made since most users do not want to learn quite as much mathematics as required to understand complex numbers. Receiving an exception instead of a complex result allows earlier detection of the unexpected complex number used as a parameter, so that the programmer can determine how and why it was generated in the first place.

full lily
hollow dock
full lily
#

that was just something I noticed, not the problem at hand

#

what part isn't working?

slate swan
#

how check if bot play something now?

hasty iron
#

!d discord.VoiceClient.is_playing

unkempt canyonBOT
surreal sierra
#

any reason why the msg doesnt get deleted?

        await ctx.send(embed=random.choice(errormsg)).delete_after(4)
storm brook
#
await ctx.send(embed=random.choice(errormsg)), delete_after=4)```
slate swan
#

it keeps saying await is out of function and i added a : and it said invalid syntax how do i fix it?

em.set_image(url = url)
await ctx.send(embed = em)
slate swan
# storm brook show full code

top = subreddit.top(limit = 5)

for submission in top:
    all_subs.append(submission)

random_sub = random.choice(all_subs)

name = random_sub.title
url = random_sub.url

em = discord.Embed(title = name)

em.set_image(url = url)
await ctx.send(embed = em)
storm brook
slate swan
# storm brook show full the function

@client.commmand()
async def animeme(ctx):
    subreddit = reddit.subreddit("Animemes")
all_subs = []

top = subreddit.top(limit = 5)

for submission in top:
    all_subs.append(submission)

random_sub = random.choice(all_subs)

name = random_sub.title
url = random_sub.url

em = discord.Embed(title = name)

em.set_image(url = url)
await ctx.send(embed = em)
storm brook
#

check indentation

maiden fable
#

!indent

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

slate swan
storm brook
storm brook
#
@client.command()
async def animeme(ctx):
    subreddit = reddit.subreddit("Animemes")
    all_subs = []

    top = subreddit.top(limit = 5)

    for submission in top:
        all_subs.append(submission)

    random_sub = random.choice(all_subs)

    name = random_sub.title
    url = random_sub.url

    em = discord.Embed(title = name)

    em.set_image(url = url)
    await ctx.send(embed = em)```
slate swan
slate swan
storm brook
#

no

slate swan
#

ok

storm brook
#

wait there is triple m in command

slate swan
#

no

#

nvm

slate swan
storm brook
#

show full code

#

you didn't defined the client in above line ig

slate swan
#

or just client.command

storm brook
#

@client.command()

slate swan
# storm brook show full code
import discord
import time
import praw

reddit = praw.Reddit(client_id = "XXXXXXXXXXX",
                     client_secret = "XXXXXXXXXXXXXXX",
                     username = "XXXXXXXXXXXXXXXXX",
                     password = "XXXXXXXXXXXXXXXXX",
                     user_agent = "XXXXXXXXXXXXXXXX")

@client.command()
async def animeme(ctx):
    subreddit = reddit.subreddit("Animemes")
    all_subs = []

    top = subreddit.top(limit = 5)

    for submission in top:
        all_subs.append(submission)

    random_sub = random.choice(all_subs)

    name = random_sub.title
    url = random_sub.url

    em = discord.Embed(title = name)

    em.set_image(url = url)
    await ctx.send(embed = em)
storm brook
#

lmao

#

add this after 3rd line also from discord.ext import commands``````python client = commands.Bot(command_prefix=">", help_command=None)

maiden fable
slate swan
slate swan
storm brook
slate swan
storm brook
slate swan
storm brook
#

animeme

slate swan
storm brook
# slate swan ok ok
import discord
from discord.ext import commands
import time
import praw
import random

client = commands.Bot(command_prefix=">", help_command=None)

reddit = praw.Reddit(client_id = "XXXXXXXXXXX",
                     client_secret = "XXXXXXXXXXXXXXX",
                     username = "XXXXXXXXXXXXXXXXX",
                     password = "XXXXXXXXXXXXXXXXX",
                     user_agent = "XXXXXXXXXXXXXXXX")

@client.command()
async def animeme(ctx):
    subreddit = reddit.subreddit("Animemes")
    all_subs = []

    top = subreddit.top(limit = 5)

    for submission in top:
        all_subs.append(submission)

    random_sub = random.choice(all_subs)

    name = random_sub.title
    url = random_sub.url

    em = discord.Embed(title = name)

    em.set_image(url = url)
    await ctx.send(embed = em)
    

client.run("your_token_here")```
hasty iron
#

!indent

unkempt canyonBOT
#

Indentation

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

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

Example

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

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

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

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

hasty iron
#

once again

storm brook
#

!commands

#

dammit

hasty iron
#

what are you trying to do

forest blade
#

!d discord.ext.commands.Bot.process_commands

unkempt canyonBOT
#

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

This function processes the commands that have been registered to the bot and other groups. Without this coroutine, none of the commands will be triggered.

By default, this coroutine is called inside the [`on_message()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_message "discord.on_message") event. If you choose to override the [`on_message()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_message "discord.on_message") event, then you should invoke this coroutine as well.

This is built using other low level tools, and is equivalent to a call to [`get_context()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") followed by a call to [`invoke()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke").

This also checks if the message’s author is a bot and doesn’t call [`get_context()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_context "discord.ext.commands.Bot.get_context") or [`invoke()`](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.invoke "discord.ext.commands.Bot.invoke") if so.
storm brook
#

I'm using this bot first time lol

#

checking some command

hasty iron
#

next time try it in #bot-commands

storm brook
slate swan
slate swan
reef shell
#

what is a Command.signature?

#

i read the docs but I'm unable to get it

hasty iron
#

!d discord.ext.commands.Command.signature

unkempt canyonBOT
hasty iron
#

!d inspect.signature

unkempt canyonBOT
#

inspect.signature(callable, *, follow_wrapped=True, globals=None, locals=None, eval_str=False)```
Return a [`Signature`](https://docs.python.org/3.10/library/inspect.html#inspect.Signature "inspect.Signature") object for the given `callable`...
dapper cobalt
#

Blanket is faster and got a better keyboard.

hasty iron
#

it uses that

hasty iron
dapper cobalt
#

Do you mean I don't? eyesFinite

reef shell
#

I have a $5 keyboard , poor lemon_sentimental

hasty iron
#

also if you still dont understand that, you can go and mess around with it a bit

slate swan
#

I'm trying to add a reaction w discords rest api but it shows method not allowed json, is the endpoint wrong or smth?
This is my code

 requests.post("https://discord.com/api/v8/channels/866260548714627073/messages/888086722573910052/reactions", headers=headers, json={'reactions':['✔️']}).json()
hasty iron
#

the error is pretty clear no?

#

the HTTP method is not allowed for that route

#

which is POST

slate swan
#

i put the prefix and it doesnt execute the command and it doesnt show a error?

import discord
import time
import praw
from discord.ext import commands
client = commands.Bot(command_prefix = "$animeme", help_command = None)
reddit = praw.Reddit(client_id = "XXXXXXXXXXXXXX",
                     client_secret = "XXXXXXXXXXXXXXXXXX",
                     username = "XXXXXXXXXXXXXXXXXXXX",
                     password = "XXXXXXXXXXXXXXXXXXXX",
                     user_agent = "XXXXXXXXXXXXXXXXXXX")


@client.command()
async def animeme(ctx):
    subreddit = reddit.subreddit("Animemes")
    all_subs = []

    top = subreddit.top(limit = 5)

    for submission in top:
        all_subs.append(submission)

    random_sub = random.choice(all_subs)

    name = random_sub.title
    url = random_sub.url

    em = discord.Embed(title = name)

    em.set_image(url = url)
    await ctx.send(embed = em)
hasty iron
#

are you actually running the bot

slate swan
#

yes

pliant gulch
#

Isn't adding reactions supposed to be a PUT request???

#

And you would need to add authorization headers seems like you are already passing headers

hasty iron
#

oh right, and also its better to have a single requests session (i think)

hasty iron
slate swan
hasty iron
#

and use asyncpraw cuz praw is blocking

maiden fable
pliant gulch
#

discord.Route and request session are two WHOLE different things

#

discord.Route doesn't even make a request

hasty iron
#

its discord.http.Route

pliant gulch
#

It represents an endpoint

slate swan
hasty iron
#

wdym where

slate swan
hasty iron
#

anyways can you add an on_ready event inside your code, print something there, and rerun your code and see if it prints

#

also

#

are you sure you're invoking the bot correctly

slate swan
slate swan
hasty iron
#

cuz the prefix is $animeme

#

so it would be $animemeanimeme

slate swan
hasty iron
#

errors?

slate swan
# hasty iron errors?

nah i think i have the problem i put:

client = discord.Client()
client = commands.bot
#

i should put a 2 in second client right?

hasty iron
#

thats like, way way different from what you sent earilier

slate swan
#

oh sorry

hasty iron
#

why is there two definitions now

#

and why commands.bot

#

its commands.Bot

slate swan
#

give me a sec

#

when streaming audio from a url can you do before_options={'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 1'} in discord.FFmpegPCMAudio? because i do this and i can get it to reconnect after it breaks or smth

slate swan
grim oar
#

No why

slate swan
#

do this ^

grim oar
#

You are generally recommended to name the instance bot

slate swan
#

bc the instance Client is used for user accounts

slate swan
#

which if you do use it for a user account u will be banned from discord

grim oar
#

What pithink

slate swan
#

its called selfbotting

#

!selfbot

#

!ytdl

#

?

#

just dont self bot

grim oar
#

but who said anything about selfbots

slate swan
#

yeah

#

the instance discord.Client is used for user accounts usaly

slate swan
grim oar
#

No what

slate swan
#

thats why there is commands.Bot

#

for bots

#

like my bot

grim oar
grim oar
slate swan
slate swan
grim oar
slate swan
slate swan
#

can you pls help me

#

when streaming audio from a url can you do before_options={'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 1'} in discord.FFmpegPCMAudio? because i do this and i can get it to reconnect after it breaks or smth the audio stops before its acualy finished

jade jolt
#

what url

#

@slate swan

round yarrow
#

maybe just close the tab

#

and then the bot stops working...unless uk you have a third party hosting service or have used flask to host it or maybe have replit hacker

slate swan
#

you forgor the open at thr line file = ('ignore.txt' 'w+')

willow vine
#

hey is there any other way other than replit + uptime bot to host my bot for free.. for some reason it goes down

reef shell
#

Any free hosting can't guarantee you a reliable uptime

#

But you can try heroku for learning

willow vine
#

hmm

slate swan
dapper cobalt
#

May I know why did you use CSS syntax highlighting and not Python?

dapper cobalt
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

dapper cobalt
#

Python's would make it much better.

reef shell
dapper cobalt
#
msg_dump_channel = 886496848196542514
ignoreusers = []

@bot.event
async def on_message(message: discord.Message):

     channel = bot.get_channel(msg_dump_channel)
     
     file = ('ignore.txt' 'w+')
     file.write (int(message.author.id))


     if message.author == bot.user or int(message.author.id) in ignoreusers:
          return
     if message.guild is None and not file:



          iduser = message.author.id
          nameuser = message.author.name
          text = message.content


          embed = discord.Embed(title = "Личные сообщение бота: ", description = (f"css\n{ text }"), color = 0x1f8b4c)
          embed.set_footer (text =f"ID автора: {iduser} | Ник автора: {nameuser}")
          embed.timestamp = datetime.utcnow()
          await channel.send(embed = embed)
     await bot.process_commands(message)
slate swan
#

lol

dapper cobalt
#

CSS makes only websites pretty, not Discord messages!

jade jolt
#

hm.

tall agate
#

any libraries i can use to play music for le bot (besides ytdl)

slate swan
#

when streaming audio from a url can you do before_options={'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 1'} in discord.FFmpegPCMAudio? because i do this and i can get it to reconnect after it breaks or smth the audio stops before its acualy finished

slate swan
jade jolt
#

not you lol

tall agate
#

no if theres any legal way at all to stream songs

#

on a bot

jade jolt
#

do you plan on buying the legal rights to use them

#

or just use noncopyright songs

tall agate
#

oH ok ty

slate swan
#

can someone please help me

jade jolt
#

with

jade jolt
#

try it and see

slate swan
#

i have

#

hundreds of times

#

many different combinations

#

it still stops playing the sound middle of it and no errors happen

jade jolt
#

could be something with discord

slate swan
#

i doubt it

#

like 100% boubt it

#

is there any way to active some sort of debug mode for ffmpeg that spits out infomations no matter what

jade jolt
#

im sure there is

slate swan
#

because if there is then the hundreds of google results i have looked throu are dumb and will never work because i have spent the last 7 hours trying to get it to not stop in the middle

brave vessel
jade jolt
#

discord mp3 url

brave vessel
#

Ah, alright, good

#

I was just making sure it isn't breaking TOS lol

jade jolt
#

yeah

#

try downloading the file and play it like that?

slate swan
slate swan
jade jolt
#

delete the file after its been played

slate swan
#

bad read write speed

#

like realy bad

#

im on a hdd

#

from like 1969

jade jolt
#

i am too

#

but it doesnt take that long

slate swan
#

😭

#

it takes 20min to load up windows

jade jolt
#

bruh what

hasty iron
#

ur computer surely cant be that bad

jade jolt
#

sounds like its infected

slate swan
#

nah im joking not downloading the mp3 files tho

stiff nexus
#
      if not self.persistent_views_added:
        self.add_view(SelfRoles(), message_id=888129416193007706)
        self.persistent_views_added = True
```this is in on_connect ^^^
```py
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 351, in _run_event
    await coro(*args, **kwargs)
  File "/home/runner/-2/owner.py", line 546, in on_connect
    self.add_view(SelfRoles(), message_id=888129416193007706)
AttributeError: 'owner' object has no attribute 'add_view'
```help???
hasty iron
#

what is owner

stiff nexus
hasty iron
#

a cog doesnt have an add_view method

stiff nexus
#

why

vale root
#

Is there a way to make my bot do ctx.send when it is shutting down

#

like when it goes offline or do I have to say it?

hasty iron
#

on_disconnect event (can be called multiple times)

vale root
#

Thats for dcing a vc?

#

So where i have my on start i would put under that

on_disconnect
await ctx.send("Bot is going down!")

hasty iron
#

wat

slate swan
#

what's that

#

!d discord.on_disconnect

unkempt canyonBOT
#

discord.on_disconnect()```
Called when the client has disconnected from Discord, or a connection attempt to Discord has failed. This could happen either through the internet being disconnected, explicit calls to close, or Discord terminating the connection one way or the other.

This function can be called many times without a corresponding [`on_connect()`](https://discordpy.readthedocs.io/en/stable/api.html#discord.on_connect "discord.on_connect") call.
main path
slate swan
#

nice

#

get the channel

vale root
#

Thanks

main path
#

👍

vale root
#

wait rq how would i make it send a msg?

main path
#

hmm

slate swan
#

!d discord.ext.commands.Bot.get_channel

unkempt canyonBOT
main path
#

Actually I am facing the same problem as you.. I am asking help in another server and waiting for a response

vale root
#

oh lol

slate swan
#

why not ask here lmao

main path
#

cuz there is much better

vale root
#

just cus i made a bot that im only running on my pc for reasons and want a event to show its shutting down

slate swan
#

the dpy server?

main path
#

They are very good in pycord

slate swan
#

pycord

#

is that a 3rd party lib?

vale root
#

lofma

hasty iron
#

isnt that the other shit fork

maiden fable
#

Can I run a coro with bot.loop.run_until_complete?

hasty iron
#

thats the whole point of it

#

but once the bot starts, you cannot

maiden fable
#

Oh

hasty iron
#

bot.run calls loop.run_forever

#

loop.run_until_complete requires the loop to not be running

maiden fable
#

Hmm

main path
hasty iron
#

use loop.create_task instead

maiden fable
#

Ah ok

main path
maiden fable
#

Well I want to run the async function in the init of the class

slate swan
hasty iron
main path
#

eh...

hasty iron
#

but when you reload the cog (via command) it will raise an error

slate swan
#

I'm just gonna wait and see

main path
hasty iron
maiden fable
#

So I should use create_task and be on the safe side?

hasty iron
#

yeah sure

maiden fable
#

Oh cool

ancient latch
#

is it allowed if i can ask a question on how to create a queue for my music bot?

stiff nexus
#
class PaginatorView(discord.ui.View):
    def __init__(self, ctx, pages: Pages, embed, timeout, show_page_count):

        super().__init__(timeout=timeout)

        self.ctx = ctx
        self.pages = pages
        self.embed = embed
        self.show_page_count = show_page_count
        self.children[5].disabled = True
        
        if self.pages.cur_page == 1:
            self.children[0].disabled = True
            self.children[1].disabled = True
            

    def lock_bro(self):
        self.children[5].disabled = True

        if self.pages.cur_page == self.pages.total:
            self.children[0].disabled = False
            self.children[1].disabled = False

            self.children[3].disabled = True
            self.children[4].disabled = True
            

        elif self.pages.cur_page == 1:
            self.children[0].disabled = True
            self.children[1].disabled = True

            self.children[3].disabled = False
            self.children[4].disabled = False
            

        elif 1 < self.pages.cur_page < self.pages.total:
            for b in self.children:
                b.disabled = False
maiden fable
#

!paste dude

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

stiff nexus
#

its not disabling ```py
@discord.ui.button(disabled=True,label='Skip to page...', style=discord.ButtonStyle.blurple)
async def numbered_page(self, button: discord.ui.Button, interaction: discord.Interaction):
#lets you type a page number to go to
if self.input_lock.locked():
await interaction.response.send_message('Already waiting for your response...', ephemeral=True)
return

    if self.message is None:
        return

    async with self.input_lock:
        channel = self.message.channel
        author_id = interaction.user and interaction.user.id
        await interaction.response.send_message('What page do you want to go to?', ephemeral=True)

        def message_check(m):
            return m.author.id == author_id and channel == m.channel and m.content.isdigit()

        try:
            msg = await self.ctx.bot.wait_for('message', check=message_check, timeout=30.0)
        except asyncio.TimeoutError:
            await interaction.followup.send('Took too long.', ephemeral=True)
            await asyncio.sleep(5)
        else:
            page = int(msg.content)
            await msg.delete()
            await self.show_checked_page(interaction, page - 1)
maiden fable
#

Dude

stiff nexus
maiden fable
#

It has covered my whole screen....

stiff nexus
#

oh

maiden fable
#

I have zoomed out, then only I can see

#

The zoom is at 80, as u can see

vale pendant
#

not that big lol

hybrid fjord
#

new feature clearly, can someone link the documentation for it?

hybrid fjord
#

cheers

maiden fable
#

(:

ancient latch
#

is it allowed if i can ask a question on how to create a queue for my music bot?

maiden fable
#

YTDL is against ToS, so I am afraid not allowed

ancient latch
#

my bad

sudden sage
#

hey guys im new in coding and i want to create a bot i dont want him to do anything he should just stay online and print current game nothing more can someone give me the code and how i can run it i already create a application at the dc dev portal

jagged hamlet
#

Is there a way to store additional data in a view/button, to recall in future when the button is clicked? I don't want to have to create a "dummy button" to hold that info

jagged hamlet
sudden sage
#

current application

#

,,Plays VALORANT" for example @jagged hamlet

jagged hamlet
#

so you want it to display an activity in its profile

sudden sage
#

exactly

jagged hamlet
#

cool, I can do that

#
import discord

client = discord.Client(status=discord.Status.online, activity=discord.Game(name="VALORANT (replace this string with whatever)"))

client.run("YOUR_BOT_TOKEN_GOES_HERE")

@sudden sage this dead simple script should work

jagged hamlet
sudden sage
jagged hamlet
#

As long as you have the discord.py package installed, it'll work

sudden sage
#

which IDE would you use

craggy cloak
#

i am trying to use webhook

#

But when someone voted this will pop up, how do i fix this?

slate swan
#

use an F string

craggy cloak
#

You can't use strings in that?

#

that is a Webhook

jagged hamlet
#

I'd just run the Python script as-is

slate swan
sudden sage
jagged hamlet
craggy cloak
#

Normally there should be a user here somewhere, but it's not there?

jagged hamlet
sudden sage
#

im currently on windows

jagged hamlet
sudden sage
#

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

slate swan
#

Error reading or writing history file 'C:\Users\my naem\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt': Access to the path is denied.
um

#

erm why did i get this

jade jolt
#

is this related to discord

slate swan
#

mhm so how do i fix it

#

also ```async def on_message(self, message):
# don't respond to ourselves
if message.author == self.user:
return

    if message.content == 'Hey':
        await message.channel.send('Shalom, how is it going?')``` why doesnt this work? it worked before
#
intents = discord.Intents.default()
intents.members = True```
slate swan
#

hello guys

jagged hamlet
slate swan
#

can anyone help me please?

jagged hamlet
kindred epoch
slate swan
#
from discord.ext import commands

#discord.Intents.all()
intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix='!', intents=intents)

@client.command()
async def clear(ctx, ammount=10):
        await ctx.channel.purge(limit=ammount)

async def on_message(self, message):
        # don't respond to ourselves
        if message.author == self.user:
            return

        if message.content == 'Hey':
            await message.channel.send('Shalom, how is it going?')

client.run('token')``` @kindred epoch
slate swan
jagged hamlet
slate swan
#

dont think so

jagged hamlet
slate swan
#

hm weird

kindred epoch
slate swan
jagged hamlet
# slate swan

First things first, it's __init__, not __innit__. You'll have to fix that for it to work.
Next up, lines 9-17 are over-indented.

jagged hamlet
kindred epoch
# slate swan

error is pretty clear, if you know enough python you should be able to fix it by yourself

slate swan
#

i'm learning python

jagged hamlet
sudden sage
#

so i opened python

jagged hamlet
# sudden sage so i opened python
  1. Run the command python -m pip install discord.py in the terminal
  2. Create a file with the .py extension
  3. Paste in the code
  4. Edit the necessary values
  5. Run the file
sudden sage
#

SyntaxError: invalid syntax

jagged hamlet
#

what?

sudden sage
#

it shows up

jagged hamlet
#

when running the file?

sudden sage
#

i did the 1st thing

craggy cloak
jagged hamlet
sudden sage
#

right now it shows up Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

jagged hamlet
kindred epoch
jagged hamlet
sudden sage
#

i did

#

maybe restart pc?

craggy cloak
jagged hamlet
sudden sage
jagged hamlet
# craggy cloak

yes, I have no idea what you're sending that from, but you need to replace user with the actual user ID

#

how you do that depends on you

craggy cloak
#

Normally there should be user here but it is not there?

jagged hamlet
#

then send the full path to that folder

sudden sage
slate swan
#

not our stuff

#

and your code doesn't match

craggy cloak
#

Maybe this?

sudden sage
#

rn it shows "-m" is either misspelled or
could not be found.

#

it works

flat solstice
#

how do you check if a msg has a embed or not? it's just py if message.Embedsright? and then if I wanted to get attributes out it would be py message.Embed[0].description[0]

bleak fulcrum
sudden sage
#

rn if i want to paste the code it shows The command "import" is either spelled incorrectly or
could not be found. @jagged hamlet

full lily
#

it's one or the other. I would stick with bot.

jagged hamlet
sudden sage
jagged hamlet
slate swan
#

what's wrong with line 3?

full lily
bleak fulcrum
#

whos TOS?

full lily
#

youtube's

full lily
slate swan
#

look

#

@commands.command()

bleak fulcrum
#

this guy is your ytd also?

full lily
# slate swan

the decorator should be aligned in indentation with the function definition

#

look at line 19

#

and look at line 21, the line after a function definition should be indented

slate swan
#

ok

full lily
#

your next function is outside of the class, you need to indent it to have it inside

#

wait no it's not

#

your first two are inside of the init

slate swan
#

uh

bleak fulcrum
#

@full lily any advice on how to make the bot dc from voice after the sleep? i tried running it in it's own thread. I also tried to make the sleep asyncronous but i muck up the hearbeats

bleak fulcrum
#

106 is commented out

#

i cant include it at 168, it disconnects immediately

#

i cant include it where it is, that part is threaded and seperate

slate swan
#

how i can remove this

full lily
#

threading does not mix with asyncio

bleak fulcrum
#

sure it does, im currently doing it

#

how would i restructure what im doing though, to make it better

slate swan
#
async def clear(ctx, ammount=90):
        await ctx.channel.purge(limit=ammount)```  doesnt work?
full lily
bleak fulcrum
#

that code i posted works... just badly

#

it doesnt dc after the file is done transmitting

#

so i know i built it janky and hacky

#

im trying to fix that I need to learn

slate swan
#

EY HELO ME MAYBE?

bleak fulcrum
#

@slate swan your behavior makes me not want to help you with the limited knowledge I do have

slate swan
#

im trynne get help i gtg soon sry

bleak fulcrum
#
bot = commands.Bot(command_prefix='?', description=description)
@bot.command()
async def clear(ctx, ammount=90):
        await ctx.channel.purge(limit=ammount)
#

try that tho

vale pendant
slate swan
#

command doesnt work

bleak fulcrum
#

instead of calling it a client

vale pendant
#

Any errors?

bleak fulcrum
#
from discord.ext import commands
#

put at top

slate swan
#

nop

bleak fulcrum
#

what it is doing?

slate swan
#

So. I want to make a command called status. And I was wandering if could take some things from a game called "FiveM" or "GTA RP". I would like it to say if the server is online and how many players are in the server. Is this even possible??

#

nothing

bleak fulcrum
#

@slate swan if they include a api sure

full lily
bleak fulcrum
#

@slate swan there is nothing in the console?

slate swan
#
from discord.ext import commands

#discord.Intents.all()
intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix='!', intents=intents)

@client.command()
async def clear(ctx, ammount=90):
        await ctx.channel.purge(limit=ammount)

class MyClient(discord.Client):

    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        word_list = ['Hore', 'faen', 'Faen', 'hore', 'fitte', 'Fitte', 'fuck', 'Fuck']

        # don't respond to ourselves
        if message.author == self.user:
            return

        messageContent = message.content
        if len(messageContent) > 0:
            for word in word_list:
                if word in messageContent:
                    await message.delete()
                    word_list = ['Hore', 'faen', 'Faen', 'hore', 'Fitte', 'fitte', 'fuck', 'Fuck']
            
        messageattachments = message.attachments
        if len(messageattachments) > 0:
            for attachment in messageattachments:
                if attachment.filename.endswith(".dll"):
                    await message.delete()
                    await message.channel.send("No DLL's allowed!")
                elif attachment.filename.endswith('.exe'):
                    await message.delete()
                    await message.channel.send("No EXE's allowed!")
                else:
                    break
                
client = MyClient()              
client.run('token')``` here is the code
bleak fulcrum
#

@slate swan well your token isnt "token"

slate swan
#

i kno

bleak fulcrum
#

and you need a bot, not a client

slate swan
#
  File "main.py", line 3, in <module>
    import music
  File "/home/runner/Music-Bot/music.py", line 19
    @commands.command()```
#

how to fix

#

and it's this part of the error

bleak fulcrum
#

i would use bot instead of client

#

i couldnt get client to work either

#

@slate swan you are trying to censor people?

slate swan
#

yuh

#

it works so

bleak fulcrum
#

ok i dont support censorship, so im done

slate swan
#

bro its for a esport thing

slate swan
bleak fulcrum
#

i dont care at all what the use-case is lol

vale pendant
#

not a valid reason not to help someone

#

it's his choice and he's asking for help

slate swan
vale pendant
#
  • censoring exe is not a bad thing
#

or cuss words as well

bleak fulcrum
#

you can hook their api with requests if they support an api

slate swan
#

jesus just stop being a brat

#

sure ur against it but there is 10 year old kids

#

do u want them to start saying racist shit

#

hm?

bleak fulcrum
#

i think it's their right to do so yea

full lily
#

👀

bleak fulcrum
#

you cant be pro free speech and then get mad people say stuff you dont agree with

vale pendant
#

It's not that he doesn't agree, it's not letting people ruin other people feelings and put them down

slate swan
#

ok this gone too far anyone else wanna help me?

bleak fulcrum
#

look im not trying to get political, there are other people here

vale pendant
#

political? this a python server to get help

vale pendant
vale pendant
slate swan
#
async def clear(ctx, ammount=90):
        await ctx.channel.purge(limit=ammount)``` this line doesnt workj
vale pendant
#

It's not that line.

slate swan
#

u get what i mean

#

im new to this

vale pendant
#

Therefore I'm going to walk you through it.

#

Start by deleting your MyClient class

kindred epoch
vale pendant
#

Yeah that's true

slate swan
#

what's wrong?

bleak fulcrum
#

I dont think they are going to help man, they dont wanna help youtube download bot makers

kindred epoch
# slate swan

is there a module named "music" that you downloaded?

slate swan
#

Oooh

bleak fulcrum
#

poetry not another package manager lol

#

pip wasnt good enough?

slate swan
#

@vale pendant

hardy yoke
slate swan
#

its for a music bot

hardy yoke
#

that doesn't answer the question but if it is a cog you don't need to import it, if it's a library you need to download it first via repl's package manager

slate swan
#

i dont know much about python

#

look

vale pendant
slate swan
#

music.py:

from discord.ext import commands
import youtube_dl

class music(commands.Cog):
  def __init__(self, client):
    self.client = client

    @commands.command()
    async def join(self,ctx):
        if ctx.author.voice is None:
            await ctx.send("You're not in voice channel")
        voice_channel = ctx.author.voice_channel
        if ctx.voice_client is None:
          await voice_channel.connect()
        else:
          await ctx.voice_client.move_to(voice_channel)

 @commands.command()
   async def disconnect(self,ctx):
     await ctx.voice_client.disconnect()

 @commands.command()
 async def play(self,ctx,url):
   ctx.voice_client.stop()
   FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_stramed 1 -reconect_delay_max 5', 'options': '-vn'}
   YDL_OPTIONS = {'format':"bestaudio"}
   vc = ctx.voice_client

   with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
     info = ydl.extract_info(url, dowload=False)
     url2 = info['formats'] [a] ['url']
     source = await discord.FFmpegOpusAudio.from_proble(url2, ++FFMPEG_OPTIONS)
     vc.play(source)

 @commands.comand()
 async def pause(self,ctx):
   await ctx.voice_client.pause()
   await ctx.send("Paused Music")

 @commands.comand()
 async def resume(self,ctx):
   await ctx.voice_client.resume()
   await ctx.send("Resume Music")

def setup(client):
  client.add_cog(music(client))
slate swan
#

how to make it so that when sending a message to a private message on behalf of a bot player, the bot should check in a text file whether its id is in the text file and if the code found its id in the text file "ignore.txt", then let the bot just start ignoring it
in this code:

msg_dump_channel = 886496848196542514
ignoreusers = []

@bot.event
async def on_message(message: discord.Message):

     channel = bot.get_channel(msg_dump_channel)
     
     if message.author == bot.user or message.author.id in ignoreusers:
          return
     if message.guild is None and not message.author.bot:



          iduser = message.author.id
          nameuser = message.author.name
          text = message.content


          embed = discord.Embed(title = "Личные сообщение бота: ", description = (f"css\n{ text }"), color = 0x1f8b4c)
          embed.set_footer (text =f"ID автора: {iduser} | Ник автора: {nameuser}")
          embed.timestamp = datetime.utcnow()
          await channel.send(embed = embed)
     await bot.process_commands(message)```
bleak fulcrum
#

@slate swan yo, do you just wanna get something up and running, or do you want something that you are building on top of?

full lily
slate swan
#
from discord.ext import commands
from discord.utils import MyClient

#discord.Intents.all()
intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix='!', intents=intents)

@client.command()
async def clear(ctx, ammount=90):
        await ctx.channel.purge(limit=ammount)

class MyBot(discord.Client):

    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        word_list = ['Hore', 'faen', 'Faen', 'hore', 'fitte', 'Fitte', 'fuck', 'Fuck']

        # don't respond to ourselves
        if message.author == self.user:
            return

        messageContent = message.content
        if len(messageContent) > 0:
            for word in word_list:
                if word in messageContent:
                    await message.delete()
                    word_list = ['Hore', 'faen', 'Faen', 'hore', 'Fitte', 'fitte', 'fuck', 'Fuck']
            
        messageattachments = message.attachments
        if len(messageattachments) > 0:
            for attachment in messageattachments:
                if attachment.filename.endswith(".dll"):
                    await message.delete()
                    await message.channel.send("Er ikke lov med .dll")
                elif attachment.filename.endswith('.exe'):
                    await message.delete()
                    await message.channel.send("Er ikke lov meg .exe")
                else:
                    break
                
bot = MyBot()              
bot.run('my token cant be bothered to change after this so dont mind the token it self :)')```
#

whats wrong witht hte !clear command?

bleak fulcrum
#

well the way ill help is much different

#

you want me to just fix your problems?

slate swan
#

i install visual code

bleak fulcrum
#

or help you learn

slate swan
#

just fix, bc learn is hard

silver wolf
slate swan
#

bc its a link

bleak fulcrum
#

@slate swan dm me man, that way other people can learn here

slate swan
#

ok, wait i will open my dm

#

done

#

Is anyone familiar with linking stock market data to a bot? Not sure where to go to grab info such as the top gainers in premarket.

#

i know y'all are supposed to help with coding but is there any good ways to get bots into servers

kindred epoch
#

promoting and uploading it on websites like top.gg ig

slate swan
#

how to make it so that when sending a message to a private message on behalf of a bot player, the bot should check in a text file whether its id is in the text file and if the code found its id in the text file "ignore.txt", then let the bot just start ignoring it
in this code:

msg_dump_channel = 886496848196542514
ignoreusers = []

@bot.event
async def on_message(message: discord.Message):

     channel = bot.get_channel(msg_dump_channel)
     
     if message.author == bot.user or message.author.id in ignoreusers:
          return
     if message.guild is None and not message.author.bot:



          iduser = message.author.id
          nameuser = message.author.name
          text = message.content


          embed = discord.Embed(title = "Личные сообщение бота: ", description = (f"css\n{ text }"), color = 0x1f8b4c)
          embed.set_footer (text =f"ID автора: {iduser} | Ник автора: {nameuser}")
          embed.timestamp = datetime.utcnow()
          await channel.send(embed = embed)
     await bot.process_commands(message)```
slate swan
#

i can't even use top.gg cuz my phone number is blacklisted 🙄

reef trail
#
@commands.cooldown(1, 3, commands.BucketType.user)
@commands.command(aliases=['colorme', 'colourme', 'color'], usage="`tp!colorme <color>`")
async def give_color(self, ctx, *, role: Creamy = None):
    """Allows users to give themselves a color role. do `tp!colors` to see what you can add to Yourself
        If there arent any colors, do `tp!rainbow` to create the roles"""
    with open('colors.json', 'r') as f:
        data = json.load(f)
        color_roles = [discord.utils.get(
            ctx.guild.roles, name=x) for x in data]
        if role is None:
            m = await ctx.send("Okie, starting to remove your roles..")
            for x in color_roles:
                if x in ctx.author.roles:
                    await asyncio.sleep(0.5)
                    await ctx.author.remove_roles(x)
            await m.edit(content="Role(s) removed.", delete_after=delay)
        elif role in color_roles:
            await ctx.author.add_roles(role)
            await ctx.reply(f"Alright, {role} was given.\n**Reminder, if you want to remove your colors, just run `tp!colorme` just like that to remove them!**")```
 how could i check if the user already has a role before adding a new one?
kindred epoch
#

check which roles the user has, if they said to give the role they already have then send something else

#

or maybe it just raises an error

#

idk

slate swan
#

@slate swan bots as in fake users to join your server?

#

or bots as in helpful bots that carry out functions

full lily
#

if current_server == guild.id: what are you trying to do here

#

on_member_join passes member not ctx

slate swan
#

not like tokens

next heath
#

Can someone help me to make a ban counter on one specific member

kindred epoch
#

?

next heath
#

Im on a server dat a person gets ban like 99 times a day so we whant to make a counter for it

kindred epoch
#

huh

#

a person cant get banned 99 times on the same server

#

unless they unban him and then ban him again

next heath
#

but we un ban him

kindred epoch
#

why do you do that then

next heath
#

for fun

kindred epoch
#

if you want to ban them again?

#

lol no

slate swan
#

hey 13 year old beginner to coding, I'm coding a dc bot rn and it's not working

#

can someone help?

full lily
slate swan
full lily
#

off the top of my head

#

and then check if the member was the person you're looking for

slate swan
#

import discord

from discord.ext import commands

client = commands.Bot(command_prefix = '.')

@client.event
async def on_ready():
await bot.process_commands(message)
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.startswith('compliment me'):
  await message.channel.send('u suck')

if message.content.startswith('LOL'):
  await message.channel.send('licking oversized lameasses')

if message.content.startswith('Compliment me'):
  await message.channel.send('u suck')

if message.content.startswith('insult me'):
  await message.channel.send('u suck')





if message.content.startswith('lol'):
  await message.channel.send('licking oversized lameasses')

if message.content.startswith('Im so cool'):
  await message.channel.send('no your not, fuck you')

if message.content.startswith('Hello'):
  await message.channel.send('no one likes you loser')

@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
await member.kick(reason=reason)

@client.command()
async def ban(ctx, member : discord.Member, *, reason=None):
await member.ban(reason=reason)

client.run('this is where my bot token is, it's correct, double checked it multiple times')

full lily
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

slate swan
full lily
slate swan
#




from discord.ext import commands

client = commands.Bot(command_prefix = '.')

@client.event
async def on_ready():
  await bot.process_commands(message)
  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.startswith('compliment me'):
      await message.channel.send('u suck')

    if message.content.startswith('LOL'):
      await message.channel.send('licking oversized lameasses')

    if message.content.startswith('Compliment me'):
      await message.channel.send('u suck')

    if message.content.startswith('insult me'):
      await message.channel.send('u suck')





    if message.content.startswith('lol'):
      await message.channel.send('licking oversized lameasses')

    if message.content.startswith('Im so cool'):
      await message.channel.send('no your not, fuck you')

    if message.content.startswith('Hello'):
      await message.channel.send('no one likes you loser')

@client.command()
async def kick(ctx, member : discord.Member, *, reason=None):
  await member.kick(reason=reason)

@client.command()
async def ban(ctx, member : discord.Member, *, reason=None):
  await member.ban(reason=reason)

client.run('this is where my bot token is, it's correct, double checked it multiple times')
hasty iron
#

your on_message is inside your on_ready

#

and also process_commands need to be inside the on_message

slate swan
#

um

#

i started coding yesterday

#

so idk what that means

hasty iron
#

so you’re still a python beginner?

kindred epoch
#

lol

hasty iron
#

i suggest you learn the language first

slate swan
#

maybe

#

but then again all you do in python is copy and paste

hasty iron
#

what

slate swan
#

so just gimme instructions and boom

kindred epoch
#

??

kindred epoch
#

yea, no thats not what we do

slate swan
hasty iron
#

serious thing -> question -> "its a joke bro"

#

but anyways

#

you should really learn python before making a discord bot

hasty iron
slate swan
#

maybe

slate swan
full lily
#

Snake sounds pretty difficult actually

#

!kindling

unkempt canyonBOT
#

Kindling Projects

The Kindling projects page on Ned Batchelder's website contains a list of projects and ideas programmers can tackle to build their skills and knowledge.

hasty iron
#

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

twilit adder
#

does anyone know what i did wrong? i know discord_component changed some stuff but it’s showing errors

slate swan
#

!code

unkempt canyonBOT
#

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

dapper cobalt
kindred epoch
#

what do you think?

wicked atlas
#

!d discord.Guild.premium_subscribers

unkempt canyonBOT
wicked atlas
#

I believe it will require some intents

dapper cobalt
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.pydis.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.

twilit adder
twilit adder
#

can u help?

graceful gulch
twilit adder
#

discord-components

#

?

graceful gulch
#

ok

#

can u send the error

#

not a screenshot

#

it’s easier to read

twilit adder
agile goblet
#

read the error

#

Value must be one of...

vale pendant
#

how can I check how much users have a certain role?

kindred epoch
unkempt canyonBOT
kindred epoch
#

use that with len()

vale pendant
#

ahhh thanks!

kindred epoch
#

np

slate swan
#

how to make it so that when sending a message to a private message on behalf of a bot player, the bot should check in a text file whether its id is in the text file and if the code found its id in the text file "ignore.txt", then let the bot just start ignoring it
in this code:

msg_dump_channel = 886496848196542514
ignoreusers = []

@bot.event
async def on_message(message: discord.Message):

     channel = bot.get_channel(msg_dump_channel)
     
     if message.author == bot.user or message.author.id in ignoreusers:
          return
     if message.guild is None and not message.author.bot:



          iduser = message.author.id
          nameuser = message.author.name
          text = message.content


          embed = discord.Embed(title = "Личные сообщение бота: ", description = (f"css\n{ text }"), color = 0x1f8b4c)
          embed.set_footer (text =f"ID автора: {iduser} | Ник автора: {nameuser}")
          embed.timestamp = datetime.utcnow()
          await channel.send(embed = embed)
     await bot.process_commands(message)```
twilit adder
quasi pawn
#

how do make it so that's mentioning the bot is also a prefix?

agile goblet
agile goblet
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/stable/ext/commands/api.html#discord.ext.commands.Bot.command_prefix "discord.ext.commands.Bot.command_prefix") attribute.

Example

```py
bot = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
```...
quasi pawn
#

aight thanks

twilit adder
# agile goblet indeed

should it be like this?
await interaction.respond(type = InteractionEventType(2), embed = paginationList[current], components=[[Button(label = "⏮", id = "backk", style = ButtonStyle.blue), Button(label = "◀️", id = "back", style = ButtonStyle.blue), Button(label = "▶️", id = "front", style = ButtonStyle.blue), Button(label = "⏭", id = "frontt", style = ButtonStyle.blue), Button(label="❌", id = "exit", style=ButtonStyle.red)]])

twilit adder
unkempt canyonBOT
#

Hey @graceful palm!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

graceful palm
#

Hi, I'm trying to make a bot that can run console commands on my PC and output them as a message.
I'm able to run commands like 'taskkill' and 'ping', but if i try something like 'echo', 'cls', or 'start', I get this error:
https://paste.pythondiscord.com/soyeloxiqo.sql
Anyone know how to fix it?
Code:

@bot.command()
async def run(ctx, *, command):
    if str(ctx.message.author.id) == '410281148128690198':
        output = subprocess.check_output(command).decode('utf-8')
        await ctx.message.reply(f'Successfully ran command: {output}')
slate swan
#
from discord.ext import commands
from discord.utils import MyClient

#discord.Intents.all()
intents = discord.Intents.default()
intents.members = True

client = commands.Bot(command_prefix='!', intents=intents)

@client.command()
async def clear(ctx, ammount=90):
        await ctx.channel.purge(limit=ammount)

class MyBot(discord.Client):

    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        word_list = ['Hore', 'faen', 'Faen', 'hore', 'fitte', 'Fitte', 'fuck', 'Fuck']

        # don't respond to ourselves
        if message.author == self.user:
            return

        messageContent = message.content
        if len(messageContent) > 0:
            for word in word_list:
                if word in messageContent:
                    await message.delete()
                    word_list = ['Hore', 'faen', 'Faen', 'hore', 'Fitte', 'fitte', 'fuck', 'Fuck']
            
        messageattachments = message.attachments
        if len(messageattachments) > 0:
            for attachment in messageattachments:
                if attachment.filename.endswith(".dll"):
                    await message.delete()
                    await message.channel.send("Er ikke lov med .dll")
                elif attachment.filename.endswith('.exe'):
                    await message.delete()
                    await message.channel.send("Er ikke lov meg .exe")
                else:
                    break
                
bot = MyBot()              
bot.run('my token')``` help me pls
#

the !clear command doesnt work

#

there is no error the !clear doesnt work thats it

#

binds[z.reactions[ind].emoji.id] = rpl2.content gives the error: 'str' object has no attribute 'id'

#

But according to the reference, id is an attr of emoji??

crude crater
#
@bot.command(aliases=["SERVERINFO", "Serverinfo", "Serverinformation", "SERVERINFORMATION", "serverinformation"])
async def serverinfo(ctx):
        embed = discord.Embed(title="Server information",
                      colour=ctx.guild.owner.colour,
                      timestamp=datetime.utcnow())

        embed.set_thumbnail(url=ctx.guild.icon_url)


        fields = [("ID", ctx.guild.id, True),
                ("Owner", ctx.guild.owner, True),
                ("Region", ctx.guild.region, True),
                ("Created at", ctx.guild.created_at.strftime("%m/%d/%Y %H:%M:%S"), True),
                ("Members", len(ctx.guild.members), True),
                ("Humans", len(list(filter(lambda m: not m.bot, ctx.guild.members))), True),
                ("Bots", len(list(filter(lambda m: m.bot, ctx.guild.members))), True),
                ("Text channels", len(ctx.guild.text_channels), True),
                ("Voice channels", len(ctx.guild.voice_channels), True),
                ("Categories", len(ctx.guild.categories), True),
                ("Roles", len(ctx.guild.roles), True),
                ("\u200b", "\u200b", True)]

        for name, value, inline in fields:
            embed.add_field(name=name, value=value, inline=inline)

        await ctx.send(embed=embed)

is there something wrong with my code?

slate swan
#

how do i fix this problem i cant figure out whats wrong?

File "C:\Users\okimii\Downloads\bot.py", line 18, in animeme
    top = subreddit.top(limit = 5)
AttributeError: 'coroutine' object has no attribute 'top'
slate swan
slate swan
# crude crater can i see code?
import discord
import time
import asyncpraw
from discord.ext import commands
client = commands.Bot(command_prefix ="$",help_command = None)
reddit =  asyncpraw.Reddit(client_id = "XXXX",
                     client_secret = "XXXXXX",
                     username = "XXXXXXXXXXX",
                     password = "XXXXXXXXXXX",
                     user_agent = "XXXXXXXXX")
bot = commands.Bot

@client.command()
async def animeme(ctx):
    subreddit = reddit.subreddit("Animemes")
    all_subs = []

    top = subreddit.top(limit = 5)

    for submission in top:
        all_subs.append(submission)

    random_sub = random.choice(all_subs)

    name = random_sub.title
    url = random_sub.url

    em = discord.Embed(title = name)

    em.set_image(url = url)
    await ctx.send(embed = em)
patent lark
#

why two constructors?

slate swan
#

snow can u help me with something`?

crude crater
#

personally im shit at coding but i think it might be that "top" isnt defined but im probably wrong lmaooo

crude crater
#

ok

final iron
crude crater
#

ah mk

final iron
#

It gets the top submissions from the subreddit

patent lark
crude crater
#

it honestly doesnt make a difference coming from someone whos used both

#

just depends on what you're doing lol

#

or what you wanna do/use it for

slate swan
#
from discord.ext import commands
from discord.utils import MyClient``` it's not "myclient" what is it i don't remember...
patent lark
#

it's not dependent on what you're doing, if you're using discord.ext.commands.Bot you should always use bot as the variable, its better practice-wise so it doesnt get confused with discord.Client().

slate swan
#

snow u talking to me or the other guy?

crude crater
#

it is lol

#

to me

slate swan
#

alr lol

patent lark
slate swan
#

also u should use bot and not client 🙂

crude crater
#

read the link i sent

slate swan
#

wiser can u help me with something?

final iron
#

What is commands.Bot even used for

crude crater
#

it does the same thing but "bot" can do more

crude crater
slate swan
#
from discord.ext import commands
from discord.utils import MyClient``` what is it suppost to be, the "myclient" part i dont remember
patent lark
# final iron What is commands.Bot even used for

discord bots? commands.Bot is far better than discord.Client(), commands.Bot has command decorators, permission check decorators, and tons more. if you're creating a discord bot, using discord.Client() isn't the go-to choice for it.

crude crater
#

what is what supposed to be?

slate swan
#
from discord.ext import commands
from discord.utils import MyClient

#discord.Intents.all()
intents = discord.Intents.default()
intents.members = True

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

@bot.command()
async def clear(ctx, ammount=90):
        await ctx.channel.purge(limit=ammount)

class MyBot(discord.Client):

    async def on_ready(self):
        print('Logged on as', self.user)

    async def on_message(self, message):
        word_list = ['Hore', 'faen', 'Faen', 'hore', 'fitte', 'Fitte', 'fuck', 'Fuck']

        # don't respond to ourselves
        if message.author == self.user:
            return

        messageContent = message.content
        if len(messageContent) > 0:
            for word in word_list:
                if word in messageContent:
                    await message.delete()
                    word_list = ['Hore', 'faen', 'Faen', 'hore', 'Fitte', 'fitte', 'fuck', 'Fuck']
            
        messageattachments = message.attachments
        if len(messageattachments) > 0:
            for attachment in messageattachments:
                if attachment.filename.endswith(".dll"):
                    await message.delete()
                    await message.channel.send("Det er ikke lov med .dll filer.")
                elif attachment.filename.endswith('.exe'):
                    await message.delete()
                    await message.channel.send("Det er ikke lov meg .exe filer.")
                else:
                    break
                
bot = MyBot()              
bot.run('mah token')``` the !clear command doesnt work, doesnt have any errors either
final iron
#

I just realized that I actually use commands.Bot I just named it client

crude crater
slate swan
#

wiser can u help me..?

crude crater
#

yes

slate swan
#

i sendt the code and shit

crude crater
#

oh okay

patent lark
#

i dont think you understand

of course the variable name wont change anything, why would it? of course it will function the same. you could name the variable literally anything and would be fine, maybe if you payed attention to my messages, you'd see that i said its better from the aspect of practice

as i said: if you're using discord.ext.commands.Bot you should always use bot as the variable, its better practice-wise so it doesnt get confused with discord.Client().

#

@crude crater

supple thorn
crude crater
crude crater
final iron
crude crater
slate swan
#

yah

#

wait

#

1 m or 2?

zinc flame
#

I'm building a basic bot, but when I import another file the bot doesn't run. Or if I import the bot into the other file, then that doesn't run. Anyone want to take a look at my code and point out where I'm going wrong?

crude crater
slate swan
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.pydis.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
zinc flame
#
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os
import time
import discord_message

PATH = "C:\\Users\\phult\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\chromedriver.exe"

driver = webdriver.Chrome(PATH)
driver.set_window_size(720, 440)
options = Options()

# URL and page element

product_link = "https://www.bestbuy.com/site/hamilton-beach-burr-coffee-grinder-stainless-steel/6447745.p?skuId=6447745"


def stock_check():
    driver.get(product_link)
    add_to_cart_button = driver.find_element_by_css_selector("div[class=fulfillment-add-to-cart-button]")
    stockStatus = add_to_cart_button.text

    # Loop to check status at timed interval
    while True:
        driver.refresh()
        time.sleep(5)
        if stockStatus == "Sold Out":
            pass
        else:
            print(stockStatus)
        time.sleep(10)

stock_check()
#
import discord
from discord.ext import commands
from dotenv import load_dotenv
import os

bot = commands.Bot(command_prefix="!")
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")


# Initial bot login
@bot.event
async def on_ready():
    print("Logged in as")
    print(bot.user.name)
    print(f"Bot User ID: {bot.user.id}")


@bot.command()
async def stock_Status(ctx):
    await ctx.channel.send("Message")


bot.run(TOKEN)```
crude crater
#
@bot.command()
@commands.has_permissions(manage_messages = True)
async def clear(ctx, amount : int):
    await ctx.channel.purge(limit=amount)
    await ctx.send(f'Message Clearing Complete!')
zinc flame
#

In either direction if I import one to the other, the main file stops running

crude crater
#

@slate swan

slate swan
#

where do i put the amount? do u just write it?

crude crater
#

yes

zinc flame
#

Sorry, I'm still pretty new so sorry if I get any terminology wrong

patent lark
slate swan
#

doesnt work

crude crater
#

whats the error?

zinc flame
slate swan
#

doesnt work

crude crater
#

i dont know then because it should work lol

slate swan
#

weird

patent lark
#

are your commands even being executed? you may have an on_message event and arent processing commands

#

@slate swan

slate swan
#

snow it doesnt work with the censor code

#

they arent being executed

patent lark
#

in your on message event, add await bot.process_commands(message)

#

or client if you are using client

slate swan
#

fixed it i think

patent lark
#

alright

slate swan
#

yep

#

had to remove bot = MyBot()

patent lark
#

👍

zinc flame
#

any thoughts on my issue?

final iron
zinc flame
#

I pasted my code above, I'll drop it in again

#
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os
import time
import discord_message

PATH = "C:\\Users\\phult\\AppData\\Local\\Programs\\Python\\Python39\\Lib\\chromedriver.exe"

driver = webdriver.Chrome(PATH)
driver.set_window_size(720, 440)
options = Options()

# URL and page element

product_link = "https://www.bestbuy.com/site/hamilton-beach-burr-coffee-grinder-stainless-steel/6447745.p?skuId=6447745"


def stock_check():
    driver.get(product_link)
    add_to_cart_button = driver.find_element_by_css_selector("div[class=fulfillment-add-to-cart-button]")
    stockStatus = add_to_cart_button.text

    # Loop to check status at timed interval
    while True:
        driver.refresh()
        time.sleep(5)
        if stockStatus == "Sold Out":
            pass
        else:
            print(stockStatus)
        time.sleep(10)

stock_check()
#
import discord
from discord.ext import commands
from dotenv import load_dotenv
import os

bot = commands.Bot(command_prefix="!")
load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")


# Initial bot login
@bot.event
async def on_ready():
    print("Logged in as")
    print(bot.user.name)
    print(f"Bot User ID: {bot.user.id}")


@bot.command()
async def stock_Status(ctx):
    await ctx.channel.send("Message")


bot.run(TOKEN)
#

If I import the statuscheck file into the bot file, the bot doesn't run

#

If I try it the other way, then the statuscheck doesn't run and the bot does

slate swan
#

hm 1. do bot.run('token`)

#

u need the ' things

zinc flame
#

Sorry, the two run fine independently of each other