Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random pictures from a file
#1
Hello I'm trying to create a discord bot and I'm stuck one subject. I want to share a random photo from a folder when someone write in the chat specific words. For example when someone write 'dog', ı want to share a dog photo from a folder. I'll show my basic code I hope you will help me.

import os
import random
import discord
from discord.ext import commands

my_files = [discord.File('A:\\ma\\1.jpg'), discord.File('A:\\ma\\2.jpg')]
bat = ['dog', 'cat']
.
.
.
if any(word in msg for word in bat):
await message.channel.send(files=my_files)
Reply


Messages In This Thread
Random pictures from a file - by aliwien - Apr-23-2021, 11:37 AM
RE: Random pictures from a file - by supuflounder - Apr-23-2021, 12:52 PM
RE: Random pictures from a file - by snippsat - Apr-23-2021, 06:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python logging RotatingFileHandler writes to random file after the first log rotation rawatg 0 453 Feb-15-2024, 11:15 AM
Last Post: rawatg
  Find a shift between 2 pictures TazFleck 0 1,216 Jan-18-2023, 09:56 PM
Last Post: TazFleck
Photo put a green boarder and text around multiple pictures jackosullivan 5 1,550 Jul-05-2022, 10:39 AM
Last Post: snippsat
  Help with taking pictures on raspberry pi octavia 1 1,717 Feb-07-2020, 04:54 PM
Last Post: Larz60+
  client-server pictures mcgrim 4 3,020 Oct-25-2019, 09:53 PM
Last Post: micseydel
  Print random musik to wav file Pereskia 2 2,698 Mar-27-2019, 11:53 AM
Last Post: Pereskia
  Open Pictures with Python MaxouRuEnIpTF34 1 3,080 Apr-22-2018, 07:48 PM
Last Post: Gribouillis
  Write selected (random) columns to output-file anjohepa 0 2,362 Feb-27-2018, 02:19 PM
Last Post: anjohepa
  Comparing pictures pedro 1 2,759 Sep-11-2017, 07:51 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020