A1: Make 7 Discord Posts#

Choose Social Media Platform: Reddit | Discord | Bluesky

In this assignment, you will modify this program to post at least 7 discord posts (no more than 15). Then you will answer some reflection questions on your bot.

We suggest that while you are working on it and testing it out, you use fake_discord so it doesn’t post on actual discord. When you are done, you can try running it on your real discord account, but you might just get rate limit errors. You can just run in with fake_discord and we’ll be able to see what your bot would have posted to discord if discord didn’t block you.

When you are done, you will need to download this file or a pdf version (file menu -> download) and turn it in on Canvas.

Code to make your posts#

Step 1: load discord library#

# Load some code called "discord" that will help us work with Discord
import discord

# Load another library that helps the bot work in Jupyter Noteboook
import nest_asyncio
nest_asyncio.apply()

(Optional) Step 1b: Make a fake discord connection with the fake_discord library#

For testing purposes, we’ve added this line of code, which loads a fake version of discord, so it wont actually connect to Discord. If you want to try to actually connect to Discord, don’t run this line of code.

%run ../../../../fake_apis/fake_discord.ipynb
Fake discord is replacing the discord.py library. Fake discord doesn't need real passwords, and prevents you from accessing real discord

Step 2: Set up your Discord connection#

To use this on your real Discord account, copy your discord token into the code below, replacing our fake passwords. into the discord_keys.py file.

%run discord_keys.py

client = discord.Client(intents=discord.Intents.default())
Fake discord is pretending to set up a client connection

Step 3: Define and run a bot that will make 7 discord posts#

This is where you will have to modify the code to:

Post 7 times to discord

  • Using the sleep() function at least two times

  • Save at least one piece of text in a variable and use it for making a post

You bot must NOT:

  • Interact with non-class or personal discord servers, or interact (e.g., tag) people who haven’t personally agreed to let you interact with them.

  • Post more than 15 times

# Provide instructions for what your discord bot should do once it has logged in
@client.event
async def on_ready():
    # Load the discord channel you want to post to
    # TODO: put the discord channel id number below
    channel_id = 123456789
    channel = client.get_channel(channel_id)

    # Post a messages to your discord channel
    # TODO: modify this code to post at least 7 times
    await channel.send("Example post!")

    # Tell your bot to stop running
    await client.close()
    
# Now that we've defined how the bot should work, start running your bot
client.run(discord_token)
Fake discord bot is fake logging in and starting to run
Fake Discord is pretending to post:
Example post!
Fake discord bot is shutting down

Reflection Questions#

You must also write answers to the following questions

Note: You can double click on these blocks of text to edit them

What is the name of your discord account so we can see the posts? Or what error message did you get when trying to make the posts? (you still get full credit even if you couldn’t get it to post for real)

TODO: Put discord account name (or error message) here

If your discord account wasn’t labeled as a bot, how do you think people would perceive those posts? (write at least 3 sentences)

TODO: Write at least 3 sentences here

If people saw those posts and then later discovered that they were posted by a computer program, how do you think their view of the posts would change? (write at least 3 sentences)

TODO: Write at least 3 sentences here

Pick two ethics frameworks and compare how they might evaluate your bot (or a similar one with more benevolent or malevalent purposes)? (write at least 6 sentences)

TODO: Write at least 6 sentences here