I want my bot to listen to every channel which is named "disminer-2" i am currently using
import discord
from discord.ext import commands
import os
import asyncio
#from keepalive import keep_alive
from replit import db
client = commands.Bot(command_prefix = ">")
client.remove_command("help")
filtered = ["fuck","shit"]
@client.event
async def on_ready():
print("We have logged in as {0.user}".format(client))
print("User: user Id : Message Content")
@client.event
async def on_message(msg):
chn_id = msg.channel.id
#all the filter things
if msg.channel.name != "disminer-1" or msg.author.id == 844182812977659904 or msg.author.bot == True:
return
if msg.content.lower() in filtered:
await msg.reply("Your message contains a filtered word.")
return
if msg.content.lower() in "https://" or msg.content.lower() in "https://":
await msg.reply("Links cannot be sent through, so don't try to advertize, idiot. And now your punishment is get pinged 10 times, loser!")
for i in range (0,10):
await asyncio.sleep(0.5)
await msg.channel.send(f"{msg.author.mention}")
return
if "discord.gg" in msg.content.lower() or "discord.com" in msg.content.lower():
await msg.reply("Links cannot be sent through, so don't try to advert your discord server, idiot. And now your punishment is get pinged 10 times, loser!")
for i in range (0,10):
await asyncio.sleep(0.5)
await msg.channel.send(f"{msg.author.mention}")
return
channel = discord.utils.get([x for x in client.get_all_channels() if x.type is discord.TextChannel], name="disminer-2")
await channel.send(f"**{msg.author}:** {msg.content}")
print(f"{msg.author} : ({msg.author.id}) : {msg.content}")
await client.process_commands(msg)
@client.command()
async def test(ctx):
for guild in client.guilds:
for channel in guild.channels:
await ctx.send (channel)
"""
Notes:
we might be able to do the for guild in thing
it seems to get all the channels.
"""
#keep_alive()
client.run(os.environ['BOTTOKEN'])
and am getting error
Ignoring exception in on_message Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(args, kwargs) File "main.py", line 45, in on_message await channel.send(f"{msg.author}:* {msg.content}") AttributeError: 'NoneType' object has no attribute 'send'
any help appreciated thx.
Im basically trying to make a global bot which reads messages in disminer-1 and sends it to every guild it is in with the channel disminer-2.