Reputation: 3
So basically I'm doing something with a discord bot, and I got stuck in this.
let's say this is callBot_and_sendmessage
function
def callBot_and_sendmessage(message):
#wake the bot
@client.event
async def on_ready():
await client.change_presence(activity = discord.Game(name='Do !help'))
#send the message
@client.event
async def on_message(message):
channel = client.get_channel(channelId)
await channel.send(message)
and my code is like this
message = input('Type a message: ')
callBot_and_sendmessage(message)
saveMessage(message)
the function saveMessage
def saveMessage(message):
with open(file, 'w') as fileData:
fileData.write(message)
My program won't call the saveMessage
Function
so I need a way to stop the callBot_and_sendmessage
aka the bot from running after sending the message
Can anyone help me with that ?
Upvotes: 0
Views: 1596
Reputation: 5647
You can make the bot log out by using client.close(). Alternatively you can put exit(0)
at the end (after the channel.send
), so the script stops running after the message has been sent.
Upvotes: 1