Inspirateur / wordy

Improved word cloud discord bot
3 stars 2 forks source link

Requesting more precise dependencies in Cargo.toml #1

Closed AZMindroma closed 5 days ago

AZMindroma commented 5 days ago

Hey there! I loved your original WordCloud bot and saw that this is a thing now since the one beforehand didn't work. Since this project seems to be a bit old already I already had some worries about it not working, and well, I guess I was right! When following the guide, I got this error:

error[E0282]: type annotations needed for `Box<_>`
  --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.20/src/format_description/parse/mod.rs:83:9
   |
83 |     let items = format_items
   |         ^^^^^
...
86 |     Ok(items.into())
   |              ---- type must be known at this point
   |
   = note: this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35` by calling `cargo update`

   Compiling reqwest v0.11.17
For more information about this error, try `rustc --explain E0282`.
error: could not compile `time` (lib) due to 1 previous error

So I ran cargo update.

Then built the program again. Then, this error came:

error: At least one of the crate features `sync` or `future` must be enabled for `moka` crate. Please update your dependencies in Cargo.toml
  --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/moka-0.12.8/src/lib.rs:89:1
   |
89 | / compile_error!(
90 | |     "At least one of the crate features `sync` or `future` must be enabled for \
91 | |     `moka` crate. Please update your dependencies in Cargo.toml"
92 | | );
   | |_^

error: could not compile `moka` (lib) due to 1 previous error

So I put this into the Cargo.toml:

moka = { version = "*", features = ["sync"] }

And tried again.

Then this error came:

error[E0432]: unresolved imports `serenity::model::application::interaction::application_command`, `serenity::model::application::interaction::InteractionResponseType`
 --> src/discord_util.rs:6:13
  |
6 |             application_command::ApplicationCommandInteraction, 
  |             ^^^^^^^^^^^^^^^^^^^ could not find `application_command` in `interaction`
7 |             InteractionResponseType::ChannelMessageWithSource,
  |             ^^^^^^^^^^^^^^^^^^^^^^^ could not find `InteractionResponseType` in `interaction`

error[E0432]: unresolved import `image::ImageOutputFormat`
 --> src/wordy_commands.rs:3:50
  |
3 | use image::{write_buffer_with_format, ColorType, ImageOutputFormat};
  |                                                  ^^^^^^^^^^^^^^^^^ no `ImageOutputFormat` in the root

error[E0432]: unresolved import `serenity::model::application::interaction::application_command`
 --> src/wordy_commands.rs:7:31
  |
7 |     application::interaction::application_command::ApplicationCommandInteraction, 
  |                               ^^^^^^^^^^^^^^^^^^^ could not find `application_command` in `interaction`

error[E0603]: module `interaction` is private
  --> src/discord_util.rs:5:22
   |
5  |         application::interaction::{
   |                      ^^^^^^^^^^^ private module
   |
note: the module `interaction` is defined here
  --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serenity-0.12.2/src/model/application/mod.rs:11:1
   |
11 | mod interaction;
   | ^^^^^^^^^^^^^^^

error[E0603]: type alias `Color` is private
  --> src/wordy.rs:14:24
   |
14 |     prelude::*, utils::Color
   |                        ^^^^^ private type alias
   |
note: the type alias `Color` is defined here
  --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serenity-0.12.2/src/utils/mod.rs:35:5
   |
35 | use crate::model::prelude::*;
   |     ^^^^^^^^^^^^^^^^^^^^^
help: import `Color` directly
   |
14 |     prelude::*, serenity::model::colour::Color
   |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error[E0603]: module `interaction` is private
  --> src/wordy_events.rs:5:22
   |
5  |         application::interaction::{
   |                      ^^^^^^^^^^^ private module
   |
help: consider importing this enum instead:
      serenity::all::Interaction
  --> src/wordy_events.rs:6:13
   |
6  |             Interaction,
   |             ^^^^^^^^^^^
note: the module `interaction` is defined here
  --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serenity-0.12.2/src/model/application/mod.rs:11:1
   |
11 | mod interaction;
   | ^^^^^^^^^^^^^^^

error[E0603]: module `interaction` is private
  --> src/wordy_commands.rs:7:18
   |
7  |     application::interaction::application_command::ApplicationCommandInteraction, 
   |                  ^^^^^^^^^^^ private module
   |
note: the module `interaction` is defined here
  --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serenity-0.12.2/src/model/application/mod.rs:11:1
   |
11 | mod interaction;
   | ^^^^^^^^^^^^^^^

error[E0282]: type annotations needed
  --> src/discord_util.rs:81:21
   |
81 |             &http, |retriever| if let Some(message) = res.last() {
   |                     ^^^^^^^^^
82 |                 retriever.before(message.id).limit(remaining)
   |                 --------- type must be known at this point
   |
help: consider giving this closure parameter an explicit type
   |
81 |             &http, |retriever: /* Type */| if let Some(message) = res.last() {
   |                              ++++++++++++

error[E0308]: mismatched types
   --> src/wordy.rs:139:33
    |
139 |                     (Token::Img(img), v)
    |                      ---------- ^^^ expected `image::dynimage::DynamicImage`, found `DynamicImage`
    |                      |
    |                      arguments to this enum variant are incorrect
    |
    = note: `DynamicImage` and `image::dynimage::DynamicImage` have similar names, but are actually distinct types
note: `DynamicImage` is defined in crate `image`
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/image-0.25.4/src/dynimage.rs:51:1
    |
51  | pub enum DynamicImage {
    | ^^^^^^^^^^^^^^^^^^^^^
note: `image::dynimage::DynamicImage` is defined in crate `image`
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/image-0.24.9/src/dynimage.rs:55:1
    |
55  | pub enum DynamicImage {
    | ^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `image` are being used?
note: tuple variant defined here
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wordcloud-rs-0.1.14/src/wordcloud.rs:9:5
    |
9   |     Img(DynamicImage)
    |     ^^^

error[E0599]: no variant or associated item named `Category` found for enum `serenity::all::Channel` in the current scope
   --> src/wordy.rs:155:33
    |
155 |                     Ok(Channel::Category(channel)) => (Token::Text(format!("#{}", channel.name)), v),
    |                                 ^^^^^^^^ variant or associated item not found in `Channel`
    |
help: there is a method `category` with a similar name
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serenity-0.12.2/src/model/channel/mod.rs:113:5
    |
113 |     pub fn category(self) -> Option<GuildChannel> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
   --> src/wordy.rs:170:9
    |
164 |       pub async fn cloud(&self, ctx: &Context, member: &Member) -> RgbaImage {
    |                                                                    --------- expected `ImageBuffer<image::Rgba<u8>, Vec<u8>>` because of return type
...
170 | /         WordCloud::new()
171 | |         .colors(Colors::BiaisedRainbow { 
172 | |             anchor: convert_color(color),
173 | |             variance: 50. 
174 | |         }).generate(wc_tokens)
    | |______________________________^ expected `ImageBuffer<image::Rgba<u8>, Vec<u8>>`, found `ImageBuffer<Rgba<u8>, Vec<u8>>`
    |
    = note: `ImageBuffer<Rgba<u8>, Vec<u8>>` and `ImageBuffer<image::Rgba<u8>, Vec<u8>>` have similar names, but are actually distinct types
note: `ImageBuffer<Rgba<u8>, Vec<u8>>` is defined in crate `image`
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/image-0.24.9/src/buffer.rs:656:1
    |
656 | pub struct ImageBuffer<P: Pixel, Container> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `ImageBuffer<image::Rgba<u8>, Vec<u8>>` is defined in crate `image`
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/image-0.25.4/src/buffer.rs:656:1
    |
656 | pub struct ImageBuffer<P: Pixel, Container> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `image` are being used?

error[E0053]: method `guild_create` has an incompatible type for trait
  --> src/wordy_events.rs:53:71
   |
53 |     async fn guild_create(&self, ctx: Context, guild: Guild, _is_new: bool) {
   |                                                                       ^^^^ expected `Option<bool>`, found `bool`
   |
   = note: expected signature `fn(&'life0 Wordy, serenity::prelude::Context, serenity::all::Guild, Option<bool>) -> std::pin::Pin<_>`
              found signature `fn(&'life0 Wordy, serenity::prelude::Context, serenity::all::Guild, bool) -> std::pin::Pin<_>`
help: change the parameter type to match the trait
   |
53 |     async fn guild_create(&self, ctx: Context, guild: Guild, _is_new: Option<bool>) {
   |                                                                       ~~~~~~~~~~~~

error[E0599]: no function or associated item named `set_application_commands` found for struct `serenity::all::GuildId` in the current scope
    --> src/wordy_commands.rs:86:36
     |
86   |         if let Err(why) = GuildId::set_application_commands(&guild_id, http, |commands| {
     |                                    ^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `GuildId`
     |
note: if you're trying to build a new `serenity::all::GuildId`, consider using `serenity::all::GuildId::new` which returns `serenity::all::GuildId`
    --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serenity-0.12.2/src/model/id.rs:265:1
     |
265  | / id_u64! {
266  | |     AttachmentId;
267  | |     ApplicationId;
268  | |     ChannelId;
...    |
291  | |     EntitlementId;
292  | | }
     | |_^
help: there is a method `set_commands` with a similar name, but with different arguments
    --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serenity-0.12.2/src/model/guild/guild_id.rs:1538:5
     |
1538 | /     pub async fn set_commands(
1539 | |         self,
1540 | |         http: impl AsRef<Http>,
1541 | |         commands: Vec<CreateCommand>,
1542 | |     ) -> Result<Vec<Command>> {
     | |_____________________________^
     = note: this error originates in the macro `id_u64` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0423]: cannot initialize a tuple struct which contains private fields
   --> src/wordy.rs:89:32
    |
89  |                 let emoji_id = EmojiId(
    |                                ^^^^^^^
    |
note: constructor is not visible here due to private fields
   --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/serenity-0.12.2/src/model/id.rs:147:49
    |
147 | pub struct EmojiId(#[serde(with = "snowflake")] NonZeroU64);
    |                                                 ^^^^^^^^^^ private field
help: you might have meant to use the `new` associated function
    |
89  |                 let emoji_id = EmojiId::new(
    |                                       +++++

warning: unused import: `Context`
  --> src/discord_util.rs:13:22
   |
13 | use anyhow::{Result, Context as ContextErr};
   |                      ^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

Some errors have detailed explanations: E0053, E0282, E0308, E0423, E0432, E0599, E0603.
For more information about an error, try `rustc --explain E0053`.
warning: `wordy` (bin "wordy") generated 1 warning
error: could not compile `wordy` (bin "wordy") due to 14 previous errors; 1 warning emitted

And I guess this might be because of changes in new versions that break how these crates work. So I wanted to ask if it's possible to have a more precise version requirement for all the dependencies of this program so that we can install the old versions to make the bot work. Thank you in advance!

AZMindroma commented 5 days ago

Nevermind, I realized that there is a proper system to lock versions, But I guess somehow I will need to downgrade the Rust API. I apologize! However, nonetheless I think there will need to be an older Rust version to build this successfully. Do you know which version you used? Currently mine is cargo 1.82.0 (8f40fc59f 2024-08-21).

Inspirateur commented 5 days ago

Since this project seems to be a bit old already I already had some worries about it not working, and well, I guess I was right!

Fear not ! I am still very active on github and will try to fix this error TODAY :)

Thanks for raising the issue ! (and saying nice things about the project ❤️)

Inspirateur commented 5 days ago

Ok so I've updated the dependencies and the code and it now compiles and runs without issues for me on latest rust :)

Do tell me if there is any remaining problem but in the meantime i'm marking this issue as completed 👍

AZMindroma commented 5 days ago

The bot also compiles for me now, thank you!!! :heart: It also runs, but then another issue arose.

For the most of the channels, the bot claims to not have the ability to read past messages, possibly due to [Read Message History] permission missing from the bot. I gave the bot permission to View Channels and to Read Message History, but it still didn't work. Then I added Admin role to the bot, but it still didn't work.

However, what is weird that it works on certain channels (there are no special permissions there that cause them to be different). Messages read and from the channels that are read, the bot makes the wordcloud :) But I don't know how to resolve the couldn't read past messages issue. Once again, thank you! :)

Bildschirmfoto_20241030_123508

Inspirateur commented 5 days ago

For the most of the channels, the bot claims to not have the ability to read past messages, possibly due to [Read Message History] permission missing from the bot. I gave the bot permission to View Channels and to Read Message History, but it still didn't work. Then I added Admin role to the bot, but it still didn't work.

Ah I ran across this and assumed it was just a new permission I forgot to add to the bot, but if you're saying that the message persists despite giving proper permission to the bot that's a real issue indeed 😬

I moved it to here https://github.com/Inspirateur/wordy/issues/2