Here is my code
import threading
import discord
from discord.ext import commands, tasks
from discord.ext.commands import has_permissions
import asyncio
activity = discord.Game(name="/help")
def get_prefix(client, message):
with open( prefixes.json , r ) as f:
prefixes = json.load(f)
return prefixes[str(message.guild.id)]
client = commands.Bot(command_prefix=get_prefix,
intents=discord.Intents.all(),
case_insensitive=True,
activity=activity,
status=discord.Status.online)
async def send_message_to_specific_channel(message,id):
channel = client.get_channel(id)
await channel.send(message)
def talk():
text = text_to_say.get( 1.0 , tkinter.END)
ID = input( ID: )
asyncio.run_coroutine_threadsafe(send_message_to_specific_channel(text,ID),client.loop)
root = tkinter.Tk()
root.geometry( 300x300 )
tkinter.Button(root, text= Talk , command=talk).pack()
text_to_say = tkinter.Text(root)
text_to_say.pack()
def Run_bot():
client.run(os.getenv("TOKEN"))
t = threading.Thread(target=Run_bot)
t.start()
root.mainloop()
I put in the ID, but nothing happens. Is there something I m missing?
By the way, most of this code is from StackOverflow.
I am trying to use it on a private channel with permission to read and chat in the channel, if that helps