I’m getting an error with my discord py code /u/GameMasterYouTube Python Education

So, this python code takes messages from a discord server and fowards it. I don’t have admin at this server, so I want to make a self-bot, (yes, I know against discord TOS,) but I need help with this code because I keep getting this error: raise LoginFailure(‘Improper token has been passed.’) from exc

discord.errors.LoginFailure: Improper token has been passed.

Py code is here:
import discord

from discord.ext import commands

import datetime

import platform

import os

# Configuration

SOURCE_SERVER_ID = 1315924793392107542 # The ID of the source server

TARGET_CHANNEL_ID = 1320978283160014859 # The ID of the target channel

TOKEN = ‘my token’ # Token

# Clear screen

sys_os = platform.system()

os.system(“clear” if sys_os == “Linux” else “cls”)

# Banner

banner = “””

[Your Banner Here]

“””

print(banner)

# Definse intents

intents = discord.Intents.default()

intents.messages = True # Enables message intents

# Bot setup

bot = commands.Bot(command_prefix=””, self_bot=True, intents=intents)

u/bot.event

async def on_ready():

print(f”Logged in as {bot.user}”)

u/bot.event

async def on_message(message):

if message.author.bot: # Ignores bot messages

return

# Checks if the message is from the source server

if message.guild and message.guild.id == SOURCE_SERVER_ID:

target_channel = bot.get_channel(TARGET_CHANNEL_ID)

if not target_channel:

print(“Target channel not found.”)

return

# Forwards the message

try:

current_time = datetime.datetime.now().strftime(“%H:%M:%S”)

content = f”{current_time} <{message.author}/{message.channel}> {message.content}”

await target_channel.send(content)

print(f”Message forwarded: {content}”)

except Exception as e:

print(f”Error sending message: {e}”)

# Run the bot

bot.run(TOKEN)

submitted by /u/GameMasterYouTube
[link] [comments]

​r/learnpython So, this python code takes messages from a discord server and fowards it. I don’t have admin at this server, so I want to make a self-bot, (yes, I know against discord TOS,) but I need help with this code because I keep getting this error: raise LoginFailure(‘Improper token has been passed.’) from exc discord.errors.LoginFailure: Improper token has been passed. Py code is here: import discord from discord.ext import commands import datetime import platform import os # Configuration SOURCE_SERVER_ID = 1315924793392107542 # The ID of the source server TARGET_CHANNEL_ID = 1320978283160014859 # The ID of the target channel TOKEN = ‘my token’ # Token # Clear screen sys_os = platform.system() os.system(“clear” if sys_os == “Linux” else “cls”) # Banner banner = “”” [Your Banner Here] “”” print(banner) # Definse intents intents = discord.Intents.default() intents.messages = True # Enables message intents # Bot setup bot = commands.Bot(command_prefix=””, self_bot=True, intents=intents) u/bot.event async def on_ready(): print(f”Logged in as {bot.user}”) u/bot.event async def on_message(message): if message.author.bot: # Ignores bot messages return # Checks if the message is from the source server if message.guild and message.guild.id == SOURCE_SERVER_ID: target_channel = bot.get_channel(TARGET_CHANNEL_ID) if not target_channel: print(“Target channel not found.”) return # Forwards the message try: current_time = datetime.datetime.now().strftime(“%H:%M:%S”) content = f”{current_time} <{message.author}/{message.channel}> {message.content}” await target_channel.send(content) print(f”Message forwarded: {content}”) except Exception as e: print(f”Error sending message: {e}”) # Run the bot bot.run(TOKEN) submitted by /u/GameMasterYouTube [link] [comments] 

So, this python code takes messages from a discord server and fowards it. I don’t have admin at this server, so I want to make a self-bot, (yes, I know against discord TOS,) but I need help with this code because I keep getting this error: raise LoginFailure(‘Improper token has been passed.’) from exc

discord.errors.LoginFailure: Improper token has been passed.

Py code is here:
import discord

from discord.ext import commands

import datetime

import platform

import os

# Configuration

SOURCE_SERVER_ID = 1315924793392107542 # The ID of the source server

TARGET_CHANNEL_ID = 1320978283160014859 # The ID of the target channel

TOKEN = ‘my token’ # Token

# Clear screen

sys_os = platform.system()

os.system(“clear” if sys_os == “Linux” else “cls”)

# Banner

banner = “””

[Your Banner Here]

“””

print(banner)

# Definse intents

intents = discord.Intents.default()

intents.messages = True # Enables message intents

# Bot setup

bot = commands.Bot(command_prefix=””, self_bot=True, intents=intents)

u/bot.event

async def on_ready():

print(f”Logged in as {bot.user}”)

u/bot.event

async def on_message(message):

if message.author.bot: # Ignores bot messages

return

# Checks if the message is from the source server

if message.guild and message.guild.id == SOURCE_SERVER_ID:

target_channel = bot.get_channel(TARGET_CHANNEL_ID)

if not target_channel:

print(“Target channel not found.”)

return

# Forwards the message

try:

current_time = datetime.datetime.now().strftime(“%H:%M:%S”)

content = f”{current_time} <{message.author}/{message.channel}> {message.content}”

await target_channel.send(content)

print(f”Message forwarded: {content}”)

except Exception as e:

print(f”Error sending message: {e}”)

# Run the bot

bot.run(TOKEN)

submitted by /u/GameMasterYouTube
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *