From 2f6dbeb5ded0243f6db04a3e7f9b0618fa980936 Mon Sep 17 00:00:00 2001 From: Alex Zhu Date: Sun, 19 May 2019 01:31:36 -0700 Subject: [PATCH 1/3] Update intervalbot.py Now the function client.is_closed() would be executed and returns a boolean. --- intervalbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intervalbot.py b/intervalbot.py index 6fcd0d6..df98168 100644 --- a/intervalbot.py +++ b/intervalbot.py @@ -69,7 +69,7 @@ async def send_interval_message(): # print list of servers where this bot is active to console async def list_servers(): await client.wait_until_ready() - while not client.is_closed: + while not client.is_closed(): # you can customize the output message(s) below print("--- INTERVAL BOT ONLINE ---") for server in client.servers: From ca60723c680f7922596261d290bfdf2ef75be2fe Mon Sep 17 00:00:00 2001 From: Alex Zhu Date: Sun, 19 May 2019 02:54:13 -0700 Subject: [PATCH 2/3] Fixed sending message Use channel.send(message) works perfectly with discord.py version v.1.1.1 --- intervalbot.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/intervalbot.py b/intervalbot.py index df98168..eeb13a3 100644 --- a/intervalbot.py +++ b/intervalbot.py @@ -35,9 +35,9 @@ INTERVAL = 60 # channel to send the message to -# the message is sent to a channel specified with an ID below +# the message is sent to a channel specified with an ID below as an int # right click on the Discord channel and click 'copy id' to get one -CHANNEL = 'YOUR_DISCORD_CHANNEL_ID_GOES_HERE' +CHANNEL = YOUR_DISCORD_CHANNEL_ID_GOES_HERE # message to be sent # custom message to be sent to specified channel @@ -57,12 +57,11 @@ client = discord.Client() async def send_interval_message(): await client.wait_until_ready() - channel = CHANNEL + channel = client.get_channel(CHANNEL) interval = INTERVAL message = MESSAGE - channel = discord.Object(id=channel) - while not client.is_closed: - await client.send_message(channel, message) + while not client.is_closed(): + await channel.send(message) await asyncio.sleep(interval) From b2321f026b9f6a9b069c4f253d761f493fb95af9 Mon Sep 17 00:00:00 2001 From: Alex Zhu Date: Sun, 19 May 2019 03:02:38 -0700 Subject: [PATCH 3/3] Update intervalbot.py Replace client.server to client.guilds to match with the updated discord.py version (v1.1.1) --- intervalbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intervalbot.py b/intervalbot.py index eeb13a3..0d99417 100644 --- a/intervalbot.py +++ b/intervalbot.py @@ -71,7 +71,7 @@ async def list_servers(): while not client.is_closed(): # you can customize the output message(s) below print("--- INTERVAL BOT ONLINE ---") - for server in client.servers: + for server in client.guilds: # you can customize the output message(s) below print('Active servers: ' + str(server.name)) await asyncio.sleep(600)