async fn stop(&self, context: &Context, msg: &Message) {
        // Clear out the proposals and list them in an announcement
        if self.in_suggestion_period(msg).await {
            if let Some(g) = msg.guild(context).await {
                role_gate!(&context, g, msg, "stop an election");

                let all_candidates = self.upcoming_topics.get(&g.id).unwrap().read().await;

                // Buffer for the string representation of these candidates
                let mut candidates_str = String::new();

                // Clear out all candidates and set their vote counts to zero
                for (i, name) in all_candidates.iter().enumerate() {
                    self.votes
                        .get(&g.id)
                        .unwrap()
                        .write()
                        .await
                        .insert(i, (name.clone(), AtomicUsize::new(0), HashMap::new()));

                    // Display the candidates with their indices
                    candidates_str = format!("{}#{}: {}\n", candidates_str, i, name);
                }

                // Remove all candidates
                self.upcoming_topics
                    .get(&g.id)
                    .unwrap()
                    .write()
                    .await
                    .clear();

                // Store the announcement message for later reporting
                if let Some(live_results) = announce!(context, msg, format!("@everyone Candidates have been selected:\n{}\nVote with !vote <n votes>, <candidate number>\n**Results so Far:**\nNo votes cast!", candidates_str)) {
                    self.results.write().await.insert(g.id, live_results);
                }

                // Allow user to cast votes, and then automatically stop the count after the
                // interval
                time::sleep(Duration::from_secs(VOTE_INTERVAL * 60 * 60)).await;
                if self.in_vote_period(msg).await {
                    self.stop(context, msg).await;
                }
            }
        // Calculate the results of the election
        } else if self.in_vote_period(msg).await {
            if let Some(g) = msg.guild(context).await {
                let winners = self.winners(&g.id).await.join("\n");

                // Display the first n winning candidates, their names, and their votes
                announce!(
                    context,
                    msg,
                    format!(
                        "@everyone The election is over. The winners are:\n{}",
                        winners,
                    )
                );

                // Clear the votes
                self.votes.get(&g.id).unwrap().write().await.clear();

                // Reset point counts
                for (_user, points) in self.points.get(&g.id).unwrap().read().await.iter() {
                    points.swap(STARTING_POINTS, Ordering::Relaxed);
                }
            }
        }
    }
/// !stop: Stops the currently running step of the election
Stops the currently running step of the election
Stops the currently running step of the election
async fn stop(&self, context: &Context, msg: &Message) {
        // Clear out the proposals and list them in an announcement
        if self.in_suggestion_period(msg).await {
            if let Some(g) = msg.guild(context).await {
                role_gate!(&context, g, msg, "stop an election");
                let all_candidates = self.upcoming_topics.get(&g.id).unwrap().read().await;
                // Buffer for the string representation of these candidates
                let mut candidates_str = String::new();
                // Clear out all candidates and set their vote counts to zero
                for (i, name) in all_candidates.iter().enumerate() {
                    self.votes
                        .get(&g.id)
                        .unwrap()
                        .write()
                        .await
                        .insert(i, (name.clone(), AtomicUsize::new(0), HashMap::new()));
                    // Display the candidates with their indices
                    candidates_str = format!("{}#{}: {}\n", candidates_str, i, name);
                }
                // Remove all candidates
                self.upcoming_topics
                    .get(&g.id)
                    .unwrap()
                    .write()
                    .await
                    .clear();
                // Store the announcement message for later reporting
                if let Some(live_results) = announce!(context, msg, format!("@everyone Candidates have been selected:\n{}\nVote with !vote <n votes>, <candidate number>\n**Results so Far:**\nNo votes cast!", candidates_str)) {
                    self.results.write().await.insert(g.id, live_results);
                }
                // Allow user to cast votes, and then automatically stop the count after the
                // interval
                time::sleep(Duration::from_secs(VOTE_INTERVAL * 60 * 60)).await;
                if self.in_vote_period(msg).await {
                    self.stop(context, msg).await;
                }
            }
        // Calculate the results of the election
        } else if self.in_vote_period(msg).await {
            if let Some(g) = msg.guild(context).await {
                let winners = self.winners(&g.id).await.join("\n");
                // Display the first n winning candidates, their names, and their votes
                announce!(
                    context,
                    msg,
                    format!(
                        "@everyone The election is over. The winners are:\n{}",
                        winners,
                    )
                );
                // Clear the votes
                self.votes.get(&g.id).unwrap().write().await.clear();
                // Reset point counts
                for (_user, points) in self.points.get(&g.id).unwrap().read().await.iter() {
                    points.swap(STARTING_POINTS, Ordering::Relaxed);
                }
            }
        }
    }
async fn stop ( & self , context : & Context , msg : & Message ) { // Clear out the proposals and list them in an announcement if self . in_suggestion_period ( msg ) . await { if let Some ( g ) = msg . guild ( context ) . await { role_gate ! ( context g msg " " ) ; let all_candidates = self . upcoming_topics . get ( & g . id ) . unwrap ( ) . read ( ) . await ; // Buffer for the string representation of these candidates let mut candidates_str = String :: new ( ) ; // Clear out all candidates and set their vote counts to zero for ( i , name ) in all_candidates . iter ( ) . enumerate ( ) { self . votes . get ( & g . id ) . unwrap ( ) . write ( ) . await . insert ( i , ( name . clone ( ) , AtomicUsize :: new ( 0 ) , HashMap :: new ( ) ) ) ; // Display the candidates with their indices candidates_str = format ! ( " \n " candidates_str i name ) ; } // Remove all candidates self . upcoming_topics . get ( & g . id ) . unwrap ( ) . write ( ) . await . clear ( ) ; // Store the announcement message for later reporting if let Some ( live_results ) = announce ! ( context msg format ( " \n \n \n \n " candidates_str ) ) { self . results . write ( ) . await . insert ( g . id , live_results ) ; } // Allow user to cast votes, and then automatically stop the count after the // interval time :: sleep ( Duration :: from_secs ( VOTE_INTERVAL * 60 * 60 ) ) . await ; if self . in_vote_period ( msg ) . await { self . stop ( context , msg ) . await ; } } // Calculate the results of the election } else if self . in_vote_period ( msg ) . await { if let Some ( g ) = msg . guild ( context ) . await { let winners = self . winners ( & g . id ) . await . join ( " \n " ) ; // Display the first n winning candidates, their names, and their votes announce ! ( context msg format ( " \n " winners ) ) ; // Clear the votes self . votes . get ( & g . id ) . unwrap ( ) . write ( ) . await . clear ( ) ; // Reset point counts for ( _user , points ) in self . points . get ( & g . id ) . unwrap ( ) . read ( ) . await . iter ( ) { points . swap ( STARTING_POINTS , Ordering :: Relaxed ) ; } } } }
stop: Stops the currently running step of the election
stop : Stops the currently running step of the election
&self
context
&Context
msg
&Message
&self
context
&Context
msg
&Message