Jump to content

Why can't I send a Discord message in 2 channels with a bot? (discord.py)

TheCoder2019
Go to solution Solved by colonel_mortis,

You never assign to `channel` - I think you meant to do

channel = client.get_channel(845779828237402132)

I have a bot that has a command, ^verify.

 

The code for ^verify is here:

#VERIFY FROM CHANNEL
@client.command()
async def verify(ctx):

  await ctx.send(f'Hey, {ctx.author}: \nWe\'ve sent a verification request to the moderators. Note:\n`You need at least 1,000 subscribers or followers on one of your linked accounts. This can take anywhere from 12 to 48 hours.`'),
  
  client.get_channel(845779828237402132)
  await channel.send(f'{ctx.author} has requested verification.')

Every time the command is run, the output is this:

Ignoring exception in command verify:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 23, in verify
    await channel.send(f'{ctx.author} has requested verification.')
NameError: name 'channel' is not defined

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 902, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 864, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NameError: name 'channel' is not defined

The first await runs, but the second doesn't. Can someone help me?

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

You never assign to `channel` - I think you meant to do

channel = client.get_channel(845779828237402132)

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, colonel_mortis said:

You never assign to `channel` - I think you meant to do


channel = client.get_channel(845779828237402132)

Well dang! That was an easy fix!

Spoiler

image.png.9e059f17a57751aa855599f068264e39.png

image.png.d4d7dbea5f3235631ce827cf70008dd5.png

Thanks!

As Someone with the username “</TheCoder2019_”, my coding skills are atrocious.

Here are my specs:

Spoiler

 

MSI PRO-VLH H310M

Intel Core i3-8100 (Thanks, @Schnoz!)

GTX 1060 OC 3GB or Intel UHD 630

16GB (2x8) Cosair Vengeance LPX CL16 - 2400MHz

GAMDIAS Argus M1

 

An old friend of mine - Intel stock cooler (temps through the roof like 60 C under load)

 

 

Linux Apps you NEED!

Spoiler

tmux

dhcpd

git

 

 


 

 

 

 

 

 

 

Hi! I love RGB! Who doesn't? Karens that don't have colorful lights on their Facebook page

Link to comment
Share on other sites

Link to post
Share on other sites

Don't be afraid to read error messages

  File "main.py", line 23, in verify
    await channel.send(f'{ctx.author} has requested verification.')
NameError: name 'channel' is not defined

 

ಠ_ಠ

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×