W
W
Wildovaniy2020-06-07 14:32:33
Python
Wildovaniy, 2020-06-07 14:32:33

How to combine Discord bot and tkinter?

I started making a discord bot for my server, I wanted to do:
So that I write the console command in the chat and open a program in which you can write text and send a message to the chat on behalf of the bot using the "send" button.
The problem occurs at the stage when I click "send" pops up this:
C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py:1283: RuntimeWarning: coroutine 'console..send_m' was never awaited
self.tk. mainloop(n)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Here is my entire code:

import discord
from discord.ext import commands
import random
from tkinter import *

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

@client.event
async def on_ready():
print('Manager is working')
games = ['♞Chess♞', 'Counter Strike: Global Offensive', 'DOTA 2 ', 'Valorant', 'Python']
await client.change_presence( status = discord.Status.online, activity = discord.Game( random.choice(games)))

@client.event
async def on_member_join( member ):
channel = client.get_channel( 716622621759766629 )
await channel.send( embed = discord.Embed( description = f"User ``{ member.name }`` has successfully connected to us \n Darova, { member.name } !\n Read the rules in channel below :)" , color = 0xFF00D3))

@client.command(pass_context = True)
async def console(ctx):
await ctx.channel.purge(limit = 1)
async def send_m():
server = client.get_guild( 701437596554756177 )
channel = client.get_channel( 716622621759766629 )
await channel.send( embed = discord.Embed( description = text_m , color = 0xFF00D3))
text_m = str(text_of_m.get())

window = Tk()
window.geometry("400x200")
window.title("Console of server of Wildovaniy")
window.wm_attributes("-alpha", 0.9)
run = Button(window, text="Send", command=send_m)
run.place(x= 150, y=100, width=100, height=40)
text_of_m = Entry(window)
text_of_m.place(x=30, y =50, width=150)
window.mainloop()

@client.command( pass_context = True)
async def clear(ctx, amount = 100):
await ctx.channel.purge(limit = amount+1)
emb = discord.Embed( title = f"Successfully cleared {amount} messages!", color = 0x29E30A)
await ctx. send(embed = emb)
@client.command( pass_context = True)
async def repeate(ctx, * ,arg):
await ctx.channel.purge(limit = 1)
await ctx.send(f' ' + arg)

token = open('token.txt', 'r').readline()
client.run(token)


Thanks in advance :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pythonMyLife, 2020-12-08
@pythonMyLife

Sir, could you please use a special tag for the code?

spoiler
python ('Кхм')

Y
Yanis07, 2021-10-07
@Yanis07

You do n't have a call here The code is hard to read, but I dare to suggest that you don't need to call an async function, try
async def send_m():
awaited
def send_m():

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question